

o 
struct PrimePower:
contains two fields: Here, power represents the number of times prime can be used as an integral divisor of the value that was factorized by PrimeFactors. 
o 
Factors:
is a synonym for std::vector<PrimePower

The default copy and move constructors are available. FBB::PrimeFactor objects created using the copy constructor share the prime numbers storage device (the BigIntVector or the stream containing the primes) with their source objects.
o PrimeFactors(BigIntVector &primes):
Prime numbers that were determined while factorizing values are collected in the BigIntVector that is passed as argument to this constructor.Initially the BigIntVector passed as argument may be empty or may contain at least two primes (which must be, respectively, 2 and 3). The prime numbers in primes must be sorted. The constructor does not verify whether the prime numbers are actually sorted, but if the BigIntVector contains primes it does check whether the first two prime numbers are indeed 2 and 3. An FBB::Exception is thrown if this condition is not met. While numbers are being factorized, new prime numbers may be added to primes, and primes can be reused by othher PrimeFactors objects. o PrimeFactors(std::string const &name = ~/.primes \( dq, size_t blockSize = 1000): \( dq
Prime numbers that are determined while factorizing values are collected on a stream whose name is passed as argument to this constructor. By default ~/.primes is used. If name starts with ‘~/, then this string is replaced by the user \( cqs home directory. \( cqPrimes are read from the named stream in blocks of at most blockSize, and new primes are flushed to this stream once blockSize new primes have been generated or when the PrimeFactors object (i.e., the last PrimeFactors object sharing the stream) ceases to exist. If the stream does not yet exist it is created by PrimeFactors. The stream may either be empty, or it must contain sorted and whitespace delimited prime numbers (inserted as hexadecimal BigInt values). The first two primes on this file must be, respectively, 2 and 3. The constructor does not verify whether the prime numbers are actually sorted, but if the stream contains primes it does check whether the first two prime numbers are indeed 2 and 3. An FBB::Exception is thrown if this condition is not met. While numbers are being factorized, new prime numbers may be added to the stream, and the stream can be reused by other PrimeFactors objects.
The default copy and move assignment operators are available. Lefthand side FBB::PrimeFactor objects receiving values from righthand side FBB::PrimeFactor objects using the copy assignment operator share the prime numbers storage device (the BigIntVector or the stream containing the primes) with their righthand side FBB::PrimeFactors arguments.
o Factors const &factorize(BigInt const &value):
The prime factors of value are determined and returned in the PrimeFactors::Factors vectors. While the prime factors of value are determined new prime numbers may be added to the BigIntVector or to the stream that is passed to the PrimeFactors object. The elements of PrimeFactors::Factors are sorted by their prime numbers. The first element contains the values smallest prime number factor. \( cq
#include <iostream> #include <bobcat/primefactors>using namespace std; using namespace FBB;
int main(int argc, char **argv) { PrimeFactors pf1(
/tmp/primes \( dq); PrimeFactors::Factors const *factors = &pf1.factorize(stoull(argv[1])); \( dqcout <<
Using /tmp/primes:\n \( dq; for (auto &factor: *factors) cout << factor.prime << \( dq** \( dq<< factor.power << \( dq\( cq; \( cqvector<BigInt> primes; PrimeFactors pf2(primes); factors = &pf2.factorize(stoull(argv[1]));
cout <<
\n \( dq\( dqUsing BigIntVector:\n \( dq; for (auto &factor: *factors) cout << factor.prime << \( dq** \( dq<< factor.power << \( dq\( cq; \( cqcout <<
\n \( dq\( dqCollected primes: \( dq; \( dqfor (auto &prime: primes) cout << prime <<
\( cq; \( cqcout <<
\n \( cq; } \( cq
If this program is run with argument 1950 it produces the following output:
Using /tmp/primes: 2**1 3**1 5**2 13**1 Using BigIntVector: 2**1 3**1 5**2 13**1 Collected primes: 2 3 5 7 11 13
bobcat/primefactors  defines the class interface
bobcat(7), bigint(3bobcat)
None Reported.
o bobcat_3.25.01x.dsc: detached signature; o bobcat_3.25.01x.tar.gz: source archive; o bobcat_3.25.01x_i386.changes: change log; o libbobcat1_3.25.01x_*.deb: debian package holding the libraries; o libbobcat1dev_3.25.01x_*.deb: debian package holding the libraries, headers and manual pages; o http://sourceforge.net/projects/bobcat: public archive location;
Bobcat is an acronym of ‘Brokkens Own Base Classes And Templates \( cq. \( cq
This is free software, distributed under the terms of the GNU General Public License (GPL).
Frank B. Brokken (f.b.brokken@rug.nl).
libbobcatdev_3&.25&.01x&.tar&.gz  FBB::PRIMEFACTORS (3bobcat)  20052015 
Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.