Blob Blame History Raw
%global pkgname factint

Name:           gap-pkg-%{pkgname}
Version:        1.5.4
Release:        1%{?dist}
Summary:        Advanced methods for factoring integers

License:        GPLv2+
URL:            http://www.gap-system.org/DevelopersPages/StefanKohl/factint.html
Source0:        http://www.gap-system.org/pub/gap/gap4/tar.bz2/packages/%{pkgname}-%{version}.tar.bz2
BuildArch:      noarch

BuildRequires:  gap-devel
BuildRequires:  GAPDoc-latex

Requires:       gap-core

%description
FactInt provides implementations of the following methods for factoring
integers:
- Pollard's p-1
- Williams' p+1
- Elliptic Curves Method (ECM)
- Continued Fraction Algorithm (CFRAC)
- Multiple Polynomial Quadratic Sieve (MPQS)
FactInt also makes use of Richard P. Brent's tables of known factors of
integers of the form bk+/-1 for "small" b.

The ECM method is suited best for finding factors which are neither too
small (i.e. have less than about 12 decimal digits) nor too close to the
square root of the number to be factored.  The MPQS method is designed
for factoring products of two primes of comparable orders of magnitude.
CFRAC is the historical predecessor of the MPQS method.  Pollard's p-1
and Williams' p+1 are useful for finding factors p such that all prime
factors of p-1 (respectively p+1) are "small", e.g. smaller than 1000000.
All factoring methods implemented in this package are probabilistic.  In
particular the time needed by the ECM method depends largely on luck.

FactInt provides a general-purpose factorization routine which uses an
appropriate combination of the methods mentioned above, the Pollard Rho
routine which is implemented in the GAP Library and a variety of tricks
for special cases to obtain a good average performance for "arbitrary"
integers.  At the user's option, FactInt provides detailed information
about the progress of the factorization process.

%prep
%setup -q -n %{pkgname}-%{version}

# Fix encodings
for fil in CHANGES; do
  iconv -f iso8859-1 -t utf-8 $fil > $fil.utf8
  touch -r $fil $fil.utf8
  mv -f $fil.utf8 $fil
done

%build
# Link to main GAP documentation
ln -s %{_gap_dir}/doc ../../doc
mkdir ../pkg
ln -s ../%{pkgname}-%{version} ../pkg/%{pkgname}
gap -l "$PWD/..;%{_gap_dir}" << EOF
MakeGAPDocDoc( "doc", "main.xml", [], "FactInt", "../../..", "MathJax" );
CopyHTMLStyleFiles( "doc" );
GAPDocManualLab( "factint" );
EOF
rm -fr ../../doc ../pkg

%install
mkdir -p %{buildroot}%{_gap_dir}/pkg
cp -a ../%{pkgname}-%{version} %{buildroot}%{_gap_dir}/pkg/%{pkgname}
rm -f %{buildroot}%{_gap_dir}/pkg/%{pkgname}/{readme.txt,relnotes.txt}
rm -f %{buildroot}%{_gap_dir}/pkg/%{pkgname}/doc/*.{aux,bbl,blg,brf,idx,ilg,ind,log,out,pnr,tex,toc}

%check
gap -l "%{buildroot}%{_gap_dir};%{_gap_dir}" << EOF 2>&1 | tee log
LoadPackage("factint");
Test("factint.tst", rec( compareFunction := "uptowhitespace" ));
EOF
grep -Fvq fail log
rm -f log

%files
%doc CHANGES README
%docdir %{_gap_dir}/pkg/%{pkgname}/doc
%{_gap_dir}/pkg/%{pkgname}/

%changelog
* Fri Mar 31 2017 Jerry James <loganjerry@gmail.com> - 1.5.4-1
- New upstream version

* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.3-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

* Tue May  3 2016 Jerry James <loganjerry@gmail.com> - 1.5.3-1
- Initial RPM