scythestat-1.0.3/0000755000175000017500000000000011766141023010710 500000000000000scythestat-1.0.3/scythestat/0000755000175000017500000000000011766141023013103 500000000000000scythestat-1.0.3/scythestat/rng/0000755000175000017500000000000011766141023013671 500000000000000scythestat-1.0.3/scythestat/rng/rtmvnorm.h0000644000175000017500000002364311550656101015655 00000000000000/* * Scythe Statistical Library Copyright (C) 2000-2002 Andrew D. Martin * and Kevin M. Quinn; 2002-present Andrew D. Martin, Kevin M. Quinn, * and Daniel Pemstein. All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify under the terms of the GNU General Public License as * published by Free Software Foundation; either version 2 of the * License, or (at your option) any later version. See the text files * COPYING and LICENSE, distributed with this source code, for further * information. * -------------------------------------------------------------------- * scythestat/rng/rtmvnorm.h * */ /*! * \file rng/rtmvnorm.h * * \brief A truncated multivariate normal random number generator. * * This file provides the class definition for the rtmvnorm class, a * functor that generates random variates from truncated multivariate * normal distributions. * */ #ifndef SCYTHE_RTMVNORM_H #define SCYTHE_RTMVNORM_H #include #include #ifdef SCYTHE_COMPILE_DIRECT #include "matrix.h" #include "rng.h" #include "error.h" #include "algorithm.h" #include "ide.h" #else #include "scythestat/matrix.h" #include "scythestat/rng.h" #include "scythestat/error.h" #include "scythestat/algorithm.h" #include "scythestat/ide.h" #endif namespace scythe { /* Truncated Multivariate Normal Distribution by Gibbs sampling * (Geweke 1991). This is a functor that allows one to * initialize---and optionally burn in---a sampler for a given * truncated multivariate normal distribution on construction * and then make (optionally thinned) draws with calls to the () * operator. * */ /*! \brief Truncated multivariate normal distribution random number * generator. * * This class is a functor that allows one to initialize, and * optionally burn in, a Gibbs sampler (Geweke 1991) for a given * truncated multivariate normal distribution on construction and * then make optionally thinned draws from the distribution with * calls to the () operator. */ template class rtmvnorm { public: /*! \brief Standard constructor. * * This method constructs a functor capable of generating * linearly constrained variates of the form: \f$x \sim * N_n(\mu, \Sigma), a \le Dx \le b\f$. That is, it generates * an object capable of simulating random variables from an * n-variate normal distribution defined by \a mu * (\f$\mu\f$) and \a sigma (\f$\Sigma\f$) subject to fewer * than \f$n\f$ linear constraints, defined by the Matrix \a D * and the bounds vectors \a a and \a b. * * The user may pass optional burn in and thinning * parameters to the constructor. The \a burnin parameter * indicates the number of draws that the sampler should * initially make and throw out on construction. The \a thin * parameter controls the behavior of the functor's () * operator. A thinning parameter of 1 indicates that each * call to operator()() should return the random variate * generated by one iteration of the Gibbs sampler, while a * value of 2 indicates that the sampler should throw every * other variate out, a value of 3 causes operator()() to * iterate the sampler three times before returning, and so on. * * Finally, this constructor inverts \a D before proceeding. * If you have pre-inverted \a D, you can set the \a * preinvertedD flag to true and the functor will not redo the * operation. This helps optimize common cases; for example, * when \a D is simply the identity matrix (and thus equal to * its own inverse), there is no need to compute the inverse. * * \param mu An n x 1 vector of means. \param sigma An n x n * variance-covariance matrix. \param D An n x n linear * constraint definition matrix; should be of rank n. \param a * An n x 1 lower bound vector (may contain infinity or * negative infinity). \param b An n x 1 upper bound vector (may * contain infinity or negative infinity). \param generator * Reference to an rng object \param burnin Optional burnin * parameter; default value is 0. \param thin Optional thinning * parameter; default value is 1. \param preinvertedD Optional * flag with default value of false; if set to true, functor * will not invert \a D. * * \throw scythe_dimension_error (Level 1) * \throw scythe_conformation_error (Level 1) * \throw scythe_invalid_arg (Level 1) * * \see operator()() * \see rng */ template rtmvnorm (const Matrix& mu, const Matrix& sigma, const Matrix& D, const Matrix& a, const Matrix& b, rng& generator, unsigned int burnin = 0, unsigned int thin = 1, bool preinvertedD = false) : mu_ (mu), C_ (mu.rows(), mu.rows(), false), h_ (mu.rows(), 1, false), z_ (mu.rows(), 1, true, 0), generator_ (generator), n_ (mu.rows()), thin_ (thin), iter_ (0) { SCYTHE_CHECK_10(thin == 0, scythe_invalid_arg, "thin must be >= 1"); SCYTHE_CHECK_10(! mu.isColVector(), scythe_dimension_error, "mu not column vector"); SCYTHE_CHECK_10(! sigma.isSquare(), scythe_dimension_error, "sigma not square"); SCYTHE_CHECK_10(! D.isSquare(), scythe_dimension_error, "D not square"); SCYTHE_CHECK_10(! a.isColVector(), scythe_dimension_error, "a not column vector"); SCYTHE_CHECK_10(! b.isColVector(), scythe_dimension_error, "b not column vector"); SCYTHE_CHECK_10(sigma.rows() != n_ || D.rows() != n_ || a.rows() != n_ || b.rows() != n_, scythe_conformation_error, "mu, sigma, D, a, and b not conformable"); // TODO will D * sigma * t(D) always be positive definite, // allowing us to use the faster invpd? if (preinvertedD) Dinv_ = D; else Dinv_ = inv(D); Matrix<> Tinv = inv(D * sigma * t(D)); alpha_ = a - D * mu; beta_ = b - D * mu; // Check truncation bounds if (SCYTHE_DEBUG > 0) { for (unsigned int i = 0; i < n_; ++i) { SCYTHE_CHECK(alpha_(i) >= beta_(i), scythe_invalid_arg, "Truncation bound " << i << " not logically consistent"); } } // Precompute some stuff (see Geweke 1991 pg 7). for (unsigned int i = 0; i < n_; ++i) { C_(i, _) = -(1 / Tinv(i, i)) % Tinv(i, _); C_(i, i) = 0; // not really clever but probably too clever h_(i) = std::sqrt(1 / Tinv(i, i)); SCYTHE_CHECK_30(std::isnan(h_(i)), scythe_invalid_arg, "sigma is not positive definite"); } // Do burnin for (unsigned int i = 0; i < burnin; ++i) sample (); } /*! \brief Generate random variates. * * Iterates the Gibbs sampler and returns a Matrix containing a * single draw from the truncated multivariate random number * generator encapsulated by the instantiated object. Thinning * of sampler draws is specified at construction. * * \see rtmvnorm() */ template Matrix operator() () { do { sample (); } while (iter_ % thin_ != 0); return (mu_ + Dinv_ * z_); } /*! \brief Generate random variates. * * Default template. See general template for details. * * \see operator()(). */ Matrix operator() () { return operator()(); } protected: /* Does one step of the Gibbs sampler (see Geweke 1991 p 6) */ void sample () { double czsum; double above; double below; for (unsigned int i = 0; i < n_; ++i) { // Calculate sum_{j \ne i} c_{ij} z_{j} czsum = 0; for (unsigned int j = 0; j < n_; ++j) { if (i == j) continue; czsum += C_(i, j) * z_(j); } // Calc truncation of conditional univariate std normal below = (alpha_(i) - czsum) / h_(i); above = (beta_(i) - czsum) / h_(i); // Draw random variate z_i z_(i) = h_(i); if (above == std::numeric_limits::infinity()){ if (below == -std::numeric_limits::infinity()) z_(i) *= generator_.rnorm(0, 1); // untruncated else z_(i) *= generator_.rtbnorm_combo(0, 1, below); } else if (below == -std::numeric_limits::infinity()) z_(i) *= generator_.rtanorm_combo(0, 1, above); else z_(i) *= generator_.rtnorm_combo(0, 1, below, above); z_(i) += czsum; } ++iter_; } /* Instance variables */ // Various reused computation matrices with names from // Geweke 1991. Matrix<> mu_; Matrix<> Dinv_; Matrix<> C_; Matrix<> alpha_; Matrix<> beta_; Matrix<> h_; Matrix<> z_; // The current draw of the posterior rng& generator_; // Refernce to random number generator unsigned int n_; // The dimension of the distribution unsigned int thin_; // thinning parameter unsigned int iter_; // The current post-burnin iteration }; } // end namespace scythe #endif scythestat-1.0.3/scythestat/rng/mersenne.h0000644000175000017500000002504611550656101015604 00000000000000/* * Scythe Statistical Library * Copyright (C) 2000-2002 Andrew D. Martin and Kevin M. Quinn; * 2002-present Andrew D. Martin, Kevin M. Quinn, and Daniel * Pemstein. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify * under the terms of the GNU General Public License as published by * Free Software Foundation; either version 2 of the License, or (at * your option) any later version. See the text files COPYING * and LICENSE, distributed with this source code, for further * information. * -------------------------------------------------------------------- * scythestat/rng/mersenne.h * * Provides the class definition for the mersenne random number * generator. This class extends the base rng class by providing an * implementation of runif() based on an implementation of the * mersenne twister, released under the following license: * * A C-program for MT19937, with initialization improved 2002/1/26. * Coded by Takuji Nishimura and Makoto Matsumoto. * * Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, * All rights reserved. * * 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 names of its contributors may not be used to endorse or * promote products derived from this software without specific * prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * CONTRIBUTORS "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 COPYRIGHT OWNER OR * CONTRIBUTORS 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. * * For more information see: * http://www.math.keio.ac.jp/matumoto/emt.html * */ /*! \file mersenne.h * \brief The Mersenne Twister random number generator. * * This file contains the mersenne class, a class that extends * Scythe's base random number generation class (scythe::rng) by * providing an implementation of scythe::rng::runif() using the * Mersenne Twister algorithm. */ #ifndef SCYTHE_MERSENNE_H #define SCYTHE_MERSENNE_H #ifdef SCYTHE_COMPILE_DIRECT #include "rng.h" #else #include "scythestat/rng.h" #endif namespace scythe { #ifdef __MINGW32__ /* constant vector a */ static const unsigned long MATRIX_A = 0x9908b0dfUL; /* most significant w-r bits */ static const unsigned long UPPER_MASK = 0x80000000UL; /* least significant r bits */ static const unsigned long LOWER_MASK = 0x7fffffffUL; #else namespace { /* constant vector a */ const unsigned long MATRIX_A = 0x9908b0dfUL; /* most significant w-r bits */ const unsigned long UPPER_MASK = 0x80000000UL; /* least significant r bits */ const unsigned long LOWER_MASK = 0x7fffffffUL; } #endif /*! \brief The Mersenne Twister random number generator. * * This class defines a random number generator, using the Mersenne * Twister algorithm developed and implemented by Makoto Matsumoto * and Takuji Nishimura (1997, 2002). The period of this random * number generator is \f$2^{19937} - 1\f$. * * The mersenne class extends Scythe's basic random number * generating class, scythe::rng, implementing the interface that it * defines. * * \see rng * \see lecuyer * */ class mersenne: public rng { public: /*! \brief Default constructor * * This constructor generates an unseeded and uninitialized * mersenne object. It is most useful for creating arrays of * random number generators. An uninitialized mersenne object * will be seeded with the default seed (5489UL) automatically * upon use. * * \see mersenne(const mersenne &m) * \see initialize(unsigned long s) */ mersenne () : rng (), mti (N + 1) {} /*! \brief Copy constructor * * This constructor makes a copy of an existing mersenne * object, duplicating its seed and current state exactly. * * \param m An existing mersenne random number generator. * * \see mersenne() */ mersenne (const mersenne &m) : rng (), mti (m.mti) { } /*! \brief Sets the seed. * * This method sets the seed of the random number generator and * readies it to begin generating random numbers. Calling this * function on a mersenne object that is already in use is * supported, although not suggested unless you know what you * are doing. * * \param s A long integer seed. * * \see mersenne() */ void initialize (unsigned long s) { mt[0]= s & 0xffffffffUL; for (mti=1; mti> 30)) + mti); /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */ /* In the previous versions, MSBs of the seed affect */ /* only MSBs of the array mt[]. */ /* 2002/01/09 modified by Makoto Matsumoto */ mt[mti] &= 0xffffffffUL; /* for >32 bit machines */ } } /*! \brief Generate a random uniform variate on (0, 1). * * This routine returns a random double precision floating point * number from the uniform distribution on the interval (0, * 1). This method overloads the pure virtual method of the * same name in the rng base class. * * \see runif(unsigned int, unsigned int) * \see genrand_int32() * \see rng */ inline double runif() { return (((double) genrand_int32()) + 0.5) * (1.0 / 4294967296.0); } /* We have to override the overloaded forms of runif because * overloading the no-arg runif() hides the base class * definition; C++ stops looking once it finds the above. */ /*! \brief Generate a Matrix of random uniform variates. * * This routine returns a Matrix of double precision random * uniform variates. on the interval (0, 1). This method * overloads the virtual method of the same name in the rng base * class. * * This is the general template version of this method and * is called through explicit template instantiation. * * \param rows The number of rows in the returned Matrix. * \param cols The number of columns in the returned Matrix. * * \see runif() * \see rng * * \note We are forced to override this overloaded method * because the 1-arg version of runif() hides the base class's * definition of this method from the compiler, although it * probably should not. */ template inline Matrix runif(unsigned int rows, unsigned int cols) { return rng::runif(rows, cols); } /*! \brief Generate a Matrix of random uniform variates. * * This routine returns a Matrix of double precision random * uniform variates on the interval (0, 1). This method * overloads the virtual method of the same name in the rng base * class. * * This is the default template version of this method and * is called through implicit template instantiation. * * \param rows The number of rows in the returned Matrix. * \param cols The number of columns in the returned Matrix. * * \see runif() * \see rng * * \note We are forced to override this overloaded method * because the 1-arg version of runif() hides the base class's * definition of this method from the compiler, although it * probably should not. */ Matrix runif(unsigned int rows, unsigned int cols) { return rng::runif(rows, cols); } /* generates a random number on [0,0xffffffff]-interval */ /*! \brief Generate a random long integer. * * This method generates a random integer, drawn from the * discrete uniform distribution on the interval [0,0xffffffff]. * * \see runif() * \see initialize(unsigned long s) */ unsigned long genrand_int32() { unsigned long y; static unsigned long mag01[2]={0x0UL, MATRIX_A}; /* mag01[x] = x * MATRIX_A for x=0,1 */ if (mti >= N) { /* generate N words at one time */ int kk; if (mti == N+1) // if init_genrand() has not been called, this->initialize(5489UL); // a default initial seed is used for (kk=0;kk> 1) ^ mag01[y & 0x1UL]; } for (;kk> 1) ^ mag01[y & 0x1UL]; } y = (mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK); mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1UL]; mti = 0; } y = mt[mti++]; /* Tempering */ y ^= (y >> 11); y ^= (y << 7) & 0x9d2c5680UL; y ^= (y << 15) & 0xefc60000UL; y ^= (y >> 18); return y; } protected: /* Period parameters */ static const int N = 624; static const int M = 398; /* the array for the state vector */ unsigned long mt[N]; /* mti==N+1 means mt[N] is not initialized */ int mti; }; } #endif /* SCYTHE_MERSENNE_H */ scythestat-1.0.3/scythestat/rng/lecuyer.h0000644000175000017500000005473411764443500015452 00000000000000/* * Scythe Statistical Library * Copyright (C) 2000-2002 Andrew D. Martin and Kevin M. Quinn; * 2002-present Andrew D. Martin, Kevin M. Quinn, and Daniel * Pemstein. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify * under the terms of the GNU General Public License as published by * Free Software Foundation; either version 2 of the License, or (at * your option) any later version. See the text files COPYING * and LICENSE, distributed with this source code, for further * information. * -------------------------------------------------------------------- * scythestat/rng/lecuyer.h * * Provides the class definition for the L'Ecuyer random number * generator, a rng capable of generating many independent substreams. * This class extends the abstract rng class by implementing runif(). * Based on RngStream.cpp, by Pierre L'Ecuyer. * * Pierre L'Ecuyer agreed to the following dual-licensing terms in an * email received 7 August 2004. This dual-license was prompted by * the Debian maintainers of R and MCMCpack. * * This software is Copyright (C) 2004 Pierre L'Ecuyer. * * License: this code can be used freely for personal, academic, or * non-commercial purposes. For commercial licensing, please contact * P. L'Ecuyer at lecuyer@iro.umontreal.ca. * * This code may also be redistributed and modified under the terms of * the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any * later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * */ /*! \file lecuyer.h * \brief The L'Ecuyer random number generator. * * This file contains the lecuyer class, a class that extends Scythe's * base random number generation class (scythe::rng) by providing an * implementation of scythe::rng::runif(), using L'Ecuyer's algorithm. * */ #ifndef SCYTHE_LECUYER_H #define SCYTHE_LECUYER_H #include #include #include #ifdef SCYTHE_COMPILE_DIRECT #include "rng.h" #else #include "scythestat/rng.h" #endif /* We want to use an anonymous namespace to make the following consts * and functions local to this file, but mingw doesn't play nice with * anonymous namespaces so we do things differently when using the * cross-compiler. */ #ifdef __MINGW32__ #define SCYTHE_MINGW32_STATIC static #else #define SCYTHE_MINGW32_STATIC #endif namespace scythe { #ifndef __MINGW32__ namespace { #endif SCYTHE_MINGW32_STATIC const double m1 = 4294967087.0; SCYTHE_MINGW32_STATIC const double m2 = 4294944443.0; SCYTHE_MINGW32_STATIC const double norm = 1.0 / (m1 + 1.0); SCYTHE_MINGW32_STATIC const double a12 = 1403580.0; SCYTHE_MINGW32_STATIC const double a13n = 810728.0; SCYTHE_MINGW32_STATIC const double a21 = 527612.0; SCYTHE_MINGW32_STATIC const double a23n = 1370589.0; SCYTHE_MINGW32_STATIC const double two17 =131072.0; SCYTHE_MINGW32_STATIC const double two53 =9007199254740992.0; /* 1/2^24 */ SCYTHE_MINGW32_STATIC const double fact = 5.9604644775390625e-8; // The following are the transition matrices of the two MRG // components (in matrix form), raised to the powers -1, 1, 2^76, // and 2^127, resp. SCYTHE_MINGW32_STATIC const double InvA1[3][3] = { // Inverse of A1p0 { 184888585.0, 0.0, 1945170933.0 }, { 1.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 } }; SCYTHE_MINGW32_STATIC const double InvA2[3][3] = { // Inverse of A2p0 { 0.0, 360363334.0, 4225571728.0 }, { 1.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 } }; SCYTHE_MINGW32_STATIC const double A1p0[3][3] = { { 0.0, 1.0, 0.0 }, { 0.0, 0.0, 1.0 }, { -810728.0, 1403580.0, 0.0 } }; SCYTHE_MINGW32_STATIC const double A2p0[3][3] = { { 0.0, 1.0, 0.0 }, { 0.0, 0.0, 1.0 }, { -1370589.0, 0.0, 527612.0 } }; SCYTHE_MINGW32_STATIC const double A1p76[3][3] = { { 82758667.0, 1871391091.0, 4127413238.0 }, { 3672831523.0, 69195019.0, 1871391091.0 }, { 3672091415.0, 3528743235.0, 69195019.0 } }; SCYTHE_MINGW32_STATIC const double A2p76[3][3] = { { 1511326704.0, 3759209742.0, 1610795712.0 }, { 4292754251.0, 1511326704.0, 3889917532.0 }, { 3859662829.0, 4292754251.0, 3708466080.0 } }; SCYTHE_MINGW32_STATIC const double A1p127[3][3] = { { 2427906178.0, 3580155704.0, 949770784.0 }, { 226153695.0, 1230515664.0, 3580155704.0 }, { 1988835001.0, 986791581.0, 1230515664.0 } }; SCYTHE_MINGW32_STATIC const double A2p127[3][3] = { { 1464411153.0, 277697599.0, 1610723613.0 }, { 32183930.0, 1464411153.0, 1022607788.0 }, { 2824425944.0, 32183930.0, 2093834863.0 } }; // Return (a*s + c) MOD m; a, s, c and m must be < 2^35 SCYTHE_MINGW32_STATIC double MultModM (double a, double s, double c, double m) { double v; long a1; v = a * s + c; if (v >= two53 || v <= -two53) { a1 = static_cast (a / two17); a -= a1 * two17; v = a1 * s; a1 = static_cast (v / m); v -= a1 * m; v = v * two17 + a * s + c; } a1 = static_cast (v / m); /* in case v < 0)*/ if ((v -= a1 * m) < 0.0) return v += m; else return v; } // Compute the vector v = A*s MOD m. Assume that -m < s[i] < m. // Works also when v = s. SCYTHE_MINGW32_STATIC void MatVecModM (const double A[3][3], const double s[3], double v[3], double m) { int i; double x[3]; // Necessary if v = s for (i = 0; i < 3; ++i) { x[i] = MultModM (A[i][0], s[0], 0.0, m); x[i] = MultModM (A[i][1], s[1], x[i], m); x[i] = MultModM (A[i][2], s[2], x[i], m); } for (i = 0; i < 3; ++i) v[i] = x[i]; } // Compute the matrix C = A*B MOD m. Assume that -m < s[i] < m. // Note: works also if A = C or B = C or A = B = C. SCYTHE_MINGW32_STATIC void MatMatModM (const double A[3][3], const double B[3][3], double C[3][3], double m) { int i, j; double V[3], W[3][3]; for (i = 0; i < 3; ++i) { for (j = 0; j < 3; ++j) V[j] = B[j][i]; MatVecModM (A, V, V, m); for (j = 0; j < 3; ++j) W[j][i] = V[j]; } for (i = 0; i < 3; ++i) for (j = 0; j < 3; ++j) C[i][j] = W[i][j]; } // Compute the matrix B = (A^(2^e) Mod m); works also if A = B. SCYTHE_MINGW32_STATIC void MatTwoPowModM(const double A[3][3], double B[3][3], double m, long e) { int i, j; /* initialize: B = A */ if (A != B) { for (i = 0; i < 3; ++i) for (j = 0; j < 3; ++j) B[i][j] = A[i][j]; } /* Compute B = A^(2^e) mod m */ for (i = 0; i < e; i++) MatMatModM (B, B, B, m); } // Compute the matrix B = (A^n Mod m); works even if A = B. SCYTHE_MINGW32_STATIC void MatPowModM (const double A[3][3], double B[3][3], double m, long n) { int i, j; double W[3][3]; /* initialize: W = A; B = I */ for (i = 0; i < 3; ++i) for (j = 0; j < 3; ++j) { W[i][j] = A[i][j]; B[i][j] = 0.0; } for (j = 0; j < 3; ++j) B[j][j] = 1.0; /* Compute B = A^n mod m using the binary decomposition of n */ while (n > 0) { if (n % 2) MatMatModM (W, B, B, m); MatMatModM (W, W, W, m); n /= 2; } } // Check that the seeds are legitimate values. Returns 0 if legal // seeds, -1 otherwise. SCYTHE_MINGW32_STATIC int CheckSeed (const unsigned long seed[6]) { int i; for (i = 0; i < 3; ++i) { if (seed[i] >= m1) { SCYTHE_THROW(scythe_randseed_error, "Seed[" << i << "] >= 4294967087, Seed is not set"); return -1; } } for (i = 3; i < 6; ++i) { if (seed[i] >= m2) { SCYTHE_THROW(scythe_randseed_error, "Seed[" << i << "] >= 4294944443, Seed is not set"); return -1; } } if (seed[0] == 0 && seed[1] == 0 && seed[2] == 0) { SCYTHE_THROW(scythe_randseed_error, "First 3 seeds = 0"); return -1; } if (seed[3] == 0 && seed[4] == 0 && seed[5] == 0) { SCYTHE_THROW(scythe_randseed_error, "Last 3 seeds = 0"); return -1; } return 0; } #ifndef __MINGW32__ } // end anonymous namespace #endif /*! \brief The L'Ecuyer random number generator. * * This class defines a random number generator, using Pierre * L'Ecuyer's algorithm (2000) and source code (2001) for * generating multiple simultaneous streams of random uniform * variates. The period of the underlying single-stream generator * is approximately \f$3.1 \times 10^{57}\f$. Each individual * stream is implemented in terms of a sequence of substreams (see * L'Ecuyer et al (2000) for details). * * The lecuyer class extends Scythe's basic random number * generating class, scythe::rng, implementing the interface that * it defines. * * \see rng * \see mersenne * */ class lecuyer : public rng { public: // Constructor /*! \brief Constructor * * This constructor creates an object encapsulating a random * number stream, with an optional name. It also sets the seed * of the stream to the package (default or user-specified) seed * if this is the first stream generated, or, otherwise, to a * value \f$2^{127}\f$ steps ahead of the seed of the previously * constructed stream. * * \param streamname The optional name for the stream. * * \see SetPackageSeed(unsigned long seed[6]) * \see SetSeed(unsigned long seed[6]) * \see SetAntithetic(bool) * \see IncreasedPrecis(bool) * \see name() */ lecuyer (std::string streamname = "") : rng (), streamname_ (streamname) { anti = false; incPrec = false; /* Information on a stream. The arrays {Cg, Bg, Ig} contain * the current state of the stream, the starting state of the * current SubStream, and the starting state of the stream. * This stream generates antithetic variates if anti = true. * It also generates numbers with extended precision (53 bits * if machine follows IEEE 754 standard) if incPrec = true. * nextSeed will be the seed of the next declared RngStream. */ for (int i = 0; i < 6; ++i) { Bg[i] = Cg[i] = Ig[i] = nextSeed[i]; } MatVecModM (A1p127, nextSeed, nextSeed, m1); MatVecModM (A2p127, &nextSeed[3], &nextSeed[3], m2); } /*! \brief Get the stream's name. * * This method returns a stream's name string. * * \see lecuyer(const char*) */ std::string name() const { return streamname_; } /*! \brief Reset the stream. * * This method resets the stream to its initial seeded state. * * \see ResetStartSubstream() * \see ResetNextSubstream() * \see SetSeed(unsigned long seed[6]) */ void ResetStartStream () { for (int i = 0; i < 6; ++i) Cg[i] = Bg[i] = Ig[i]; } /*! \brief Reset the current substream. * * * This method resets the stream to the first state of its * current substream. * * \see ResetStartStream() * \see ResetNextSubstream() * \see SetSeed(unsigned long seed[6]) * */ void ResetStartSubstream () { for (int i = 0; i < 6; ++i) Cg[i] = Bg[i]; } /*! \brief Jump to the next substream. * * This method resets the stream to the first state of its next * substream. * * \see ResetStartStream() * \see ResetStartSubstream() * \see SetSeed(unsigned long seed[6]) * */ void ResetNextSubstream () { MatVecModM(A1p76, Bg, Bg, m1); MatVecModM(A2p76, &Bg[3], &Bg[3], m2); for (int i = 0; i < 6; ++i) Cg[i] = Bg[i]; } /*! \brief Set the package seed. * * This method sets the overall package seed. The default * initial seed is (12345, 12345, 12345, 12345, 12345, 12345). * The package seed is the seed used to initialize the first * constructed random number stream in a given program. * * \param seed An array of six integers to seed the package. * The first three values cannot all equal 0 and must all be * less than 4294967087 while the second trio of integers must * all be less than 4294944443 and not all 0. * * \see SetSeed(unsigned long seed[6]) * * \throw scythe_randseed_error (Level 0) */ static void SetPackageSeed (unsigned long seed[6]) { if (CheckSeed (seed)) return; for (int i = 0; i < 6; ++i) nextSeed[i] = seed[i]; } /*! \brief Set the stream seed. * * This method sets the stream seed which is used to initialize * the state of the given stream. * * \warning This method sets the stream seed in isolation and * does not coordinate with any other streams. Therefore, * using this method without care can result in multiple * streams that overlap in the course of their runs. * * \param seed An array of six integers to seed the stream. * The first three values cannot all equal 0 and must all be * less than 4294967087 while the second trio of integers must * all be less than 4294944443 and not all 0. * * \see SetPackageSeed(unsigned long seed[6]) * \see ResetStartStream() * \see ResetStartSubstream() * \see ResetNextSubstream() * * \throw scythe_randseed_error (Level 0) */ void SetSeed (unsigned long seed[6]) { if (CheckSeed (seed)) return; for (int i = 0; i < 6; ++i) Cg[i] = Bg[i] = Ig[i] = seed[i]; } // XXX: get the cases formula working! /*! \brief Advances the state of the stream. * * This method advances the input \f$n\f$ steps, using the rule: * \f[ * n = * \begin{cases} * 2^e + c \quad if~e > 0, \\ * -2^{-e} + c \quad if~e < 0, \\ * c \quad if~e = 0. * \end{cases} * \f] * * \param e This parameter controls state advancement. * \param c This parameter also controls state advancement. * * \see GetState() * \see ResetStartStream() * \see ResetStartSubstream() * \see ResetNextSubstream() */ void AdvanceState (long e, long c) { double B1[3][3], C1[3][3], B2[3][3], C2[3][3]; if (e > 0) { MatTwoPowModM (A1p0, B1, m1, e); MatTwoPowModM (A2p0, B2, m2, e); } else if (e < 0) { MatTwoPowModM (InvA1, B1, m1, -e); MatTwoPowModM (InvA2, B2, m2, -e); } if (c >= 0) { MatPowModM (A1p0, C1, m1, c); MatPowModM (A2p0, C2, m2, c); } else { MatPowModM (InvA1, C1, m1, -c); MatPowModM (InvA2, C2, m2, -c); } if (e) { MatMatModM (B1, C1, C1, m1); MatMatModM (B2, C2, C2, m2); } MatVecModM (C1, Cg, Cg, m1); MatVecModM (C2, &Cg[3], &Cg[3], m2); } /*! \brief Get the current state. * * This method places the current state of the stream, as * represented by six integers, into the array argument. This * is useful for saving and restoring streams across program * runs. * * \param seed An array of six integers that will hold the state values on return. * * \see AdvanceState() */ void GetState (unsigned long seed[6]) const { for (int i = 0; i < 6; ++i) seed[i] = static_cast (Cg[i]); } /*! \brief Toggle generator precision. * * This method sets the precision level of the given stream. By * default, streams generate random numbers with 32 bit * resolution. If the user invokes this method with \a incp = * true, then the stream will begin to generate variates with * greater precision (53 bits on machines following the IEEE 754 * standard). Calling this method again with \a incp = false * will return the precision of generated numbers to 32 bits. * * \param incp A boolean value where true implies high (most * likely 53 bit) precision and false implies low (32 bit) * precision. * * \see SetAntithetic(bool) */ void IncreasedPrecis (bool incp) { incPrec = incp; } /*! \brief Toggle the orientation of generated random numbers. * * This methods causes the given stream to generate antithetic * (1 - U, where U is the default number generated) when called * with \a a = true. Calling this method with \a a = false will * return generated numbers to their default orientation. * * \param a A boolean value that selects regular or antithetic * variates. * * \see IncreasedPrecis(bool) */ void SetAntithetic (bool a) { anti = a; } /*! \brief Generate a random uniform variate on (0, 1). * * This routine returns a random double precision floating point * number from the uniform distribution on the interval (0, * 1). This method overloads the pure virtual method of the * same name in the rng base class. * * \see runif(unsigned int, unsigned int) * \see RandInt(long, long) * \see rng */ double runif () { if (incPrec) return U01d(); else return U01(); } /* We have to override the overloaded form of runif because * overloading the no-arg runif() hides the base class * definition; C++ stops looking once it finds the above. */ /*! \brief Generate a Matrix of random uniform variates. * * This routine returns a Matrix of double precision random * uniform variates. on the interval (0, 1). This method * overloads the virtual method of the same name in the rng base * class. * * This is the general template version of this method and * is called through explicit template instantiation. * * \param rows The number of rows in the returned Matrix. * \param cols The number of columns in the returned Matrix. * * \see runif() * \see rng * * \note We are forced to override this overloaded method * because the 1-arg version of runif() hides the base class's * definition of this method from the compiler, although it * probably should not. */ template Matrix runif(unsigned int rows, unsigned int cols) { return rng::runif(rows,cols); } /*! \brief Generate a Matrix of random uniform variates. * * This routine returns a Matrix of double precision random * uniform variates on the interval (0, 1). This method * overloads the virtual method of the same name in the rng base * class. * * This is the default template version of this method and * is called through implicit template instantiation. * * \param rows The number of rows in the returned Matrix. * \param cols The number of columns in the returned Matrix. * * \see runif() * \see rng * * \note We are forced to override this overloaded method * because the 1-arg version of runif() hides the base class's * definition of this method from the compiler, although it * probably should not. */ Matrix runif(unsigned int rows, unsigned int cols) { return rng::runif(rows, cols); } /*! \brief Generate the next random integer. * * This method generates a random integer from the discrete * uniform distribution on the interval [\a low, \a high]. * * \param low The lower bound of the interval to evaluate. * \param high the upper bound of the interval to evaluate. * * \see runif() */ long RandInt (long low, long high) { return low + static_cast ((high - low + 1) * runif ()); } protected: // Generate the next random number. // double U01 () { long k; double p1, p2, u; /* Component 1 */ p1 = a12 * Cg[1] - a13n * Cg[0]; k = static_cast (p1 / m1); p1 -= k * m1; if (p1 < 0.0) p1 += m1; Cg[0] = Cg[1]; Cg[1] = Cg[2]; Cg[2] = p1; /* Component 2 */ p2 = a21 * Cg[5] - a23n * Cg[3]; k = static_cast (p2 / m2); p2 -= k * m2; if (p2 < 0.0) p2 += m2; Cg[3] = Cg[4]; Cg[4] = Cg[5]; Cg[5] = p2; /* Combination */ u = ((p1 > p2) ? (p1 - p2) * norm : (p1 - p2 + m1) * norm); return (anti == false) ? u : (1 - u); } // Generate the next random number with extended (53 bits) precision. double U01d () { double u; u = U01(); if (anti) { // Don't forget that U01() returns 1 - u in the antithetic case u += (U01() - 1.0) * fact; return (u < 0.0) ? u + 1.0 : u; } else { u += U01() * fact; return (u < 1.0) ? u : (u - 1.0); } } // Public members of the class start here // The default seed of the package; will be the seed of the first // declared RngStream, unless SetPackageSeed is called. static double nextSeed[6]; /* Instance variables */ double Cg[6], Bg[6], Ig[6]; bool anti, incPrec; std::string streamname_; }; #ifndef SCYTHE_RPACK /* Default seed definition */ double lecuyer::nextSeed[6] = { 12345.0, 12345.0, 12345.0, 12345.0, 12345.0, 12345.0 }; #endif } #endif /* SCYTHE_LECUYER_H */ scythestat-1.0.3/scythestat/rng/wrapped_generator.h0000644000175000017500000001437411550656101017502 00000000000000/* * Scythe Statistical Library * Copyright (C) 2000-2002 Andrew D. Martin and Kevin M. Quinn; * 2002-present Andrew D. Martin, Kevin M. Quinn, and Daniel * Pemstein. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify * under the terms of the GNU General Public License as published by * Free Software Foundation; either version 2 of the License, or (at * your option) any later version. See the text files COPYING * and LICENSE, distributed with this source code, for further * information. * -------------------------------------------------------------------- * scythestat/rng/wrapped_generator.h * * Provides a class definition that allows users to adapt non-Scythe * pseudo-random number generators to Scythe's rng interface. * Specifically, wraps any functor that generators uniform variates on * (0, 1). * */ /*! \file wrapped_generator.h * \brief Adaptor for non-Scythe quasi-random number generators. * * This file contains the wrapped_generator class, a class that * extends Scythe's base random number generation class (scythe::rng) * by allowing an arbitrary random uniform number generator to act as * the engine for random number generation in Scythe. */ #ifndef SCYTHE_WRAPPED_GENERATOR_H #define SCYTHE_WRAPPED_GENERATOR_H #ifdef SCYTHE_COMPILE_DIRECT #include "rng.h" #else #include "scythestat/rng.h" #endif namespace scythe { /*! \brief Adaptor for non-Scythe quasi-random number generators. * * This class defines a wrapper for arbitrary random uniform number * generators, allowing them to act as the underlying engine for * random number generation in Scythe. Specifically, any function * object that overloads the function call operator to return * random uniform deviates on the interval (0, 1). * * The wrapped_generator class extends Scythe's basic random number * generating class, scythe::rng, implementing the interface that it * defines. * * \see rng * \see lecuyer * */ template class wrapped_generator: public rng > { public: /*! \brief Default constructor * * This constructor wraps the provided random uniform number * generating function object, creating an object suitable for * random number generation in Scythe. Note that the function * object is passed by reference and is not copied on * construction. * * \param e A function object that returns uniform random * numbers on (0,1) when invoked. * * \see wrapped_generator(const wrapped_generator& wg) */ wrapped_generator (ENGINE& e) : rng > (), engine (e) {} /*! \brief Copy constructor * * This constructor makes a copy of an existing * wrapped_generator object, duplicating its seed and current * state exactly. Note that this will create a copy of the * underlying function object using the function objects copy * construction semantics. * * \param wg An existing wrapped_generator object. * * \see wrapped_generator(ENGINE& e) */ wrapped_generator(const wrapped_generator& wg) : rng > (), engine (wg.engine) {} /*! \brief Generate a random uniform variate on (0, 1). * * This routine returns a random double precision floating point * number from the uniform distribution on the interval (0, * 1). This method overloads the pure virtual method of the * same name in the rng base class. * * \see runif(unsigned int, unsigned int) * \see rng */ inline double runif() { return engine(); } /* We have to override the overloaded forms of runif because * overloading the no-arg runif() hides the base class * definition; C++ stops looking once it finds the above. */ /*! \brief Generate a Matrix of random uniform variates. * * This routine returns a Matrix of double precision random * uniform variates. on the interval (0, 1). This method * overloads the virtual method of the same name in the rng base * class. * * This is the general template version of this method and * is called through explicit template instantiation. * * \param rows The number of rows in the returned Matrix. * \param cols The number of columns in the returned Matrix. * * \see runif() * \see rng * * \note We are forced to override this overloaded method * because the 1-arg version of runif() hides the base class's * definition of this method from the compiler, although it * probably should not. */ template inline Matrix runif(unsigned int rows, unsigned int cols) { return rng >::runif(rows, cols); } /*! \brief Generate a Matrix of random uniform variates. * * This routine returns a Matrix of double precision random * uniform variates on the interval (0, 1). This method * overloads the virtual method of the same name in the rng base * class. * * This is the default template version of this method and * is called through implicit template instantiation. * * \param rows The number of rows in the returned Matrix. * \param cols The number of columns in the returned Matrix. * * \see runif() * \see rng * * \note We are forced to override this overloaded method * because the 1-arg version of runif() hides the base class's * definition of this method from the compiler, although it * probably should not. */ Matrix runif (unsigned int rows, unsigned int cols) { return rng >::runif(rows, cols); } protected: ENGINE& engine; // The wrapped runif engine }; } // end namespace scythe #endif /* SCYTHE_WRAPPED_GENERATOR_H */ scythestat-1.0.3/scythestat/rng/Makefile.in0000644000175000017500000003320211766141014015656 00000000000000# Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = scythestat/rng DIST_COMMON = $(pkginclude_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = SOURCES = DIST_SOURCES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkgincludedir)" HEADERS = $(pkginclude_HEADERS) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) pkgincludedir = $(includedir)/scythestat/rng ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ DX_CONFIG = @DX_CONFIG@ DX_DOCDIR = @DX_DOCDIR@ DX_DOT = @DX_DOT@ DX_DOXYGEN = @DX_DOXYGEN@ DX_DVIPS = @DX_DVIPS@ DX_EGREP = @DX_EGREP@ DX_ENV = @DX_ENV@ DX_FLAG_chi = @DX_FLAG_chi@ DX_FLAG_chm = @DX_FLAG_chm@ DX_FLAG_doc = @DX_FLAG_doc@ DX_FLAG_dot = @DX_FLAG_dot@ DX_FLAG_html = @DX_FLAG_html@ DX_FLAG_man = @DX_FLAG_man@ DX_FLAG_pdf = @DX_FLAG_pdf@ DX_FLAG_ps = @DX_FLAG_ps@ DX_FLAG_rtf = @DX_FLAG_rtf@ DX_FLAG_xml = @DX_FLAG_xml@ DX_HHC = @DX_HHC@ DX_LATEX = @DX_LATEX@ DX_MAKEINDEX = @DX_MAKEINDEX@ DX_PDFLATEX = @DX_PDFLATEX@ DX_PERL = @DX_PERL@ DX_PROJECT = @DX_PROJECT@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EXEEXT = @EXEEXT@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ VERSION_INFO = @VERSION_INFO@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CXX = @ac_ct_CXX@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ INCLUDES = -I@top_srcdir@/ pkginclude_HEADERS = mersenne.h lecuyer.h wrapped_generator.h rtmvnorm.h all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu scythestat/rng/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu scythestat/rng/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkgincludeHEADERS: $(pkginclude_HEADERS) @$(NORMAL_INSTALL) test -z "$(pkgincludedir)" || $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)" @list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(pkgincludedir)'"; \ $(INSTALL_HEADER) $$files "$(DESTDIR)$(pkgincludedir)" || exit $$?; \ done uninstall-pkgincludeHEADERS: @$(NORMAL_UNINSTALL) @list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(pkgincludedir)'; $(am__uninstall_files_from_dir) ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(HEADERS) installdirs: for dir in "$(DESTDIR)$(pkgincludedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-pkgincludeHEADERS install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkgincludeHEADERS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ ctags distclean distclean-generic distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-pkgincludeHEADERS install-ps \ install-ps-am install-strip installcheck installcheck-am \ installdirs maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic pdf pdf-am ps ps-am tags \ uninstall uninstall-am uninstall-pkgincludeHEADERS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: scythestat-1.0.3/scythestat/rng/Makefile.am0000644000175000017500000000022011550656101015636 00000000000000INCLUDES = -I@top_srcdir@/ pkgincludedir=$(includedir)/scythestat/rng pkginclude_HEADERS = mersenne.h lecuyer.h wrapped_generator.h rtmvnorm.h scythestat-1.0.3/scythestat/matrix.h0000644000175000017500000060006211763751462014517 00000000000000/* * Scythe Statistical Library Copyright (C) 2000-2002 Andrew D. Martin * and Kevin M. Quinn; 2002-present Andrew D. Martin, Kevin M. Quinn, * and Daniel Pemstein. All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify under the terms of the GNU General Public License as * published by Free Software Foundation; either version 2 of the * License, or (at your option) any later version. See the text files * COPYING and LICENSE, distributed with this source code, for further * information. * -------------------------------------------------------------------- * scythe's/matrix.h * */ /*! * \file matrix.h * \brief Definitions of Matrix and related classes and functions. * * This file contains the definitions of the Matrix, Matrix_base, and * associated classes. It also contains a number of external * functions that operate on Matrix objects, such as mathematical * operators. * * Many of the arithmetic and logical operators in this file are * implemented in terms of overloaded template definitions to provide * both generic and default versions of each operation. Generic * templates allow (and force) the user to fully specify the * template type of the returned matrix object (row or column order, * concrete or view) while default templates automatically return * concrete matrices with the ordering of the first or only Matrix * argument to the function. Furthermore, we overload binary * functions to provide scalar by Matrix operations, in addition to * basic Matrix by Matrix arithmetic and logic. Therefore, * definitions for multiple versions appear in the functions list * below. We adopt the convention of providing explicit documentation * for only the most generic Matrix by Matrix version of each of these * operators and describe the behavior of the various overloaded * versions in these documents. */ #ifndef SCYTHE_MATRIX_H #define SCYTHE_MATRIX_H #include #include #include #include #include #include #include #include //#include #include #include #ifdef SCYTHE_COMPILE_DIRECT #include "defs.h" #include "algorithm.h" #include "error.h" #include "datablock.h" #include "matrix_random_access_iterator.h" #include "matrix_forward_iterator.h" #include "matrix_bidirectional_iterator.h" #ifdef SCYTHE_LAPACK #include "lapack.h" #endif #else #include "scythestat/defs.h" #include "scythestat/algorithm.h" #include "scythestat/error.h" #include "scythestat/datablock.h" #include "scythestat/matrix_random_access_iterator.h" #include "scythestat/matrix_forward_iterator.h" #include "scythestat/matrix_bidirectional_iterator.h" #ifdef SCYTHE_LAPACK #include "scythestat/lapack.h" #endif #endif namespace scythe { namespace { // make the uint typedef local to this file /* Convenience typedefs */ typedef unsigned int uint; } /* Forward declare the matrix multiplication functions for *= to use * within Matrix proper . */ template Matrix operator* (const Matrix& lhs, const Matrix& rhs); template Matrix operator* (const Matrix& lhs, const Matrix& rhs); /* forward declaration of the matrix class */ template class Matrix; /*! \brief A helper class for list-wise initialization. * * This class gets used behind the scenes to provide listwise * initialization for Matrix objects. This documentation is mostly * intended for developers. * * The Matrix class's assignment operator returns a ListInitializer * object when passed a scalar. The assignment operator binds before * the comma operator, so this happens first, no matter if there is * one scalar, or a list of scalars on the right hand side of the * assignment sign. The ListInitializer constructor keeps an iterator * to the Matrix that created it and places the initial item at the * head of a list. Then the ListInitializer comma operator gets * called 0 or more times, appending items to the list. At this * point the ListInitializer object gets destructed because the * expression is done and it is just a temporary. All the action is * in the destructor where the list is copied into the Matrix with * R-style recycling. * * To handle chained assignments, such as A = B = C = 1.2 where A, * B, and C are matrices, correctly, we encapsulate the Matrix * population sequence that is typically called by the destructor in * the private function populate, and make Matrix a friend of this * class. The Matrix class contains an assignment operator for * ListInitializer objects that calls this function. When a call * like "A = B = C = 1.2" occurs the compiler first evaluates C = * 1.2 and returns a ListInitializer object. Then, the * ListInitializer assignment operator in the Matrix class (being * called on B = (C = 1.2)) forces the ListInitializer object to * populate C early (it would otherwise not occur until destruction * at the end of th entire call) by calling the populate method and * then does a simple Matrix assignment of B = C and the populated C * and the chain of assignment proceeds from there in the usual * fashion. * * Based on code in Blitz++ (http://www.oonumerics.org/blitz/) by * Todd Veldhuizen. Blitz++ is distributed under the terms of the * GNU GPL. */ template class ListInitializer { // An unbound friend template friend class Matrix; public: ListInitializer (T_elem val, T_iter begin, T_iter end, Matrix* matrix) : vals_ (), iter_ (begin), end_ (end), matrix_ (matrix), populated_ (false) { vals_.push_back(val); } ~ListInitializer () { if (! populated_) populate(); } ListInitializer &operator, (T_elem x) { vals_.push_back(x); return *this; } private: void populate () { typename std::list::iterator vi = vals_.begin(); while (iter_ < end_) { if (vi == vals_.end()) vi = vals_.begin(); *iter_ = *vi; ++iter_; ++vi; } populated_ = true; } std::list vals_; T_iter iter_; T_iter end_; Matrix* matrix_; bool populated_; }; /*! \brief Matrix superclass. * * The Matrix_base class handles Matrix functionality that doesn't * need to be templatized with respect to data type. This helps * reduce code bloat by reducing replication of code for member * functions that don't rely on templating. Furthermore, it * hides all of the implementation details of indexing. The * constructors of this class are protected and end-users should * always work with full-fledged Matrix objects. * * The public functions in this class generally provide Matrix * metadata like information on dimensionality and size. */ template class Matrix_base { protected: /**** CONSTRUCTORS ****/ /* Default constructor */ Matrix_base () : rows_ (0), cols_ (0), rowstride_ (0), colstride_ (0), storeorder_ (ORDER) {} /* Standard constructor */ Matrix_base (uint rows, uint cols) : rows_ (rows), cols_ (cols), storeorder_ (ORDER) { if (ORDER == Col) { rowstride_ = 1; colstride_ = rows; } else { rowstride_ = cols; colstride_ = 1; } } /* Copy constructors * * The first version handles matrices of the same order and * style. The second handles matrices with different * orders/styles. The same- templates are more specific, * so they will always catch same- cases. * */ Matrix_base (const Matrix_base &m) : rows_ (m.rows()), cols_ (m.cols()), rowstride_ (m.rowstride()), colstride_ (m.colstride()) { if (STYLE == View) storeorder_ = m.storeorder(); else storeorder_ = ORDER; } template Matrix_base (const Matrix_base &m) : rows_ (m.rows()), cols_ (m.cols()) { if (STYLE == View) { storeorder_ = m.storeorder(); rowstride_ = m.rowstride(); colstride_ = m.colstride(); } else { storeorder_ = ORDER; if (ORDER == Col) { rowstride_ = 1; colstride_ = rows_; } else { rowstride_ = cols_; colstride_ = 1; } } } /* Submatrix constructor */ template Matrix_base (const Matrix_base &m, uint x1, uint y1, uint x2, uint y2) : rows_ (x2 - x1 + 1), cols_ (y2 - y1 + 1), rowstride_ (m.rowstride()), colstride_ (m.colstride()), storeorder_ (m.storeorder()) { /* Submatrices always have to be views, but the whole * concrete-view thing is just a policy maintained by the * software. Therefore, we need to ensure this constructor * only returns views. There's no neat way to do it but this * is still a compile time check, even if it only reports at * run-time. Of course, we should never get this far. */ if (STYLE == Concrete) { SCYTHE_THROW(scythe_style_error, "Tried to construct a concrete submatrix (Matrix_base)!"); } } /**** DESTRUCTOR ****/ ~Matrix_base () {} /**** OPERRATORS ****/ // I'm defining one just to make sure we don't get any subtle // bugs from defaults being called. Matrix_base& operator=(const Matrix_base& m) { SCYTHE_THROW(scythe_unexpected_default_error, "Unexpected call to Matrix_base default assignment operator"); } /**** MODIFIERS ****/ /* Make this Matrix_base an exact copy of the matrix passed in. * Just like an assignment operator but can be called from a derived * class w/out making the = optor public and doing something * like * *(dynamic_cast (this)) = M; * in the derived class. * * Works across styles, but should be used with care */ template inline void mimic (const Matrix_base &m) { rows_ = m.rows(); cols_ = m.cols(); rowstride_ = m.rowstride(); colstride_ = m.colstride(); storeorder_ = m.storeorder(); } /* Reset the dimensions of this Matrix_base. * * TODO This function is a bit of an interface weakness. It * assumes a resize always means a fresh matrix (concrete or * view) with no slack between dims and strides. This happens to * always be the case when it is called, but it tightly couples * Matrix_base and extending classes. Not a big issue (since * Matrix is probably the only class that will ever extend this) * but something to maybe fix down the road. */ inline void resize (uint rows, uint cols) { rows_ = rows; cols_ = cols; if (ORDER == Col) { rowstride_ = 1; colstride_ = rows; } else { rowstride_ = cols; colstride_ = 1; } storeorder_ = ORDER; } public: /**** ACCESSORS ****/ /*! \brief Returns the total number of elements in the Matrix. * * \see rows() * \see cols() * \see max_size() */ inline uint size () const { return (rows() * cols()); } /*! \brief Returns the number of rows in the Matrix. * * \see size() * \see cols() */ inline uint rows() const { return rows_; } /*! \brief Returns the number of columns in the Matrix. * * \see size() * \see rows() */ inline uint cols () const { return cols_; } /*! \brief Check matrix ordering. * * This method returns the matrix_order of this Matrix. * * \see style() * \see storeorder() */ inline matrix_order order() const { return ORDER; } /*! \brief Check matrix style. * * This method returns the matrix_style of this Matrix. * * \see order() * \see storeorder() */ inline matrix_style style() const { return STYLE; } /*! \brief Returns the storage order of the underlying * DataBlock. * * In view matrices, the storage order of the data may not be the * same as the template ORDER. * * * \see rowstride() * \see colstride() * \see order() * \see style() */ inline matrix_order storeorder () const { return storeorder_; } /*! \brief Returns the in-memory distance between elements in * successive rows of the matrix. * * \see colstride() * \see storeorder() */ inline uint rowstride () const { return rowstride_; } /*! \brief Returns the in-memory distance between elements in * successive columns of the matrix. * * \see rowstride() * \see storeorder() */ inline uint colstride () const { return colstride_; } /*! \brief Returns the maximum possible matrix size. * * Maximum matrix size is simply the highest available unsigned * int on your system. * * \see size() */ inline uint max_size () const { return UINT_MAX; } /*! \brief Returns true if this Matrix is 1x1. * * \see isNull() */ inline bool isScalar () const { return (rows() == 1 && cols() == 1); } /*! \brief Returns true if this Matrix is 1xm. * * \see isColVector() * \see isVector() */ inline bool isRowVector () const { return (rows() == 1); } /*! \brief Returns true if this Matrix is nx1. * * \see isRowVector() * \see isVector() */ inline bool isColVector () const { return (cols() == 1); } /*! \brief Returns true if this Matrix is nx1 or 1xn. * * \see isRowVector() * \see isColVector() */ inline bool isVector () const { return (cols() == 1 || rows() == 1); } /*! \brief Returns true if this Matrix is nxn. * * Null and scalar matrices are both considered square. * * \see isNull() * \see isScalar() */ inline bool isSquare () const { return (cols() == rows()); } /*! \brief Returns true if this Matrix has 0 elements. * * \see empty() * \see isScalar() */ inline bool isNull () const { return (rows() == 0); } /*! \brief Returns true if this Matrix has 0 elements. * * This function is identical to isNull() but conforms to STL * container class conventions. * * \see isNull() */ inline bool empty () const { return (rows() == 0); } /**** HELPERS ****/ /*! \brief Check if an index is in bounds. * * This function takes a single-argument index into a Matrix and * returns true iff that index is within the bounds of the * Matrix. This function is equivalent to the expression: * \code * i < M.size() * \endcode * for a given Matrix M. * * \param i The element index to check. * * \see inRange(uint, uint) */ inline bool inRange (uint i) const { return (i < size()); } /*! \brief Check if an index is in bounds. * * This function takes a two-argument index into a Matrix and * returns true iff that index is within the bounds of the * Matrix. This function is equivalent to the expression: * \code * i < M.rows() && j < M.cols() * \endcode * for a given Matrix M. * * \param i The row value of the index to check. * \param j The column value of the index to check. * * \see inRange(uint) */ inline bool inRange (uint i, uint j) const { return (i < rows() && j < cols()); } protected: /* These methods take offsets into a matrix and convert them * into that actual position in the referenced memory block, * taking stride into account. Protection is debatable. They * could be useful to outside functions in the library but most * callers should rely on the public () operator in the derived * class or iterators. * * Note that these are very fast for concrete matrices but not * so great for views. Of course, the type checks are done at * compile time. */ /* Turn an index into a true offset into the data. */ inline uint index (uint i) const { if (STYLE == View) { if (ORDER == Col) { uint col = i / rows(); uint row = i % rows(); return (index(row, col)); } else { uint row = i / cols(); uint col = i % cols(); return (index(row, col)); } } else return(i); } /* Turn an i, j into an index. */ inline uint index (uint row, uint col) const { if (STYLE == Concrete) { if (ORDER == Col) return (col * rows() + row); else return (row * cols() + col); } else { // view if (storeorder_ == Col) return (col * colstride() + row); else return (row * rowstride() + col); } } /**** INSTANCE VARIABLES ****/ protected: uint rows_; // # of rows uint cols_; // # of cols private: /* The derived class shouldn't have to worry about this * implementation detail. */ uint rowstride_; // the in-memory number of elements from the uint colstride_; // beginning of one column(row) to the next matrix_order storeorder_; // The in-memory storage order of this // matrix. This will always be the // same as ORDER for concrete // matrices but views can look at // matrices with storage orders that // differ from their own. // TODO storeorder is always known at // compile time, so we could probably // add a third template param to deal // with this. That would speed up // views a touch. Bit messy maybe. }; /**** MATRIX CLASS ****/ /*! \brief An STL-compliant matrix container class. * * The Matrix class provides a matrix object with an interface similar * to standard mathematical notation. The class provides a number * of unary and binary operators for manipulating matrices. * Operators provide such functionality as addition, multiplication, * and access to specific elements within the Matrix. One can test * two matrices for equality or use provided methods to test the * size, shape, or symmetry of a given Matrix. In addition, we * provide a number of facilities for saving, loading, and printing * matrices. Other portions of the library provide functions for * manipulating matrices. Most notably, la.h provides definitions * of common linear algebra routines and ide.h defines functions * that perform inversion and decomposition. * * This Matrix data structure sits at the core of the library. In * addition to standard matrix operations, this class allows * multiple matrices to view and modify the same underlying data. * This ability provides an elegant way in which to access and * modify submatrices such as isolated row vectors and greatly * increases the overall flexibility of the class. In addition, we * provide iterators (defined in matrix_random_access_iterator.h, * matrix_forward_iterator.h, and matrix_bidirectional_iterator.h) * that allow Matrix objects to interact seamlessly with the generic * algorithms provided by the Standard Template Library (STL). * * The Matrix class uses template parameters to define multiple * behaviors. Matrices are templated on data type, matrix_order, * and matrix_style. * * Matrix objects can contain elements of any type. For the most * part, uses will wish to fill their matrices with single or double * precision floating point numbers, but matrices of integers, * boolean values, complex numbers, and user-defined types are all * possible and useful. Although the basic book-keeping methods in * the Matrix class will support virtually any type, certain * operators require that one or more mathematical operator be * defined for the given type and many of the functions in the wider * Scythe library expect, or even demand, matrices containing floating * point numbers. * * There are two possible Matrix element orderings, row- or * column-major. Differences in matrix ordering will be most * noticeable at construction time. Constructors that build matrices * from streams or other list-like structures will place elements * into the matrix in its given order. In general, any method that * processes a matrix in order will use the given matrix_order. For * the most part, matrices of both orderings should exhibit the same * performance, but when a trade-off must be made, we err on the * side of column-major ordering. In one respect, this bias is very * strong. If you enable LAPACK/BLAS support in with the * SCYTHE_LAPACK compiler flag, the library will use these optimized * fortran routines to perform a number of operations on column * major matrices; we provide no LAPACK/BLAS support for row-major * matrices. Operations on matrices with mismatched ordering are * legal and supported, but not guaranteed to be as fast as * same-order operations, especially when SCYTHE_LAPACK is enabled. * * There are also two possible styles of Matrix template, concrete * and view. These two types of matrix provide distinct ways in * which to interact with an underlying block of data. * * Concrete matrices behave like matrices in previous * Scythe releases. They directly encapsulate a block of data and * always process it in the same order as it is stored (their * matrix_order always matches the underlying storage order). * All copy constructions and assignments on * concrete matrices make deep copies and it is not possible to use * the reference() method to make a concrete Matrix a view of * another Matrix. Furthermore, concrete matrices are guaranteed to * have unit stride (That is, adjacent Matrix elements are stored * adjacently in memory). * * Views, on the other hand, provide references to data blocks. * More than one view can look at the same underlying block of data, * possibly at different portions of the data at the same time. * Furthermore, a view may look at the data block of a concrete * matrix, perhaps accessing a single row vector or a small * submatrix of a larger matrix. When you copy construct * a view a deep copy is not made, rather the view simply provides * access to the extant block of data underlying the copied object. * Furthermore, when * you assign to a view, you overwrite the data the view is * currently pointing to, rather than generating a new data block. * Together, these behaviors allow * for matrices that view portions of other matrices * (submatrices) and submatrix assignment. Views do not guarantee * unit stride and may even logically access their elements in a * different order than they are stored in memory. Copying between * concretes and views is fully supported and often transparent to * the user. * * There is a fundamental trade-off between concrete matrices and * views. Concrete matrices are simpler to work with, but not * as flexible as views. Because they always have unit stride, * concrete matrices * have fast iterators and access operators but, because they must * always be copied deeply, they provide slow copies (for example, * copy construction of a Matrix returned from a function wastes * cycles). Views are more flexible but also somewhat more * complicated to program with. Furthermore, because they cannot * guarantee unit stride, their iterators and access operations are * somewhat slower than those for concrete matrices. On the other * hand, they provide very fast copies. The average Scythe user may * find that she virtually never works with views directly (although * they can be quite useful in certain situations) but they provide * a variety of functionality underneath the hood of the library and * underpin many common operations. * * \note * The Matrix interface is split between two classes: this Matrix * class and Matrix_base, which Matrix extends. Matrix_base * includes a range of accessors that provide the programmer with * information about such things as the dimensionality of Matrix * objects. */ template class Matrix : public Matrix_base, public DataBlockReference { public: /**** TYPEDEFS ****/ /* Iterator types */ /*! \brief Random Access Iterator type. * * This typedef for matrix_random_access_iterator provides a * convenient shorthand for the default, and most general, * Matrix iterator type. * * \see const_iterator * \see reverse_iterator * \see const_reverse_iterator * \see forward_iterator * \see const_forward_iterator * \see reverse_forward_iterator * \see const_reverse_forward_iterator * \see bidirectional_iterator * \see const_bidirectional_iterator * \see reverse_bidirectional_iterator * \see const_reverse_bidirectional_iterator */ typedef matrix_random_access_iterator iterator; /*! \brief Const Random Access Iterator type. * * This typedef for const_matrix_random_access_iterator provides * a convenient shorthand for the default, and most general, * Matrix const iterator type. * * \see iterator * \see reverse_iterator * \see const_reverse_iterator * \see forward_iterator * \see const_forward_iterator * \see reverse_forward_iterator * \see const_reverse_forward_iterator * \see bidirectional_iterator * \see const_bidirectional_iterator * \see reverse_bidirectional_iterator * \see const_reverse_bidirectional_iterator */ typedef const_matrix_random_access_iterator const_iterator; /*! \brief Reverse Random Access Iterator type. * * This typedef uses std::reverse_iterator to describe a * reversed matrix_random_access_iterator type. This is the * reverse of iterator. * * \see iterator * \see const_iterator * \see const_reverse_iterator * \see forward_iterator * \see const_forward_iterator * \see reverse_forward_iterator * \see const_reverse_forward_iterator * \see bidirectional_iterator * \see const_bidirectional_iterator * \see reverse_bidirectional_iterator * \see const_reverse_bidirectional_iterator */ typedef typename std::reverse_iterator > reverse_iterator; /*! \brief Reverse Const Random Access Iterator type. * * This typedef uses std::reverse_iterator to describe a * reversed const_matrix_random_access_iterator type. This is * the reverse of const_iterator. * * \see iterator * \see const_iterator * \see reverse_iterator * \see forward_iterator * \see const_forward_iterator * \see reverse_forward_iterator * \see const_reverse_forward_iterator * \see bidirectional_iterator * \see const_bidirectional_iterator * \see reverse_bidirectional_iterator * \see const_reverse_bidirectional_iterator */ typedef typename std::reverse_iterator > const_reverse_iterator; /*! \brief Forward Iterator type. * * This typedef for matrix_forward_iterator provides * a convenient shorthand for a fast (when compared to * matrix_random_access_iterator) Matrix iterator type. * * \see iterator * \see const_iterator * \see reverse_iterator * \see const_reverse_iterator * \see const_forward_iterator * \see reverse_forward_iterator * \see const_reverse_forward_iterator * \see bidirectional_iterator * \see const_bidirectional_iterator * \see reverse_bidirectional_iterator * \see const_reverse_bidirectional_iterator */ typedef matrix_forward_iterator forward_iterator; /*! \brief Const Forward Iterator type. * * This typedef for const_matrix_forward_iterator provides a * convenient shorthand for a fast (when compared to * const_matrix_random_access_iterator) const Matrix iterator * type. * * \see iterator * \see const_iterator * \see reverse_iterator * \see const_reverse_iterator * \see forward_iterator * \see reverse_forward_iterator * \see const_reverse_forward_iterator * \see bidirectional_iterator * \see const_bidirectional_iterator * \see reverse_bidirectional_iterator * \see const_reverse_bidirectional_iterator */ typedef const_matrix_forward_iterator const_forward_iterator; /*! \brief Bidirectional Iterator type. * * This typedef for matrix_bidirectional_iterator provides * a convenient shorthand for a compromise (with speed and * flexibility between matrix_random_access_iterator and * matrix_forward_iterator) Matrix iterator type. * * \see iterator * \see const_iterator * \see reverse_iterator * \see const_reverse_iterator * \see forward_iterator * \see const_forward_iterator * \see reverse_forward_iterator * \see const_reverse_forward_iterator * \see const_bidirectional_iterator * \see reverse_bidirectional_iterator * \see const_reverse_bidirectional_iterator */ typedef matrix_bidirectional_iterator bidirectional_iterator; /*! \brief Const Bidirectional Iterator type. * * This typedef for const_matrix_bidirectional_iterator provides * a convenient shorthand for a compromise (with speed and * flexibility between const_matrix_random_access_iterator and * const_matrix_forward_iterator) const Matrix iterator type. * * \see iterator * \see const_iterator * \see reverse_iterator * \see const_reverse_iterator * \see forward_iterator * \see const_forward_iterator * \see reverse_forward_iterator * \see const_reverse_forward_iterator * \see bidirectional_iterator * \see reverse_bidirectional_iterator * \see const_reverse_bidirectional_iterator */ typedef const_matrix_bidirectional_iterator const_bidirectional_iterator; /*! \brief Const Bidirectional Iterator type. * * This typedef uses std::reverse_iterator to describe a * reversed matrix_bidirectional_iterator type. This is * the reverse of bidirectional_iterator. * * \see iterator * \see const_iterator * \see reverse_iterator * \see const_reverse_iterator * \see forward_iterator * \see const_forward_iterator * \see reverse_forward_iterator * \see const_reverse_forward_iterator * \see bidirectional_iterator * \see const_bidirectional_iterator * \see const_reverse_bidirectional_iterator */ typedef typename std::reverse_iterator > reverse_bidirectional_iterator; /*! \brief Reverse Const Bidirectional Iterator type. * * This typedef uses std::reverse_iterator to describe a * reversed const_matrix_bidirectional_iterator type. This is * the reverse of const_bidirectional_iterator. * * \see iterator * \see const_iterator * \see reverse_iterator * \see const_reverse_iterator * \see forward_iterator * \see const_forward_iterator * \see reverse_forward_iterator * \see const_reverse_forward_iterator * \see bidirectional_iterator * \see const_bidirectional_iterator * \see reverse_bidirectional_iterator */ typedef typename std::reverse_iterator > const_reverse_bidirectional_iterator; /*!\brief The Matrix' element type. * * This typedef describes the element type (T_type) of this * Matrix. */ typedef T_type ttype; private: /* Some convenience typedefs */ typedef DataBlockReference DBRef; typedef Matrix_base Base; public: /**** CONSTRUCTORS ****/ /*! \brief Default constructor. * * The default constructor creates an empty/null matrix. Using * null matrices in operations will typically cause errors; this * constructor exists primarily for initialization within * aggregate types. * * \see Matrix(T_type) * \see Matrix(uint, uint, bool, T_type) * \see Matrix(uint, uint, T_iterator) * \see Matrix(const std::string&) * \see Matrix(const Matrix&) * \see Matrix(const Matrix &) * \see Matrix(const Matrix &) * \see Matrix(const Matrix&, uint, uint, uint, uint) * * \b Example: * \include example.matrix.constructor.default.cc */ Matrix () : Base (), DBRef () { } /*! \brief Parameterized type constructor. * * Creates a 1x1 matrix (scalar). * * \param element The scalar value of the constructed Matrix. * * \see Matrix() * \see Matrix(uint, uint, bool, T_type) * \see Matrix(uint, uint, T_iterator) * \see Matrix(const std::string&) * \see Matrix(const Matrix&) * \see Matrix(const Matrix &) * \see Matrix(const Matrix &) * \see Matrix(const Matrix&, uint, uint, uint, uint) * * \throw scythe_alloc_error (Level 1) * * \b Example: * \include example.matrix.constructor.ptype.cc */ Matrix (T_type element) : Base (1, 1), DBRef (1) { data_[Base::index(0)] = element; // ALWAYS use index() } /*! \brief Standard constructor. * * The standard constructor creates a rowsXcols Matrix, filled * with zeros by default. Optionally, you can leave the Matrix * uninitialized, or choose a different fill value. * * \param rows The number of rows in the Matrix. * \param cols The number of columns in the Matrix. * \param fill Indicates whether or not the Matrix should be * initialized. * \param fill_value The scalar value to fill the Matrix with * when fill == true. * * \see Matrix() * \see Matrix(T_type) * \see Matrix(uint, uint, T_iterator) * \see Matrix(const std::string&) * \see Matrix(const Matrix&) * \see Matrix(const Matrix &) * \see Matrix(const Matrix &) * \see Matrix(const Matrix&, uint, uint, uint, uint) * * \throw scythe_alloc_error (Level 1) * * \b Example: * \include example.matrix.constructor.standard.cc */ Matrix (uint rows, uint cols, bool fill = true, T_type fill_value = 0) : Base (rows, cols), DBRef (rows * cols) { // TODO Might use iterator here for abstraction. if (fill) for (uint i = 0; i < Base::size(); ++i) data_[Base::index(i)] = fill_value; // we know data contig } /*! \brief Iterator constructor. * * Creates a \a rows X \a cols matrix, filling it sequentially * (based on this template's matrix_order) with values * referenced by the input iterator \a it. Pointers are a form * of input iterator, so one can use this constructor to * initialize a matrix object from a c-style array. The caller * is responsible for supplying an iterator that won't be * exhausted too soon. * * \param rows The number of rows in the Matrix. * \param cols The number of columns in the Matrix. * \param it The input iterator to read from. * * \see Matrix() * \see Matrix(T_type) * \see Matrix(uint, uint, bool, T_type) * \see Matrix(const std::string&) * \see Matrix(const Matrix&) * \see Matrix(const Matrix &) * \see Matrix(const Matrix &) * \see Matrix(const Matrix&, uint, uint, uint, uint) * * \throw scythe_alloc_error (Level 1) * * \b Example: * \include example.matrix.constructor.iterator.cc */ template Matrix (uint rows, uint cols, T_iterator it) : Base (rows, cols), DBRef (rows * cols) { // TODO again, should probably use iterator for (uint i = 0; i < Base::size(); ++i) { data_[Base::index(i)] = *it; // we know data_ is contig ++it; } } /*! \brief File constructor. * * Constructs a matrix from the contents of a file. The * standard input file format is a simple rectangular text file * with one matrix row per line and spaces delimiting values in * a row. Optionally, one can also use Scythe's old file format * which is a space-delimited, row-major ordered, list of values * with row and column lengths in the first two slots. * * \param path The path of the input file. * \param oldstyle Whether or not to use Scythe's old file format. * * \see Matrix() * \see Matrix(T_type) * \see Matrix(uint, uint, bool, T_type) * \see Matrix(uint, uint, T_iterator) * \see Matrix(const Matrix&) * \see Matrix(const Matrix &) * \see Matrix(const Matrix &) * \see Matrix(const Matrix&, uint, uint, uint, uint) * \see save(const std::string&) * * \throw scythe_alloc_error (Level 1) * \throw scythe_file_error (Level 1) * \throw scythe_bounds_error (Level 3) * * \b Example: * \include example.matrix.constructor.file.cc */ Matrix (const std::string& path, bool oldstyle=false) : Base (), DBRef () { std::ifstream file(path.c_str()); SCYTHE_CHECK_10(! file, scythe_file_error, "Could not open file " << path); if (oldstyle) { uint rows, cols; file >> rows >> cols; resize(rows, cols); std::copy(std::istream_iterator (file), std::istream_iterator(), begin_f()); } else { std::string row; unsigned int cols = -1; std::vector > vals; unsigned int rows = 0; while (std::getline(file, row)) { std::vector column; std::istringstream rowstream(row); std::copy(std::istream_iterator (rowstream), std::istream_iterator(), std::back_inserter(column)); if (cols == -1) cols = (unsigned int) column.size(); SCYTHE_CHECK_10(cols != column.size(), scythe_file_error, "Row " << (rows + 1) << " of input file has " << column.size() << " elements, but should have " << cols); vals.push_back(column); rows++; } resize(rows, cols); for (unsigned int i = 0; i < rows; ++i) operator()(i, _) = Matrix(1, cols, vals[i].begin()); } } /* Copy constructors. Uses template args to set up correct * behavior for both concrete and view matrices. The branches * are no-ops and get optimized away at compile time. * * We have to define this twice because we must explicitly * override the default copy constructor; otherwise it is the * most specific template in a lot of cases and causes ugliness. */ /*! \brief Default copy constructor. * * Copy constructing a concrete Matrix makes an exact copy of M * in a new data block. On the other hand, copy constructing a * view Matrix generates a new Matrix object that references (or * views) M's existing data block. * * \param M The Matrix to copy or make a view of. * * \see Matrix() * \see Matrix(T_type) * \see Matrix(uint, uint, bool, T_type) * \see Matrix(uint, uint, T_iterator) * \see Matrix(const std::string&) * \see Matrix(const Matrix &) * \see Matrix(const Matrix &) * \see Matrix(const Matrix&, uint, uint, uint, uint) * \see copy() * \see copy(const Matrix &) * \see reference(const Matrix &) * * \throw scythe_alloc_error (Level 1) * * \b Example: * \include example.matrix.constructor.copy.cc */ Matrix (const Matrix& M) : Base (M), // this call deals with concrete-view conversions DBRef () { if (STYLE == Concrete) { this->referenceNew(M.size()); scythe::copy(M, *this); } else // STYLE == View this->referenceOther(M); } /*! \brief Cross order and/or style copy constructor. * * Copy constructing a concrete Matrix makes an exact copy of M * in a new data block. On the other hand, copy constructing a * view Matrix generates a new Matrix object that references (or * views) M's existing data block. * * This version of the copy constructor extends Matrix(const * Matrix &) by allowing the user to make concrete copies and * views of matrices that have matrix_order or matrix_style that * does not match that of the constructed Matrix. That is, this * constructor makes it possible to create views of concrete * matrices and concrete copies of views, row-major copies of * col-major matrices, and so on. * * \param M The Matrix to copy or make a view of. * * \see Matrix() * \see Matrix(T_type) * \see Matrix(uint, uint, bool, T_type) * \see Matrix(uint, uint, T_iterator) * \see Matrix(const std::string&) * \see Matrix(const Matrix&) * \see Matrix(const Matrix &) * \see Matrix(const Matrix&, uint, uint, uint, uint) * \see copy() * \see copy(const Matrix &) * \see reference(const Matrix &) * * \throw scythe_alloc_error (Level 1) * * \b Example: * \include example.matrix.constructor.crosscopy.cc */ template Matrix (const Matrix &M) : Base (M), // this call deals with concrete-view conversions DBRef () { if (STYLE == Concrete) { this->referenceNew(M.size()); scythe::copy (M, *this); } else // STYLE == View this->referenceOther(M); } /*! \brief Cross type copy constructor * * The type conversion copy constructor takes a reference to an * existing matrix containing elements of a different type than * the constructed matrix and creates a copy. This constructor * will only work if it is possible to cast elements from the * copied matrix to the type of elements in the constructed * matrix. * * This constructor always creates a deep copy of the existing * matrix, even if the constructed matrix is a view. It is * impossible for a matrix view with one element type to * reference the data block of a matrix containing elements of a * different type. * * \param M The Matrix to copy. * * \see Matrix() * \see Matrix(T_type) * \see Matrix(uint, uint, bool, T_type) * \see Matrix(uint, uint, T_iterator) * \see Matrix(const std::string&) * \see Matrix(const Matrix&) * \see Matrix(const Matrix &) * \see Matrix(const Matrix&, uint, uint, uint, uint) * * \throw scythe_alloc_error (Level 1) * * \b Example: * \include example.matrix.constructor.convcopy.cc */ template Matrix (const Matrix &M) : Base(M), // this call deal with concrete-view conversions DBRef (M.size()) { scythe::copy (M, *this); } /*! \brief Submatrix constructor * * The submatrix constructor takes a reference to an existing * matrix and a set of indices, and generates a new Matrix * object referencing the submatrix described by the indices. * One can only construct a submatrix with a view template and * this constructor will throw an error if one tries to use it * to construct a concrete matrix. * * \note * The submatrix-returning operators provide the same * functionality as this constructor with less obtuse syntax. * Users should generally employ these methods instead of this * constructor. * * \param M The Matrix to view. * \param x1 The first row coordinate, \a x1 <= \a x2. * \param y1 The first column coordinate, \a y1 <= \a y2. * \param x2 The second row coordinate, \a x2 > \a x1. * \param y2 The second column coordinate, \a y2 > \a y1. * * \see Matrix() * \see Matrix(T_type) * \see Matrix(uint, uint, bool, T_type) * \see Matrix(uint, uint, T_iterator) * \see Matrix(const std::string&) * \see Matrix(const Matrix&) * \see Matrix(const Matrix &) * \see Matrix(const Matrix &) * \see operator()(uint, uint, uint, uint) * \see operator()(uint, uint, uint, uint) const * \see operator()(all_elements, uint) * \see operator()(all_elements, uint) const * \see operator()(uint, all_elements) * \see operator()(uint, all_elements) const * \see reference(const Matrix &) * * \throw scythe_style_error (Level 0) * \throw scythe_alloc_error (Level 1) */ template Matrix (const Matrix &M, uint x1, uint y1, uint x2, uint y2) : Base(M, x1, y1, x2, y2), DBRef(M, Base::index(x1, y1)) { /* Submatrices always have to be views, but the whole * concrete-view thing is just a policy maintained by the * software. Therefore, we need to ensure this constructor * only returns views. There's no neat way to do it but this * is still a compile time check, even if it only reports at * run-time. */ if (STYLE == Concrete) { SCYTHE_THROW(scythe_style_error, "Tried to construct a concrete submatrix (Matrix)!"); } } public: /**** DESTRUCTOR ****/ /*!\brief Destructor. */ ~Matrix() {} /**** COPY/REFERENCE METHODS ****/ /* Make this matrix a view of another's data. If this matrix's * previous datablock is not viewed by any other object it is * deallocated. Concrete matrices cannot be turned into views * at run-time! Therefore, we generate an error here if *this * is concrete. */ /*!\brief View another Matrix's data. * * This modifier makes this matrix a view of another's data. * The action detaches the Matrix from its current view; if no * other Matrix views the detached DataBlock, it will be * deallocated. * * Concrete matrices cannot convert into views at * run time. Therefore, it is an error to invoke this method on * a concrete Matrix. * * \param M The Matrix to view. * * \see Matrix(const Matrix&) * \see Matrix(const Matrix &) * \see Matrix(const Matrix &) * \see copy() * \see copy(const Matrix &) * * \throw scythe_style_error (Level 0) * * \b Example: * \include example.matrix.reference.cc */ template inline void reference (const Matrix &M) { if (STYLE == Concrete) { SCYTHE_THROW(scythe_style_error, "Concrete matrices cannot reference other matrices"); } else { this->referenceOther(M); this->mimic(M); } } /*!\brief Create a copy of this matrix. * * Creates a deep copy of this Matrix. The returned concrete * matrix references a newly created DataBlock that contains * values that are identical to, but distinct from, the values * contained in the original Matrix. * * \see Matrix(const Matrix&) * \see Matrix(const Matrix &) * \see Matrix(const Matrix &) * \see copy(const Matrix &) * \see reference(const Matrix &) * * \throw scythe_alloc_error (Level 1) * * \b Example: * \include example.matrix.copy.cc */ inline Matrix copy () const { Matrix res (Base::rows(), Base::cols(), false); std::copy(begin_f(), end_f(), res.begin_f()); return res; } /* Make this matrix a copy of another. The matrix retains its * own order and style in this case, because that can't change * at run time. */ /*!\brief Make this Matrix a copy of another. * * Converts this Matrix into a deep copy of another Matrix. * This Matrix retains its own matrix_order and matrix_style but * contains copies of M's elements and becomes the same size and * shape as M. Calling this method automatically detaches this * Matrix from its previous DataBlock before copying. * * \param M The Matrix to copy. * * \see Matrix(const Matrix&) * \see Matrix(const Matrix &) * \see Matrix(const Matrix &) * \see copy() * \see reference(const Matrix &) * \see detach() * * \throw scythe_alloc_error (Level 1) * * \b Example: * \include example.matrix.copyother.cc */ template inline void copy (const Matrix& M) { resize2Match(M); scythe::copy (M, *this); } /**** INDEXING OPERATORS ****/ /*! \brief Access or modify an element in this Matrix. * * This indexing operator allows the caller to access or modify * the ith (indexed in this Matrix's matrix_order) element of * this Matrix, indexed from 0 to n - 1, where n is the number * of elements in the Matrix. * * \param i The index of the element to access/modify. * * \see operator[](uint) const * \see operator()(uint) * \see operator()(uint) const * \see operator()(uint, uint) * \see operator()(uint, uint) const * * \throw scythe_bounds_error (Level 3) */ inline T_type& operator[] (uint i) { SCYTHE_CHECK_30 (! Base::inRange(i), scythe_bounds_error, "Index " << i << " out of range"); return data_[Base::index(i)]; } /*! \brief Access an element in this Matrix. * * This indexing operator allows the caller to access * the ith (indexed in this Matrix's matrix_order) element of * this Matrix, indexed from 0 to n - 1, where n is the number * of elements in the Matrix. * * \param i The index of the element to access. * * \see operator[](uint) * \see operator()(uint) * \see operator()(uint) const * \see operator()(uint, uint) * \see operator()(uint, uint) const * * \throw scythe_bounds_error (Level 3) */ inline T_type& operator[] (uint i) const { SCYTHE_CHECK_30 (! Base::inRange(i), scythe_bounds_error, "Index " << i << " out of range"); return data_[Base::index(i)]; } /*! \brief Access or modify an element in this Matrix. * * This indexing operator allows the caller to access or modify * the ith (indexed in this Matrix's matrix_order) element of * this Matrix, indexed from 0 to n - 1, where n is the number * of elements in the Matrix. * * \param i The index of the element to access/modify. * * \see operator[](uint) * \see operator[](uint) const * \see operator()(uint) const * \see operator()(uint, uint) * \see operator()(uint, uint) const * * \throw scythe_bounds_error (Level 3) */ inline T_type& operator() (uint i) { SCYTHE_CHECK_30 (! Base::inRange(i), scythe_bounds_error, "Index " << i << " out of range"); return data_[Base::index(i)]; } /*! \brief Access an element in this Matrix. * * This indexing operator allows the caller to access * the ith (indexed in this Matrix's matrix_order) element of * this Matrix, indexed from 0 to n - 1, where n is the number * of elements in the Matrix. * * \param i The index of the element to access. * * \see operator[](uint) * \see operator[](uint) const * \see operator()(uint) * \see operator()(uint, uint) * \see operator()(uint, uint) const * * \throw scythe_bounds_error (Level 3) */ inline T_type& operator() (uint i) const { SCYTHE_CHECK_30 (! Base::inRange(i), scythe_bounds_error, "Index " << i << " out of range"); return data_[Base::index(i)]; } /*! \brief Access or modify an element in this Matrix. * * This indexing operator allows the caller to access or modify * the (i, j)th element of * this Matrix, where i is an element of 0, 1, ..., rows - 1 and * j is an element of 0, 1, ..., columns - 1. * * \param i The row index of the element to access/modify. * \param j The column index of the element to access/modify. * * \see operator[](uint) * \see operator[](uint) const * \see operator()(uint) * \see operator()(uint) const * \see operator()(uint, uint) const * * \throw scythe_bounds_error (Level 3) */ inline T_type& operator() (uint i, uint j) { SCYTHE_CHECK_30 (! Base::inRange(i, j), scythe_bounds_error, "Index (" << i << ", " << j << ") out of range"); return data_[Base::index(i, j)]; } /*! \brief Access an element in this Matrix. * * This indexing operator allows the caller to access * the (i, j)th element of * this Matrix, where i is an element of 0, 1, ..., rows - 1 and * j is an element of 0, 1, ..., columns - 1. * * \param i The row index of the element to access. * \param j The column index of the element to access. * * \see operator[](uint) * \see operator[](uint) const * \see operator()(uint) * \see operator()(uint) const * \see operator() (uint, uint) * * \throw scythe_bounds_error (Level 3) */ inline T_type& operator() (uint i, uint j) const { SCYTHE_CHECK_30 (! Base::inRange(i, j), scythe_bounds_error, "Index (" << i << ", " << j << ") out of range"); return data_[Base::index(i, j)]; } /**** SUBMATRIX OPERATORS ****/ /* Submatrices are always views. An extra (but relatively * cheap) copy constructor call is made when mixing and matching * orders like * * Matrix<> A; * ... * Matrix B = A(2, 2, 4, 4); * * It is technically possible to get around this, by providing * templates of each function of the form * template * Matrix operator() (...) * * but the syntax to call them (crappy return type inference): * * Matrix B = A.template operator()(2, 2, 4, 4) * * is such complete gibberish that I don't think this is worth * the slight optimization. */ /*! \brief Returns a view of a submatrix. * * This operator returns a rectangular submatrix view of this * Matrix with its upper left corner at (x1, y1) and its lower * right corner at (x2, y2). * * \param x1 The upper row of the submatrix. * \param y1 The leftmost column of the submatrix. * \param x2 The lowest row of the submatrix. * \param y2 The rightmost column of the submatrix. * * \see operator()(uint, uint, uint, uint) const * \see operator()(all_elements, uint) * \see operator()(all_elements, uint) const * \see operator()(uint, all_elements) * \see operator()(uint, all_elements) const * * \throw scythe_bounds_error (Level 2) * * \b Example: * \include example.matrix.submatrix.cc */ inline Matrix operator() (uint x1, uint y1, uint x2, uint y2) { SCYTHE_CHECK_20 (! Base::inRange(x1, y1) || ! Base::inRange(x2, y2) || x1 > x2 || y1 > y2, scythe_bounds_error, "Submatrix (" << x1 << ", " << y1 << ") ; (" << x2 << ", " << y2 << ") out of range or ill-formed"); return (Matrix(*this, x1, y1, x2, y2)); } /*! \brief Returns a view of a submatrix. * * This operator returns a rectangular submatrix view of this * Matrix with its upper left corner at (x1, y1) and its lower * right corner at (x2, y2). * * \param x1 The upper row of the submatrix. * \param y1 The leftmost column of the submatrix. * \param x2 The lowest row of the submatrix. * \param y2 The rightmost column of the submatrix. * * \see operator()(uint, uint, uint, uint) * \see operator()(all_elements, uint) * \see operator()(all_elements, uint) const * \see operator()(uint, all_elements) * \see operator()(uint, all_elements) const * * \throw scythe_bounds_error (Level 2) */ inline Matrix operator() (uint x1, uint y1, uint x2, uint y2) const { SCYTHE_CHECK_20 (! Base::inRange(x1, y1) || ! Base::inRange(x2, y2) || x1 > x2 || y1 > y2, scythe_bounds_error, "Submatrix (" << x1 << ", " << y1 << ") ; (" << x2 << ", " << y2 << ") out of range or ill-formed"); return (Matrix(*this, x1, y1, x2, y2)); } /*! \brief Returns a view of a column vector. * * This operator returns a vector view of column j in this Matrix. * * \param a An all_elements object signifying whole vector access. * \param j The column to view. * * \see operator()(uint, uint, uint, uint) * \see operator()(uint, uint, uint, uint) const * \see operator()(all_elements, uint) const * \see operator()(uint, all_elements) * \see operator()(uint, all_elements) const * * \throw scythe_bounds_error (Level 2) * * \b Example: * \include example.matrix.vector.cc */ inline Matrix operator() (const all_elements a, uint j) { SCYTHE_CHECK_20 (j >= Base::cols(), scythe_bounds_error, "Column vector index " << j << " out of range"); return (Matrix (*this, 0, j, Base::rows() - 1, j)); } /*! \brief Returns a view of a column vector. * * This operator returns a vector view of column j in this Matrix. * * \param a An all_elements object signifying whole vector access. * \param j The column to view. * * \see operator()(uint, uint, uint, uint) * \see operator()(uint, uint, uint, uint) const * \see operator()(all_elements, uint) * \see operator()(uint, all_elements) * \see operator()(uint, all_elements) const * * \throw scythe_bounds_error (Level 2) */ inline Matrix operator() (const all_elements a, uint j) const { SCYTHE_CHECK_20 (j >= Base::cols(), scythe_bounds_error, "Column vector index " << j << " out of range"); return (Matrix (*this, 0, j, Base::rows() - 1, j)); } /*! \brief Returns a view of a row vector. * * This operator returns a vector view of row i in this Matrix. * * \param i The row to view. * \param b An all_elements object signifying whole vector access. * * \see operator()(uint, uint, uint, uint) * \see operator()(uint, uint, uint, uint) const * \see operator()(all_elements, uint) * \see operator()(all_elements, uint) const * \see operator()(uint, all_elements) const * * \throw scythe_bounds_error (Level 2) * * \b Example: * \include example.matrix.vector.cc */ inline Matrix operator() (uint i, const all_elements b) { SCYTHE_CHECK_20 (i >= Base::rows(), scythe_bounds_error, "Row vector index " << i << " out of range"); return (Matrix (*this, i, 0, i, Base::cols() - 1)); } /*! \brief Returns a view of a row vector. * * This operator returns a vector view of row i in this Matrix. * * \param i The row to view. * \param b An all_elements object signifying whole vector access. * * \see operator()(uint, uint, uint, uint) * \see operator()(uint, uint, uint, uint) const * \see operator()(all_elements, uint) * \see operator()(all_elements, uint) const * \see operator()(uint, all_elements) * * \throw scythe_bounds_error (Level 2) */ inline Matrix operator() (uint i, const all_elements b) const { SCYTHE_CHECK_20 (i >= Base::rows(), scythe_bounds_error, "Row vector index " << i << " out of range"); return (Matrix (*this, i, 0, i, Base::cols() - 1)); } /*! \brief Returns single element in matrix as scalar type * * This method converts a matrix object to a single scalar * element of whatever type the matrix is composed of. The * method simply returns the element at position zero; if error * checking is turned on the method with throw an error if the * matrix is not, in fact, 1x1. * * \throw scythe_conformation_error (Level 1) */ /**** ASSIGNMENT OPERATORS ****/ /* * As with the copy constructor, we need to * explicitly define the same-order-same-style assignment * operator or the default operator will take over. * * TODO With views, it may be desirable to auto-grow (and, * technically, detach) views to the null matrix. This means * you can write something like: * * Matrix X; * X = ... * * and not run into trouble because you didn't presize. Still, * not sure this won't encourage silly mistakes...need to think * about it. */ /*! \brief Assign the contents of one Matrix to another. * * Like copy construction, assignment works differently for * concrete matrices than it does for views. When you assign to * a concrete Matrix it resizes itself to match the right hand * side Matrix and copies over the values. Like all resizes, * this causes this Matrix to detach() from its original * DataBlock. This means that any views attached to this Matrix * will no longer view this Matrix's data after the assignment; * they will continue to view this Matrix's previous DataBlock. * When you assign to a view it first checks that * the right hand side conforms to its dimensions (by default, * see below), and then copies the right hand side values over * into its current DataBlock, overwriting the current contents. * * Scythe also supports a slightly different model of view * assignment. If the user compiled her program with the * SCYTHE_VIEW_ASSIGNMENT_RECYCLE flag set then it is possible * to copy into a view that is not of the same size as the * Matrix on the right hand side of the equation. In this case, * the operator copies elements from the right hand side * object into this matrix until either this matrix runs out of * room, or the right hand side one does. In the latter case, * the operator starts over at the beginning of the right hand * side object, recycling its values as many times as necessary * to fill the left hand side object. The * SCYTHE_VIEW_ASSIGNMENT_RECYCLE flag does not affect the * behavior of the concrete matrices in any way. * * \param M The Matrix to copy. * * \see operator=(const Matrix&) * \see operator=(T_type x) * \see operator=(ListInitializer) * \see Matrix(const Matrix&) * \see Matrix(const Matrix &) * \see Matrix(const Matrix &) * \see copy() * \see copy(const Matrix &) * \see reference(const Matrix &) * \see resize(uint, uint, bool) * \see detach() * * \throw scythe_conformation_error (Level 1) * \throw scythe_alloc_error (Level 1) * * \b Example: * \include example.matrix.operator.assignment.cc */ Matrix& operator= (const Matrix& M) { if (STYLE == Concrete) { resize2Match(M); scythe::copy (M, *this); } else { #ifndef SCYTHE_VIEW_ASSIGNMENT_RECYCLE SCYTHE_CHECK_10 (Base::size() != M.size(), scythe_conformation_error, "LHS has dimensions (" << Base::rows() << ", " << Base::cols() << ") while RHS has dimensions (" << M.rows() << ", " << M.cols() << ")"); scythe::copy (M, *this); #else copy_recycle(M, *this); #endif } return *this; } /*! \brief Assign the contents of one Matrix to another. * * Like copy construction, assignment works differently for * concrete matrices than it does for views. When you assign to * a concrete Matrix it resizes itself to match the right hand * side Matrix and copies over the values. Like all resizes, * this causes this Matrix to detach() from its original * DataBlock. When you assign to a view it first checks that * the right hand side conforms to its dimensions, and then * copies the right hand side values over into its current * DataBlock, overwriting the current contents. * * Scythe also supports a slightly different model of view * assignment. If the user compiled her program with the * SCYTHE_VIEW_ASSIGNMENT_RECYCLE flag set then it is possible * to copy into a view that is not of the same size as the * Matrix on the right hand side of the equation. In this case, * the operator copies elements from the right hand side * object into this matrix until either this matrix runs out of * room, or the right hand side one does. In the latter case, * the operator starts over at the beginning of the right hand * side object, recycling its values as many times as necessary * to fill the left hand side object. The * SCYTHE_VIEW_ASSIGNMENT_RECYCLE flag does not affect the * behavior of the concrete matrices in any way. * * This version of the assignment operator handles assignments * between matrices of different matrix_order and/or * matrix_style. * * \param M The Matrix to copy. * * \see operator=(const Matrix&) * \see operator=(T_type x) * \see operator=(ListInitializer) * \see Matrix(const Matrix&) * \see Matrix(const Matrix &) * \see Matrix(const Matrix &) * \see copy() * \see copy(const Matrix &) * \see reference(const Matrix &) * \see resize(uint, uint, bool) * \see detach() * * \throw scythe_conformation_error (Level 1) * \throw scythe_alloc_error (Level 1) * * \b Example: * \include example.matrix.operator.assignment.cc */ template Matrix &operator= (const Matrix &M) { if (STYLE == Concrete) { resize2Match(M); scythe::copy (M, *this); } else { #ifndef SCYTHE_VIEW_ASSIGNMENT_RECYCLE SCYTHE_CHECK_10 (Base::size() != M.size(), scythe_conformation_error, "LHS has dimensions (" << Base::rows() << ", " << Base::cols() << ") while RHS has dimensions (" << M.rows() << ", " << M.cols() << ")"); scythe::copy (M, *this); #else copy_recycle(M, *this); #endif } return *this; } /* List-wise initialization behavior is a touch complicated. * List needs to be less than or equal to matrix in size and it * is copied into the matrix with R-style recycling. * * The one issue is that, if you want true assignment of a * scalar to a concrete matrix (resize the matrix to a scalar) * you need to be explicit: * * Matrix<> A(2, 2); * double x = 3; * ... * A = Matrix<>(x); // -> 3 * * A = x; // -> 3 3 * // 3 3 */ /*! \brief Copy values in a comma-separated list into this Matrix. * * This assignment operator allows the user to copy the values in * a bare, comma-separated, list into this Matrix. The list * should have no more elements in it than the Matrix has * elements. If the list has fewer elements than the Matrix, it * will be recycled until the Matrix is full. * * If you wish to convert a concrete Matrix to a scalar-valued * Matrix object you need to explicitly promote the scalar to a * Matrix, using the parameterized type constructor * (Matrix(T_type)). * * \param x The first element in the list. * * \see operator=(const Matrix&) * \see operator=(const Matrix&) * \see operator=(ListInitializer) * \see Matrix(const Matrix&) * \see Matrix(const Matrix &) * \see Matrix(const Matrix &) * \see copy() * \see copy(const Matrix &) * \see reference(const Matrix &) * \see resize(uint, uint, bool) * \see detach() * * \b Example: * \include example.matrix.operator.assignment.cc */ ListInitializer operator=(T_type x) { return (ListInitializer (x, begin(),end(), this)); } /*! \brief A special assignment operator. * * This assignment operator provides the necessary glue to allow * chained assignments of matrices where the last assignment is * achieved through list initialization. This allows users to * write code like * \code * Matrix<> A, B, C; * Matrix<> D(4, 4, false); * A = B = C = (D = 1, 2, 3, 4); * \endcode * where the assignment in the parentheses technically returns a * ListInitializer object, not a Matrix object. The details of * this mechanism are not important for the average user and the * distinction can safely be ignored. * * \note * The parentheses in the code above are necessary because of * the precedence of the assignment operator. * * \see operator=(const Matrix&) * \see operator=(const Matrix&) * \see operator=(T_type x) * * \b Example: * \include example.matrix.operator.assignment.cc */ template Matrix &operator=(ListInitializer li) { li.populate(); *this = *(li.matrix_); return *this; } /**** ARITHMETIC OPERATORS ****/ private: /* Reusable chunk of code for element-wise operator * assignments. Updates are done in-place except for the 1x1 by * nXm case, which forces a resize. */ template inline Matrix& elementWiseOperatorAssignment (const Matrix& M, OP op) { SCYTHE_CHECK_10 (Base::size() != 1 && M.size() != 1 && (Base::rows () != M.rows() || Base::cols() != M.cols()), scythe_conformation_error, "Matrices with dimensions (" << Base::rows() << ", " << Base::cols() << ") and (" << M.rows() << ", " << M.cols() << ") are not conformable"); if (Base::size() == 1) { // 1x1 += nXm T_type tmp = (*this)(0); resize2Match(M); std::transform(M.begin_f(), M.end_f(), begin_f(), std::bind1st(op, tmp)); } else if (M.size() == 1) { // nXm += 1x1 std::transform(begin_f(), end_f(), begin_f(), std::bind2nd(op, M(0))); } else { // nXm += nXm std::transform(begin_f(), end_f(), M.begin_f(), begin_f(), op); } return *this; } public: /*! \brief Add another Matrix to this Matrix. * * This operator sums this Matrix with another and places the * result into this Matrix. The two matrices must have the same * dimensions or one of the matrices must be 1x1. * * \param M The Matrix to add to this one. * * \see operator+=(T_type) * \see operator-=(const Matrix &) * \see operator%=(const Matrix &) * \see operator/=(const Matrix &) * \see operator^=(const Matrix &) * \see operator*=(const Matrix &) * \see kronecker(const Matrix &) * * \throw scythe_conformation_error (Level 1) * \throw scythe_alloc_error (Level 1) */ template inline Matrix& operator+= (const Matrix &M) { return elementWiseOperatorAssignment(M, std::plus ()); } /*! \brief Add a scalar to this Matrix. * * This operator sums each element of this Matrix with the * scalar \a x and places the result into this Matrix. * * \param x The scalar to add to each element. * * \see operator+=(const Matrix &) * \see operator-=(T_type) * \see operator%=(T_type) * \see operator/=(T_type) * \see operator^=(T_type) * \see kronecker(T_type) * * \throw scythe_conformation_error (Level 1) */ inline Matrix& operator+= (T_type x) { return elementWiseOperatorAssignment(Matrix(x), std::plus ()); } /*! \brief Subtract another Matrix from this Matrix. * * This operator subtracts another Matrix from this one and * places the result into this Matrix. The two matrices must * have the same dimensions or one of the matrices must be 1x1. * * \param M The Matrix to subtract from this one. * * \see operator-=(T_type) * \see operator+=(const Matrix &) * \see operator%=(const Matrix &) * \see operator/=(const Matrix &) * \see operator^=(const Matrix &) * \see operator*=(const Matrix &) * \see kronecker(const Matrix &) * * \throw scythe_conformation_error (Level 1) * \throw scythe_alloc_error (Level 1) */ template inline Matrix& operator-= (const Matrix &M) { return elementWiseOperatorAssignment(M, std::minus ()); } /*! \brief Subtract a scalar from this Matrix. * * This operator subtracts \a x from each element of this * Matrix and places the result into this Matrix. * * \param x The scalar to subtract from each element. * * \see operator-=(const Matrix &) * \see operator+=(T_type) * \see operator%=(T_type) * \see operator/=(T_type) * \see operator^=(T_type) * \see kronecker(T_type) * * \throw scythe_conformation_error (Level 1) */ inline Matrix& operator-= (T_type x) { return elementWiseOperatorAssignment(Matrix(x), std::minus ()); } /*! \brief Multiply the elements of this Matrix with another's. * * This operator multiplies the elements of this Matrix with * another's and places the result into this Matrix. The two * matrices must have the same dimensions, or one of the * matrices must be 1x1. * * This operator performs element-by-element multiplication * (calculates the Hadamard product), not conventional matrix * multiplication. * * \param M The Matrix to multiply with this one. * * \see operator%=(T_type) * \see operator+=(const Matrix &) * \see operator-=(const Matrix &) * \see operator/=(const Matrix &) * \see operator^=(const Matrix &) * \see operator*=(const Matrix &) * \see kronecker(const Matrix &) * * \throw scythe_conformation_error (Level 1) * \throw scythe_alloc_error (Level 1) */ template inline Matrix& operator%= (const Matrix &M) { return elementWiseOperatorAssignment(M, std::multiplies ()); } /*! \brief Multiply this Matrix by a scalar. * * This operator multiplies each element of this * Matrix with \a x and places the result into this Matrix. * * \param x The scalar to multiply each element by. * * \see operator%=(const Matrix &) * \see operator+=(T_type) * \see operator-=(T_type) * \see operator/=(T_type) * \see operator^=(T_type) * \see kronecker(T_type) * * \throw scythe_conformation_error (Level 1) */ inline Matrix& operator%= (T_type x) { return elementWiseOperatorAssignment(Matrix(x), std::multiplies ()); } /*! \brief Divide the elements of this Matrix by another's. * * This operator divides the elements of this Matrix by * another's and places the result into this Matrix. The two * matrices must have the same dimensions, or one of the * Matrices must be 1x1. * * \param M The Matrix to divide this one by. * * \see operator/=(T_type) * \see operator+=(const Matrix &) * \see operator-=(const Matrix &) * \see operator%=(const Matrix &) * \see operator^=(const Matrix &) * \see operator*=(const Matrix &) * \see kronecker(const Matrix &) * * \throw scythe_conformation_error (Level 1) * \throw scythe_alloc_error (Level 1) */ template inline Matrix& operator/= (const Matrix &M) { return elementWiseOperatorAssignment(M, std::divides()); } /*! \brief Divide this Matrix by a scalar. * * This operator divides each element of this * Matrix by \a x and places the result into this Matrix. * * \param x The scalar to divide each element by. * * \see operator/=(const Matrix &) * \see operator+=(T_type) * \see operator-=(T_type) * \see operator%=(T_type) * \see operator^=(T_type) * \see kronecker(T_type) * * \throw scythe_conformation_error (Level 1) */ inline Matrix& operator/= (T_type x) { return elementWiseOperatorAssignment(Matrix(x), std::divides ()); } /*! \brief Exponentiate the elements of this Matrix by another's. * * This operator exponentiates the elements of this Matrix by * another's and places the result into this Matrix. The two * matrices must have the same dimensions, or one of the * Matrices must be 1x1. * * \param M The Matrix to exponentiate this one by. * * \see operator^=(T_type) * \see operator+=(const Matrix &) * \see operator-=(const Matrix &) * \see operator%=(const Matrix &) * \see operator^=(const Matrix &) * \see operator*=(const Matrix &) * \see kronecker(const Matrix &) * * \throw scythe_conformation_error (Level 1) * \throw scythe_alloc_error (Level 1) */ template inline Matrix& operator^= (const Matrix &M) { return elementWiseOperatorAssignment(M, exponentiate()); } /*! \brief Exponentiate this Matrix by a scalar. * * This operator exponentiates each element of this * Matrix by \a x and places the result into this Matrix. * * \param x The scalar to exponentiate each element by. * * \see operator^=(const Matrix &) * \see operator+=(T_type) * \see operator-=(T_type) * \see operator%=(T_type) * \see operator/=(T_type) * \see kronecker(T_type) * * \throw scythe_conformation_error (Level 1) */ inline Matrix& operator^= (T_type x) { return elementWiseOperatorAssignment(Matrix(x), exponentiate ()); } /* Matrix mult always disengages views because it generally * requires a resize. We force a disengage in the one place it * isn't absolutely necessary(this->size()==1), for consistency. */ /*! \brief Multiply this Matrix by another. * * This operator multiplies this Matrix by another and places * the result into this Matrix. The two matrices must conform; * this Matrix must have as many columns as the right hand side * Matrix has rows. * * Matrix multiplication always causes a Matrix to detach() from * its current view, because it generally requires a resize(). * Even when it is not absolutely necessary to detach() the * Matrix, this function will do so to maintain consistency. * * Scythe will use LAPACK/BLAS routines to multiply concrete * column-major matrices of double-precision floating point * numbers if LAPACK/BLAS is available and you compile your * program with the SCYTHE_LAPACK flag enabled. * * \param M The Matrix to multiply this one by. * * \see operator*=(T_type) * \see operator+=(const Matrix &) * \see operator-=(const Matrix &) * \see operator%=(const Matrix &) * \see operator/=(const Matrix &) * \see operator^=(const Matrix &) * \see kronecker(const Matrix &) * * \throw scythe_conformation_error (Level 1) * \throw scythe_alloc_error (Level 1) */ template Matrix& operator*= (const Matrix& M) { /* Farm out the work to the plain old * operator and make this * matrix a reference (the only reference) to the result. We * always have to create a new matrix here, so there is no * speed-up from using *=. */ /* This saves a copy over * *this = (*this) * M; * if we're concrete */ Matrix res = (*this) * M; this->referenceOther(res); this->mimic(res); return *this; } /*! \brief Multiply this Matrix by a scalar. * * This operator multiplies each element of this * Matrix with \a x and places the result into this Matrix. * * \note This method is identical in behavior to * operator%=(T_type). It also slightly overgeneralizes matrix * multiplication but makes life easy on the user by allowing * the matrix multiplication operator to work for basic scaler * multiplications. * * \param x The scalar to multiply each element by. * * \see operator*=(const Matrix &) * \see operator+=(T_type) * \see operator-=(T_type) * \see operator%=(T_type) * \see operator/=(T_type) * \see operator^=(T_type) * \see kronecker(T_type) * * \throw scythe_conformation_error (Level 1) */ inline Matrix& operator*= (T_type x) { return elementWiseOperatorAssignment(Matrix(x), std::multiplies ()); } /*! \brief Kronecker multiply this Matrix by another. * * This method computes the Kronecker product of this Matrix and * \a M, and sets the value of this Matrix to the result. * * Kronecker multiplication always causes a Matrix to detach() * from its current view, because it generally requires a * resize(). * * \note This method would have been implemented as an operator * if we had any reasonable operator choices left. * * \param M The Matrix to Kronecker multiply this one by. * * \see kronecker(T_type) * \see operator+=(const Matrix &) * \see operator-=(const Matrix &) * \see operator%=(const Matrix &) * \see operator/=(const Matrix &) * \see operator^=(const Matrix &) * \see operator*=(const Matrix &) * * \throw scythe_alloc_error (Level 1) */ template Matrix& kronecker (const Matrix& M) { uint totalrows = Base::rows() * M.rows(); uint totalcols = Base::cols() * M.cols(); // Even if we're a view, make this guy concrete. Matrix res(totalrows, totalcols, false); /* TODO: This the most natural way to write this in scythe * (with a small optimization based on ordering) but probably * not the fastest because it uses submatrix assignments. * Optimizations should be considered. */ forward_iterator it = begin_f(); if (ORDER == Row) { for (uint row = 0; row < totalrows; row += M.rows()) { for (uint col = 0; col < totalcols; col += M.cols()){ res(row, col, row + M.rows() - 1, col + M.cols() - 1) = (*it) * M; it++; } } } else { for (uint col = 0; col < totalcols; col += M.cols()) { for (uint row = 0; row < totalrows; row += M.rows()){ res(row, col, row + M.rows() - 1, col + M.cols() - 1) = (*it) * M; it++; } } } this->referenceOther(res); this->mimic(res); return *this; } /*! \brief Kronecker multiply this Matrix by a scalar. * * This method Kronecker multiplies this Matrix with some scalar, * \a x. This is a degenerate case of Kronecker * multiplication, simply multiplying every element in the * Matrix by \a x. * * \note This method is identical in behavior to * operator%=(T_type) and operator*=(T_type). * * \param x The scalar to Kronecker multiply this Matrix by. * * \see kronecker(const Matrix &) * \see operator+=(T_type) * \see operator-=(T_type) * \see operator%=(T_type) * \see operator/=(T_type) * \see operator^=(T_type) * \see operator*=(T_type) * */ inline Matrix& kronecker (T_type x) { return elementWiseOperatorAssignment(Matrix(x), std::multiplies ()); } /* Logical assignment operators */ /*! \brief Logically AND this Matrix with another. * * This operator computes the element-wise logical AND of this * Matrix and another and places the result into this Matrix. * That is, after the operation, an element in this Matrix will * evaluate to true (or the type-specific analog of true, * typically 1) iff the corresponding element previously * residing in this Matrix and the corresponding element in \a M * both evaluate to true. The two matrices must have the same * dimensions, or one of the Matrices must be 1x1. * * \param M The Matrix to AND with this one. * * \see operator&=(T_type) * \see operator|=(const Matrix &) * * \throw scythe_conformation_error (Level 1) * \throw scythe_alloc_error (Level 1) */ template inline Matrix& operator&= (const Matrix &M) { return elementWiseOperatorAssignment(M, std::logical_and()); } /*! \brief Logically AND this Matrix with a scalar. * * This operator computes the element-wise logical AND of this * Matrix and a scalar. That is, after the operation, an * element in this Matrix will evaluate to true (or the * type-specific analog of true, typically 1) iff the * corresponding element previously residing in this Matrix and * \a x both evaluate to true. * * \param x The scalar to AND with each element. * * \see operator&=(const Matrix &) * \see operator|=(T_type) * * \throw scythe_conformation_error (Level 1) */ inline Matrix& operator&= (T_type x) { return elementWiseOperatorAssignment(Matrix(x), std::logical_and ()); } /*! \brief Logically OR this Matrix with another. * * This operator computes the element-wise logical OR of this * Matrix and another and places the result into this Matrix. * That is, after the operation, an element in this Matrix will * evaluate to true (or the type-specific analog of true, * typically 1) if the corresponding element previously * residing in this Matrix or the corresponding element in \a M * evaluate to true. The two matrices must have the same * dimensions, or one of the Matrices must be 1x1. * * \param M The Matrix to OR with this one. * * \see operator|=(T_type) * \see operator&=(const Matrix &) * * \throw scythe_conformation_error (Level 1) * \throw scythe_alloc_error (Level 1) */ template inline Matrix& operator|= (const Matrix &M) { return elementWiseOperatorAssignment(M, std::logical_or()); } /*! \brief Logically OR this Matrix with a scalar. * * This operator computes the element-wise logical OR of this * Matrix and a scalar. That is, after the operation, an * element in this Matrix will evaluate to true (or the * type-specific analog of true, typically 1) if the * corresponding element previously residing in this Matrix or * \a x evaluate to true. * * \param x The scalar to OR with each element. * * \see operator|=(const Matrix &) * \see operator&=(T_type) * * \throw scythe_conformation_error (Level 1) */ inline Matrix& operator|= (T_type x) { return elementWiseOperatorAssignment(Matrix(x), std::logical_or ()); } /**** MODIFIERS ****/ /* Resize a matrix view. resize() takes dimensions as * parameters while resize2Match() takes a matrix reference and * uses its dimensions. */ /*! \brief Resize or reshape a Matrix. * * This modifier resizes this Matrix to the given dimensions. * Matrix contents after a resize is undefined (junk) unless the * preserve flag is set to true. In this case, the old contents * of the Matrix remains at the same indices it occupied in the * old Matrix. Any excess capacity is junk. * * Resizing a Matrix ALWAYS disengages it from its current view, * even if the dimensions passed to resize are the same as the * current Matrix's dimensions. Resized matrices point to new, * uninitialized data blocks (technically, the Matrix might * recycle its current block if it is the only Matrix viewing * the block, but callers cannot rely on this). It is important * to realize that concrete matrices behave just like views in * this respect. Any views to a concrete Matrix will be * pointing to a different underlying data block than the * concrete Matrix after the concrete Matrix is resized. * * \param rows The number of rows in the resized Matrix. * \param cols The number of columns in the resized Matrix. * \param preserve Whether or not to retain the current contents * of the Matrix. * * \see resize2Match(const Matrix&, bool) * \see detach() * * \throw scythe_alloc_error (Level 1) */ void resize (uint rows, uint cols, bool preserve=false) { if (preserve) { /* TODO Optimize this case. It is rather clunky. */ Matrix tmp(*this); this->referenceNew(rows * cols); Base::resize(rows, cols); uint min_cols = std::min(Base::cols(), tmp.cols()); uint min_rows = std::min(Base::rows(), tmp.rows()); // TODO use iterators here perhaps if (ORDER == Col) { for (uint j = 0; j < min_cols; ++j) for (uint i = 0; i < min_rows; ++i) (*this)(i, j) = tmp(i, j); } else { for (uint i = 0; i < min_rows; ++i) for (uint j = 0; j < min_cols; ++j) (*this)(i, j) = tmp(i, j); } } else { this->referenceNew(rows * cols); Base::resize(rows, cols); } } /*!\brief Resize a Matrix to match another. * * This modifier resizes this Matrix to match the dimensions of * the argument. In all other respects, it behaves just like * resize(). * * \param M The Matrix providing the dimensions to mimic. * \param preserve Whether or not to train the current contents * of the Matrix. * * \see resize(uint, uint, bool) * \see detach() * * \throw scythe_alloc_error (Level 1) */ template inline void resize2Match(const Matrix &M, bool preserve=false) { resize(M.rows(), M.cols(), preserve); } /* Copy this matrix to a new datablock in contiguous storage */ /*! \brief Copy the contents of this Matrix to a new DataBlock. * * The detach method copies the data viewed by this Matrix to a * fresh DataBlock, detaches this Matrix from its old block and * attaches it to the new block. The old DataBlock will be * deallocated if no other matrices view the block after this * one detaches. * * This method can be used to ensure that this Matrix is the * sole viewer of its DataBlock. It also ensures that the * underlying data is stored contiguously in memory. * * \see copy() * \see resize(uint, uint, bool) * * \throw scythe_alloc_error (Level 1) */ inline void detach () { resize2Match(*this, true); } /* Swap operator: sort of a dual copy constructor. Part of the * standard STL container interface. We only support swaps * between matrices of like order and style because things get * hairy otherwise. The behavior of this for concrete matrices * is a little hairy in any case. * * Matrix<> A, B; * ... // fill in A and B * Matrix v1 = A(_, 1); * A.swap(B); * Matrix v2 = B(_, 1); * * v1 == v2; // evaluates to true * */ /*! \brief Swap this Matrix with another. * * This modifier is much like a dual copy constructor and is * part of the Standard Template Library (STL) * interface for container objects. It is only possible to swap * two matrices of the same matrix_order and matrix_style. When * two matrices are swapped, they trade their underlying * DataBlock and dimensions. This behavior is perfectly natural * for views, but my seem somewhat surprising for concrete * matrices. When two concrete matrices are swapped, any views * that referenced either matrices' DataBlock will reference the * other matrices' DataBlock after the swap. * * \param M - The Matrix to swap with. */ inline void swap (Matrix &M) { Matrix tmp = *this; /* This are just reference() calls, but we do this explicitly * here to avoid throwing errors on the concrete case. While * having a concrete matrix reference another matrix is * generally a bad idea, it is safe when the referenced matrix * is concrete, has the same order, and gets deallocated (or * redirected at another block) like here. */ this->referenceOther(M); this->mimic(M); M.referenceOther(tmp); M.mimic(tmp); } /**** ACCESSORS ****/ /* Accessors that don't access the data itself (that don't rely * on T_type) are in Matrix_base */ /* Are all the elements of this Matrix == 0 */ /*! \brief Returns true if every element in this Matrix equals 0. * * The return value of this method is undefined for null * matrices. * * \see empty() * \see isNull() */ inline bool isZero () const { const_forward_iterator last = end_f(); return (last == std::find_if(begin_f(), last, std::bind1st(std::not_equal_to (), 0))); } /* M(i,j) == 0 when i != j */ /*! \brief Returns true if this Matrix is square and its * off-diagonal elements are all 0. * * The return value of this method is undefined for null * matrices. * * \see isSquare() * \see isIdentity() * \see isLowerTriangular() * \see isUpperTriangular() */ inline bool isDiagonal() const { if (! Base::isSquare()) return false; /* Always travel in order. It would be nice to use iterators * here, but we'd need to take views and their iterators are * too slow at the moment. * TODO redo with views and iterators if optimized. */ if (ORDER == Row) { for (uint i = 0; i < Base::rows(); ++i) { for (uint j = 0; j < Base::cols(); ++j) { if (i != j && (*this)(i, j) != 0) return false; } } } else { // ORDER == Col for (uint j = 0; j < Base::cols(); ++j) { for (uint i = 0; i < Base::rows(); ++i) { if (i != j && (*this)(i, j) != 0) return false; } } } return true; } /* M(I, j) == 0 when i!= j and 1 when i == j */ /*! \brief Returns true if this Matrix is diagonal and its * diagonal elements are all 1s. * * The return value of this method is undefined for null * matrices. * * \see isSquare() * \see isDiagonal() * \see isLowerTriangular() * \see isUpperTriangular() */ inline bool isIdentity () const { if (! Base::isSquare()) return false; // TODO redo with views and iterator if optimized if (ORDER == Row) { for (uint i = 0; i < Base::rows(); ++i) { for (uint j = 0; j < Base::cols(); ++j) { if (i != j) { if ((*this)(i,j) != 0) return false; } else if ((*this)(i,j) != 1) return false; } } } else { // ORDER == Col for (uint j = 0; j < Base::rows(); ++j) { for (uint i = 0; i < Base::cols(); ++i) { if (i != j) { if ((*this)(i,j) != 0) return false; } else if ((*this)(i,j) != 1) return false; } } } return true; } /* M(i,j) == 0 when i < j */ /*! \brief Returns true if all of this Matrix's above-diagonal * elements equal 0. * * The return value of this method is undefined for null * matrices. * * \see isDiagonal() * \see isUpperTriangular */ inline bool isLowerTriangular () const { if (! Base::isSquare()) return false; // TODO view+iterator if optimized if (ORDER == Row) { for (uint i = 0; i < Base::rows(); ++i) for (uint j = i + 1; j < Base::cols(); ++j) if ((*this)(i,j) != 0) return false; } else { for (uint j = 0; j < Base::cols(); ++j) for (uint i = 0; i < j; ++i) if ((*this)(i,j) != 0) return false; } return true; } /* M(i,j) == 0 when i > j */ /*! \brief Returns true if all of this Matrix's below-diagonal * elements equal 0. * * The return value of this method is undefined for null * matrices. * * \see isDiagonal() * \see isLowerTriangular */ inline bool isUpperTriangular () const { if (! Base::isSquare()) return false; // TODO view+iterator if optimized if (ORDER == Row) { for (uint i = 0; i < Base::rows(); ++i) for (uint j = 0; j < i; ++j) if ((*this)(i,j) != 0) return false; } else { for (uint j = 0; j < Base::cols(); ++j) for (uint i = j + 1; i < Base::rows(); ++i) if ((*this)(i,j) != 0) return false; } return true; } /*! \brief Returns true if this Matrix is square and has no * inverse. * * \see isSquare() * \see operator~() */ inline bool isSingular() const { if (! Base::isSquare() || Base::isNull()) return false; if ((~(*this)) == (T_type) 0) return true; return false; } /* Square and t(M) = M(inv(M) * t(M) == I */ /*! Returns true if this Matrix is equal to its transpose. * * A Matrix is symmetric when \f$M^T = M\f$ or, equivalently, * \f$M^{-1} M^T = I\f$. In simple terms, this means that the * (i,j)th element of the Matrix is equal to the (j, i)th * element for all i, j. * * \see isSkewSymmetric() */ inline bool isSymmetric () const { if (! Base::isSquare()) return false; // No point in order optimizing here for (uint i = 1; i < Base::rows(); ++i) for (uint j = 0; j < i; ++j) if ((*this)(i, j) != (*this)(j, i)) return false; return true; } /* The matrix is square and t(A) = -A */ /*! Returns true if this Matrix is equal to its negated * transpose. * * A Matrix is skew symmetric when \f$-M^T = M\f$ or, * equivalently, \f$-M^{-1} M^T = I\f$. In simple terms, this * means that the (i, j)th element of the Matrix is equal to the * negation of the (j, i)th element for all i, j. * * \see isSymmetric() */ inline bool isSkewSymmetric () const { if (! Base::isSquare()) return false; // No point in order optimizing here for (uint i = 1; i < Base::rows(); ++i) for (uint j = 0; j < i; ++j) if ((*this)(i, j) != 0 - (*this)(j, i)) return false; return true; } /*! \brief Test Matrix equality. * * This method returns true if all of \a M's elements are equal * to those in this Matrix. To be equal, two matrices must * be of the same dimension. Matrices with differing * matrix_order or matrix_style may equal one another. * * \param M The Matrix to test equality with. * * \see equals(T_type x) const * \see operator==(const Matrix& lhs, const Matrix& rhs) */ template inline bool equals(const Matrix& M) const { if (data_ == M.getArray() && STYLE == Concrete && S == Concrete) return true; else if (data_ == M.getArray() && Base::rows() == M.rows() && Base::cols() == M.cols()) { return true; } else if (this->isNull() && M.isNull()) return true; else if (Base::rows() != M.rows() || Base::cols() != M.cols()) return false; return std::equal(begin_f(), end_f(), M.template begin_f()); } /*! \brief Test Matrix equality. * * This method returns true if all of the elements in this * Matrix are equal to \a x. * * \param x The scalar value to test equality with. * * \see equals(const Matrix& M) const * \see operator==(const Matrix& lhs, const Matrix& rhs) */ inline bool equals(T_type x) const { const_forward_iterator last = end_f(); return (last == std::find_if(begin_f(), last, std::bind1st(std::not_equal_to (), x))); } /**** OTHER UTILITIES ****/ /*! \brief Returns a pointer to this Matrix's internal data * array. * * This method returns a pointer to the internal data array * contained within the DataBlock that this Matrix references. * * \warning It is generally a bad idea to use this method. We * provide it only for convenience. Please note that, when * working with views, the internal data array may not even be * stored in this Matrix's matrix_order. Furthermore, data * encapsulated by a view will generally not be contiguous * within the data array. It this is a concrete Matrix, * getArray() will always return a pointer to a data array * ordered like this Matrix and in contiguous storage. */ inline T_type* getArray () const { return data_; } /*! \brief Saves a Matrix to disk. * * This method writes the contents of this Matrix to the file * specified by \a path. The user can control file overwriting * with \a flag. The parameter \a header controls the output * style. When one sets \a header to true the Matrix is written * as a space-separated list of values, with the number of rows * and columns placed in the first two positions in the list. * If header is set to false, the file is written as a space * separated ascii block, with end-of-lines indicating ends of * rows. The Matrix is always written out in row-major order. * * \param path The name of the file to write. * \param flag Overwrite flag taking values 'a': append, 'o': * overwrite, or 'n': do not replace. * \param header Boolean value indicating whether to write as a * flat list with dimension header or as a rectangular block. * * \see Matrix(const std::string& file) * \see operator>>(std::istream& is, Matrix& M) * * \throw scythe_invalid_arg (Level 0) * \throw scythe_file_error (Level 0) */ inline void save (const std::string& path, const char flag = 'n', const bool header = false) const { std::ofstream out; if (flag == 'n') { std::fstream temp(path.c_str(), std::ios::in); if (! temp) out.open(path.c_str(), std::ios::out); else { temp.close(); SCYTHE_THROW(scythe_file_error, "Cannot overwrite file " << path << " when flag = n"); } } else if (flag == 'o') out.open(path.c_str(), std::ios::out | std::ios::trunc); else if (flag == 'a') out.open(path.c_str(), std::ios::out | std::ios::app); else SCYTHE_THROW(scythe_invalid_arg, "Invalid flag: " << flag); if (! out) SCYTHE_THROW(scythe_file_error, "Could not open file " << path); if (header) { out << Base::rows() << " " << Base::cols(); for (uint i = 0; i < Base::size(); ++i) out << " " << (*this)[i]; out << std::endl; } else { for (uint i = 0; i < Base::rows(); ++i) { for (uint j = 0; j < Base::cols(); ++j) out << (*this)(i,j) << " "; out << "\n"; } } out.close(); } /**** ITERATOR FACTORIES ****/ /* TODO Write some cpp macro code to reduce this to something * manageable. */ /* Random Access Iterator Factories */ /* Generalized versions */ /*! \brief Get an iterator pointing to the start of a Matrix. * * This is a factory that returns a random_access_iterator that * points to the first element in the given Matrix. * * This is a general template of this function. It allows the * user to generate iterators that iterate over the given Matrix * in any order through an explicit template instantiation. */ template inline matrix_random_access_iterator begin () { return matrix_random_access_iterator(*this); } /*! \brief Get an iterator pointing to the start of a Matrix. * * This is a factory that returns a * const_random_access_iterator that * points to the first element in the given Matrix. * * This is a general template of this function. It allows the * user to generate iterators that iterate over the given Matrix * in any order through an explicit template instantiation. */ template inline const_matrix_random_access_iterator begin() const { return const_matrix_random_access_iterator (*this); } /*! \brief Get an iterator pointing to the end of a Matrix. * * This is a factory that returns a * matrix_random_access_iterator that * points to just after the last element in the given Matrix. * * This is a general template of this function. It allows the * user to generate iterators that iterate over the given Matrix * in any order through an explicit template instantiation. */ template inline matrix_random_access_iterator end () { return (begin() + Base::size()); } /*! \brief Get an iterator pointing to the end of a Matrix. * * This is a factory that returns an * const_matrix_random_access_iterator that * points to just after the last element in the given Matrix. * * This is a general template of this function. It allows the * user to generate iterators that iterate over the given Matrix * in any order through an explicit template instantiation. */ template inline const_matrix_random_access_iterator end () const { return (begin() + Base::size()); } /*! \brief Get a reverse iterator pointing to the end of a Matrix. * * This is a factory that returns a reverse * matrix_random_access_iterator that * points to the last element in the given Matrix. * * This is a general template of this function. It allows the * user to generate iterators that iterate over the given Matrix * in any order through an explicit template instantiation. */ template inline std::reverse_iterator > rbegin() { return std::reverse_iterator > (end()); } /*! \brief Get a reverse iterator pointing to the end of a Matrix. * * This is a factory that returns a reverse * const_matrix_random_access_iterator that points to the last * element in the given Matrix. * * This is a general template of this function. It allows the * user to generate iterators that iterate over the given Matrix * in any order through an explicit template instantiation. */ template inline std::reverse_iterator > rbegin() const { return std::reverse_iterator > (end()); } /*! \brief Get a reverse iterator pointing to the start of a Matrix. * * This is a factory that returns a reverse * matrix_random_access_iterator * that points to the just before the first element in the given * Matrix. * * This is a general template of this function. It allows the * user to generate iterators that iterate over the given Matrix * in any order through an explicit template instantiation. */ template inline std::reverse_iterator > rend() { return std::reverse_iterator > (begin()); } /*! \brief Get a reverse iterator pointing to the start of a Matrix. * * This is a factory that returns a reverse * const_matrix_random_access_iterator that points to the just * before the first element in the given Matrix. * * This is a general template of this function. It allows the * user to generate iterators that iterate over the given Matrix * in any order through an explicit template instantiation. */ template inline std::reverse_iterator > rend() const { return std::reverse_iterator > (begin()); } /* Specific versions --- the generalized versions force you * choose the ordering explicitly. These definitions set up * in-order iteration as a default */ /*! \brief Get an iterator pointing to the start of a Matrix. * * This is a factory that returns a Matrix::iterator that * points to the first element in the given Matrix. * * This is the default template of this function. It allows the * user to generate iterators of a given Matrix without * explicitly stating the order of iteration. The iterator * returned by this function always iterates in the same order * as the given Matrix' matrix_order. */ inline iterator begin () { return iterator(*this); } /*! \brief Get an iterator pointing to the start of a Matrix. * * This is a factory that returns a Matrix::const_iterator that * points to the first element in the given Matrix. * * This is the default template of this function. It allows the * user to generate iterators of a given Matrix without * explicitly stating the order of iteration. The iterator * returned by this function always iterates in the same order * as the given Matrix' matrix_order. */ inline const_iterator begin() const { return const_iterator (*this); } /*! \brief Get an iterator pointing to the end of a Matrix. * * This is a factory that returns an Matrix::iterator that * points to just after the last element in the given Matrix. * * This is the default template of this function. It allows the * user to generate iterators of a given Matrix without * explicitly stating the order of iteration. The iterator * returned by this function always iterates in the same order * as the given Matrix' matrix_order. */ inline iterator end () { return (begin() + Base::size()); } /*! \brief Get an iterator pointing to the end of a Matrix. * * This is a factory that returns an Matrix::const_iterator that * points to just after the last element in the given Matrix. * * This is the default template of this function. It allows the * user to generate iterators of a given Matrix without * explicitly stating the order of iteration. The iterator * returned by this function always iterates in the same order * as the given Matrix' matrix_order. */ inline const_iterator end () const { return (begin() + Base::size()); } /*! \brief Get a reverse iterator pointing to the end of a Matrix. * * This is a factory that returns a Matrix::reverse_iterator that * points to the last element in the given Matrix. * * This is the default template of this function. It allows the * user to generate iterators of a given Matrix without * explicitly stating the order of iteration. The iterator * returned by this function always iterates in the same order * as the given Matrix' matrix_order. */ inline reverse_iterator rbegin() { return reverse_iterator (end()); } /*! \brief Get a reverse iterator pointing to the end of a Matrix. * * This is a factory that returns a * Matrix::const_reverse_iterator that points to the last * element in the given Matrix. * * This is the default template of this function. It allows the * user to generate iterators of a given Matrix without * explicitly stating the order of iteration. The iterator * returned by this function always iterates in the same order * as the given Matrix' matrix_order. */ inline const_reverse_iterator rbegin() const { return const_reverse_iterator (end()); } /*! \brief Get a reverse iterator pointing to the start of a Matrix. * * This is a factory that returns a Matrix::reverse_iterator * that points to the just before the first element in the given * Matrix. * * This is the default template of this function. It allows the * user to generate iterators of a given Matrix without * explicitly stating the order of iteration. The iterator * returned by this function always iterates in the same order * as the given Matrix' matrix_order. */ inline reverse_iterator rend() { return reverse_iterator (begin()); } /*! \brief Get a reverse iterator pointing to the start of a Matrix. * * This is a factory that returns a Matrix::const_reverse_iterator * that points to the just before the first element in the given * Matrix. * * This is the default template of this function. It allows the * user to generate iterators of a given Matrix without * explicitly stating the order of iteration. The iterator * returned by this function always iterates in the same order * as the given Matrix' matrix_order. */ inline const_reverse_iterator rend() const { return const_reverse_iterator (begin()); } /* Forward Iterator Factories */ /* Generalized versions */ /*! \brief Get an iterator pointing to the start of a Matrix. * * This is a factory that returns a matrix_forward_iterator that * points to the first element in the given Matrix. * * This is a general template of this function. It allows the * user to generate iterators that iterate over the given Matrix * in any order through an explicit template instantiation. */ template inline matrix_forward_iterator begin_f () { return matrix_forward_iterator(*this); } /*! \brief Get an iterator pointing to the start of a Matrix. * * This is a factory that returns a * const_matrix_forward_iterator that * points to the first element in the given Matrix. * * This is a general template of this function. It allows the * user to generate iterators that iterate over the given Matrix * in any order through an explicit template instantiation. */ template inline const_matrix_forward_iterator begin_f () const { return const_matrix_forward_iterator (*this); } /*! \brief Get an iterator pointing to the end of a Matrix. * * This is a factory that returns an matrix_forward_iterator that * points to just after the last element in the given Matrix. * * This is a general template of this function. It allows the * user to generate iterators that iterate over the given Matrix * in any order through an explicit template instantiation. */ template inline matrix_forward_iterator end_f () { return (begin_f().set_end()); } /*! \brief Get an iterator pointing to the end of a Matrix. * * This is a factory that returns an * const_matrix_forward_iterator that points to just after the * last element in the given Matrix. * * This is a general template of this function. It allows the * user to generate iterators that iterate over the given Matrix * in any order through an explicit template instantiation. */ template inline const_matrix_forward_iterator end_f () const { return (begin_f().set_end()); } /* Default Versions */ /*! \brief Get an iterator pointing to the start of a Matrix. * * This is a factory that returns a Matrix::forward_iterator that * points to the first element in the given Matrix. * * This is the default template of this function. It allows the * user to generate iterators of a given Matrix without * explicitly stating the order of iteration. The iterator * returned by this function always iterates in the same order * as the given Matrix' matrix_order. */ inline forward_iterator begin_f () { return forward_iterator(*this); } /*! \brief Get an iterator pointing to the start of a Matrix. * * This is a factory that returns a * Matrix::const_forward_iterator that points to the first * element in the given Matrix. * * This is the default template of this function. It allows the * user to generate iterators of a given Matrix without * explicitly stating the order of iteration. The iterator * returned by this function always iterates in the same order * as the given Matrix' matrix_order. */ inline const_forward_iterator begin_f () const { return const_forward_iterator (*this); } /*! \brief Get an iterator pointing to the end of a Matrix. * * This is a factory that returns an Matrix::forward_iterator that * points to just after the last element in the given Matrix. * * This is the default template of this function. It allows the * user to generate iterators of a given Matrix without * explicitly stating the order of iteration. The iterator * returned by this function always iterates in the same order * as the given Matrix' matrix_order. */ inline forward_iterator end_f () { return (begin_f().set_end()); } /*! \brief Get an iterator pointing to the end of a Matrix. * * This is a factory that returns an * Matrix::const_forward_iterator that points to just after the * last element in the given Matrix. * * This is the default template of this function. It allows the * user to generate iterators of a given Matrix without * explicitly stating the order of iteration. The iterator * returned by this function always iterates in the same order * as the given Matrix' matrix_order. */ inline const_forward_iterator end_f () const { return (begin_f().set_end()); } /* Bidirectional Iterator Factories */ /* Generalized versions */ /*! \brief Get an iterator pointing to the start of a Matrix. * * This is a factory that returns a * matrix_bidirectional_iterator that * points to the first element in the given Matrix. * * This is a general template of this function. It allows the * user to generate iterators that iterate over the given Matrix * in any order through an explicit template instantiation. */ template inline matrix_bidirectional_iterator begin_bd () { return matrix_bidirectional_iterator(*this); } /*! \brief Get an iterator pointing to the start of a Matrix. * * This is a factory that returns a * const_matrix_bidirectional_iterator that points to the first * element in the given Matrix. * * This is a general template of this function. It allows the * user to generate iterators that iterate over the given Matrix * in any order through an explicit template instantiation. */ template inline const_matrix_bidirectional_iterator begin_bd () const { return const_matrix_bidirectional_iterator (*this); } /*! \brief Get an iterator pointing to the end of a Matrix. * * This is a factory that returns an * matrix_bidirectional_iterator that points to just after the * last element in the given Matrix. * * This is a general template of this function. It allows the * user to generate iterators that iterate over the given Matrix * in any order through an explicit template instantiation. */ template inline matrix_bidirectional_iterator end_bd () { return (begin_bd().set_end()); } /*! \brief Get an iterator pointing to the end of a Matrix. * * This is a factory that returns an * const_matrix_bidirectional_iterator that points to just after * the last element in the given Matrix. * * This is a general template of this function. It allows the * user to generate iterators that iterate over the given Matrix * in any order through an explicit template instantiation. */ template inline const_matrix_bidirectional_iterator end_bd () const { return (begin_bd.set_end()); } /*! \brief Get a reverse iterator pointing to the end of a Matrix. * * This is a factory that returns a reverse * matrix_bidirectional_iterator that points to the last element * in the given Matrix. * * This is a general template of this function. It allows the * user to generate iterators that iterate over the given Matrix * in any order through an explicit template instantiation. */ template inline std::reverse_iterator > rbegin_bd () { return std::reverse_iterator > (end_bd()); } /*! \brief Get a reverse iterator pointing to the end of a Matrix. * * This is a factory that returns a reverse * const_matrix_bidirectional_iterator that points to the last * element in the given Matrix. * * This is a general template of this function. It allows the * user to generate iterators that iterate over the given Matrix * in any order through an explicit template instantiation. */ template inline std::reverse_iterator > rbegin_bd () const { return std::reverse_iterator > (end_bd()); } /*! \brief Get a reverse iterator pointing to the start of a Matrix. * * This is a factory that returns a reverse * matrix_bidirectional_iterator that points to the just before * the first element in the given * Matrix. * * This is a general template of this function. It allows the * user to generate iterators that iterate over the given Matrix * in any order through an explicit template instantiation. */ template inline std::reverse_iterator > rend_bd () { return std::reverse_iterator > (begin_bd()); } /*! \brief Get a reverse iterator pointing to the start of a Matrix. * * This is a factory that returns a reverse * const_matrix_bidirectional_iterator that points to the just * before the first element in the given Matrix. * * This is a general template of this function. It allows the * user to generate iterators that iterate over the given Matrix * in any order through an explicit template instantiation. */ template inline std::reverse_iterator > rend_bd () const { return std::reverse_iterator > (begin_bd()); } /* Specific versions --- the generalized versions force you * choose the ordering explicitly. These definitions set up * in-order iteration as a default */ /*! \brief Get an iterator pointing to the start of a Matrix. * * This is a factory that returns a * Matrix::bidirectional_iterator that points to the first * element in the given Matrix. * * This is the default template of this function. It allows the * user to generate iterators of a given Matrix without * explicitly stating the order of iteration. The iterator * returned by this function always iterates in the same order * as the given Matrix' matrix_order. */ inline bidirectional_iterator begin_bd () { return bidirectional_iterator(*this); } /*! \brief Get an iterator pointing to the start of a Matrix. * * This is a factory that returns a * Matrix::const_bidirectional_iterator that points to the first * element in the given Matrix. * * This is the default template of this function. It allows the * user to generate iterators of a given Matrix without * explicitly stating the order of iteration. The iterator * returned by this function always iterates in the same order * as the given Matrix' matrix_order. */ inline const_bidirectional_iterator begin_bd() const { return const_bidirectional_iterator (*this); } /*! \brief Get an iterator pointing to the end of a Matrix. * * This is a factory that returns an * Matrix::bidirectional_iterator that points to just after the * last element in the given Matrix. * * This is the default template of this function. It allows the * user to generate iterators of a given Matrix without * explicitly stating the order of iteration. The iterator * returned by this function always iterates in the same order * as the given Matrix' matrix_order. */ inline bidirectional_iterator end_bd () { return (begin_bd().set_end()); } /*! \brief Get an iterator pointing to the end of a Matrix. * * This is a factory that returns an Matrix::const_bidirectional * iterator that points to just after the last element in the * given Matrix. * * This is the default template of this function. It allows the * user to generate iterators of a given Matrix without * explicitly stating the order of iteration. The iterator * returned by this function always iterates in the same order * as the given Matrix' matrix_order. */ inline const_bidirectional_iterator end_bd () const { return (begin_bd().set_end()); } /*! \brief Get a reverse iterator pointing to the end of a Matrix. * * This is a factory that returns a * Matrix::reverse_bidirectional_iterator that points to the * last element in the given Matrix. * * This is the default template of this function. It allows the * user to generate iterators of a given Matrix without * explicitly stating the order of iteration. The iterator * returned by this function always iterates in the same order * as the given Matrix' matrix_order. */ inline reverse_bidirectional_iterator rbegin_bd() { return reverse_bidirectional_iterator (end_bd()); } /*! \brief Get a reverse iterator pointing to the end of a Matrix. * * This is a factory that returns a * Matrix::const_reverse_bidirectional_iterator that points to * the last element in the given Matrix. * * This is the default template of this function. It allows the * user to generate iterators of a given Matrix without * explicitly stating the order of iteration. The iterator * returned by this function always iterates in the same order * as the given Matrix' matrix_order. */ inline const_reverse_bidirectional_iterator rbegin_bd () const { return const_reverse_bidirectional_iterator (end_bd()); } /*! \brief Get a reverse iterator pointing to the start of a Matrix. * * This is a factory that returns a * Matrix::reverse_bidirectional_iterator that points to the * just before the first element in the given Matrix. * * This is the default template of this function. It allows the * user to generate iterators of a given Matrix without * explicitly stating the order of iteration. The iterator * returned by this function always iterates in the same order * as the given Matrix' matrix_order. */ inline reverse_bidirectional_iterator rend_bd () { return reverse_bidirectional_iterator (begin_bd()); } /*! \brief Get a reverse iterator pointing to the start of a Matrix. * * This is a factory that returns a * Matrix::const_reverse_bidirectional_iterator that points to * the just before the first element in the given Matrix. * * This is the default template of this function. It allows the * user to generate iterators of a given Matrix without * explicitly stating the order of iteration. The iterator * returned by this function always iterates in the same order * as the given Matrix' matrix_order. */ inline const_reverse_iterator rend_bd () const { return const_reverse_bidirectiona_iterator (begin_bd()); } protected: /**** INSTANCE VARIABLES ****/ /* I know the point of C++ is to force you to write 20 times * more code than should be necessary but "using" inherited ivs * is just stupid. */ using DBRef::data_; // refer to inherited data pointer directly using Base::rows_; // " # of rows directly using Base::cols_; // " # of cols directly }; // end class Matrix /**** EXTERNAL OPERATORS ****/ /* External operators include a range of binary matrix operations * such as tests for equality, and arithmetic. Style * (concrete/view) of the returned matrix is that of the left hand * side parameter by default * * There is also a question of the ordering of the returned matrix. * We adopt the convention of returning a matrix ordered like that * of the left hand side argument, by default. * * Whenever there is only one matrix argument (lhs is scalar) we use * its order and style as the default. * * A general template version of each operator also exists and users * can coerce the return type to whatever they prefer using some * ugly syntax; ex: * * Matrix<> A; ... Matrix B = operator* * (A, A); * * In general, the matrix class copy constructor will quietly * convert whatever matrix template is returned to the type of the * matrix it is being copied into on return, but one might want to * specify the type for objects that only exist for a second (ex: * (operator*(A, A)).begin()). Also, note that the * fact that we return concrete matrices by default does not * preclude the user from taking advantage of fast view copies. It * is the template type of the object being copy-constructed that * matters---in terms of underlying implementation all matrices are * views, concrete matrices just maintain a particular policy. * * TODO Consider the best type for scalar args to these functions. * For the most part, these will be primitives---doubles mostly. * Passing these by reference is probably less efficient than * passing by value. But, for user-defined types pass-by-reference * might be the way to go and the cost in this case will be much * higher than the value-reference trade-off for primitives. Right * now we use pass-by-reference but we might reconsider... */ /**** ARITHMETIC OPERATORS ****/ /* These macros provide templates for the basic definitions required * for all of the binary operators. Each operator requires 6 * definitions. First, a general matrix definition must be * provided. This definition can return a matrix of a different * style and order than its arguments but can only be called if its * template type is explicitly specified. The actual logic of the * operator should be specified within this function. The macros * provide definitions for the other 5 required templates, one * default matrix by matrix, general matrix by scalar, default * matrix by scalar, general scalar by matrix, default scalar by * matrix. The default versions call the more general versions with * such that they will return concrete matrices with order equal to * the left-hand (or only) matrix passed to the default version. * */ #define SCYTHE_BINARY_OPERATOR_DMM(OP) \ template \ inline Matrix \ OP (const Matrix& lhs, \ const Matrix& rhs) \ { \ return OP (lhs, rhs); \ } #define SCYTHE_BINARY_OPERATOR_GMS(OP) \ template \ inline Matrix \ OP (const Matrix& lhs, \ const typename Matrix::ttype &rhs) \ { \ return (OP \ (lhs, Matrix(rhs))); \ } #define SCYTHE_BINARY_OPERATOR_DMS(OP) \ template \ inline Matrix \ OP (const Matrix& lhs, \ const typename Matrix::ttype &rhs) \ { \ return (OP (lhs, rhs)); \ } #define SCYTHE_BINARY_OPERATOR_GSM(OP) \ template \ inline Matrix \ OP (const typename Matrix::ttype &lhs, \ const Matrix& rhs) \ { \ return (OP \ (Matrix(lhs), rhs)); \ } #define SCYTHE_BINARY_OPERATOR_DSM(OP) \ template \ inline Matrix \ OP (const typename Matrix::ttype &lhs, \ const Matrix& rhs) \ { \ return (OP (lhs, rhs)); \ } #define SCYTHE_BINARY_OPERATOR_DEFS(OP) \ SCYTHE_BINARY_OPERATOR_DMM(OP) \ SCYTHE_BINARY_OPERATOR_GMS(OP) \ SCYTHE_BINARY_OPERATOR_DMS(OP) \ SCYTHE_BINARY_OPERATOR_GSM(OP) \ SCYTHE_BINARY_OPERATOR_DSM(OP) /* Matrix multiplication */ /* General template version. Must be called with operator*<> syntax */ /* We provide two symmetric algorithms for matrix multiplication, * one for col-major and the other for row-major matrices. They are * designed to minimize cache misses.The decision is based on the * return type of the template so, when using matrices of multiple * orders, this can get ugly. These optimizations only really start * paying dividends as matrices get big, because cache misses are * rare with smaller matrices. */ /*! \brief Multiply two matrices. * * This operator multiplies the matrices \a lhs and \a rhs together, * returning the result in a new Matrix object. This operator is * overloaded to provide both Matrix by Matrix multiplication and * Matrix by scalar multiplication. In the latter case, the scalar * on the left- or right-hand side of the operator is promoted to a * 1x1 Matrix and then multiplied with the Matrix on the other side * of the operator. In either case, the matrices must conform; that * is, the number of columns in the left-hand side argument must * equal the number of rows in the right-hand side argument. The * one exception is when one matrix is a scalar. In this case we * allow Matrix by scalar multiplication with the "*" operator that * is comparable to element-by-element multiplication of a Matrix by * a scalar value, for convenience. * * In addition, we define multiple templates of the overloaded * operator to provide maximal flexibility when working with * matrices with differing matrix_order and/or matrix_style. Each * version of the overloaded operator (Matrix by Matrix, scalar by * Matrix, and Matrix by scalar) provides both a default and * general behavior, using templates. By default, the returned * Matrix is concrete and has the same matrix_order as the * left-hand (or only) Matrix argument. Alternatively, one may * coerce the matrix_order and matrix_style of the returned Matrix * to preferred values by using the full template declaration of * the operator. * * Scythe will use LAPACK/BLAS routines to multiply concrete * column-major matrices of double-precision floating point * numbers if LAPACK/BLAS is available and you compile your * program with the SCYTHE_LAPACK flag enabled. * * \param lhs The left-hand-side Matrix or scalar. * \param rhs The right-hand-side Matrix or scalar. * * \see operator*(const Matrix& lhs, const Matrix& rhs) * \see operator*(const Matrix& lhs, const Matrix& rhs) * \see operator*(const Matrix& lhs, const T_type& rhs) * \see operator*(const Matrix& lhs, const T_type& rhs) * \see operator*(const T_type& lhs, const Matrix& rhs) * \see operator*(const T_type& lhs, const Matrix& rhs) * * \throw scythe_conformation_error (Level 1) * \throw scythe_alloc_error (Level 1) */ template inline Matrix operator* (const Matrix& lhs, const Matrix& rhs) { if (lhs.size() == 1 || rhs.size() == 1) return (lhs % rhs); SCYTHE_CHECK_10 (lhs.cols() != rhs.rows(), scythe_conformation_error, "Matrices with dimensions (" << lhs.rows() << ", " << lhs.cols() << ") and (" << rhs.rows() << ", " << rhs.cols() << ") are not multiplication-conformable"); Matrix result (lhs.rows(), rhs.cols(), false); T_type tmp; if (ORDER == Col) { // col-major optimized for (uint j = 0; j < rhs.cols(); ++j) { for (uint i = 0; i < lhs.rows(); ++i) result(i, j) = (T_type) 0; for (uint l = 0; l < lhs.cols(); ++l) { tmp = rhs(l, j); for (uint i = 0; i < lhs.rows(); ++i) result(i, j) += tmp * lhs(i, l); } } } else { // row-major optimized for (uint i = 0; i < lhs.rows(); ++i) { for (uint j = 0; j < rhs.cols(); ++j) result(i, j) = (T_type) 0; for (uint l = 0; l < rhs.rows(); ++l) { tmp = lhs(i, l); for (uint j = 0; j < rhs.cols(); ++j) result(i, j) += tmp * rhs(l,j); } } } SCYTHE_VIEW_RETURN(T_type, ORDER, STYLE, result) } SCYTHE_BINARY_OPERATOR_DEFS(operator*) /*! \brief Kronecker multiply two matrices. * * This functions computes the Kronecker product of two Matrix * objects. This function is overloaded to provide both Matrix by * Matrix addition and Matrix by scalar addition. In the former * case, the dimensions of the two matrices must be the same. * * In addition, we define multiple templates of the overloaded * operator to provide maximal flexibility when working with * matrices with differing matrix_order and/or matrix_style. Each * version of the overloaded operator (Matrix by Matrix, scalar by * Matrix, and Matrix by scalar) provides both a default and * general behavior, using templates. By default, the returned * Matrix is concrete and has the same matrix_order as the * left-hand (or only) Matrix argument. Alternatively, one may * coerce the matrix_order and matrix_style of the returned Matrix * to preferred values by using the full template declaration of * the operator. * * \param lhs The left-hand-side Matrix or scalar. * \param rhs The right-hand-side Matrix or scalar. * * \throw scythe_conformation_error (Level 1) * \throw scythe_alloc_error (Level 1) */ template inline Matrix kronecker (const Matrix& lhs, const Matrix& rhs) { Matrix res = lhs; res.kronecker(rhs); return (res); } SCYTHE_BINARY_OPERATOR_DEFS(kronecker) /* Macro definition for general return type templates of standard * binary operators (this handles, +, -, %, /, but not *) */ #define SCYTHE_GENERAL_BINARY_OPERATOR(OP,FUNCTOR) \ template \ inline Matrix \ OP (const Matrix& lhs, \ const Matrix& rhs) \ { \ SCYTHE_CHECK_10(lhs.size() != 1 && rhs.size() != 1 && \ (lhs.rows() != rhs.rows() || lhs.cols() != rhs.cols()), \ scythe_conformation_error, \ "Matrices with dimensions (" << lhs.rows() \ << ", " << lhs.cols() \ << ") and (" << rhs.rows() << ", " << rhs.cols() \ << ") are not conformable"); \ \ if (lhs.size() == 1) { \ Matrix res(rhs.rows(),rhs.cols(),false); \ std::transform(rhs.begin_f(), rhs.end_f(), \ res.template begin_f(), \ std::bind1st(FUNCTOR (), lhs(0))); \ SCYTHE_VIEW_RETURN(T_type, ORDER, STYLE, res) \ } \ \ Matrix res(lhs.rows(), lhs.cols(), false); \ \ if (rhs.size() == 1) { \ std::transform(lhs.begin_f(), lhs.end_f(), \ res.template begin_f (), \ std::bind2nd(FUNCTOR (), rhs(0))); \ } else { \ std::transform(lhs.begin_f(), lhs.end_f(), \ rhs.template begin_f(), \ res.template begin_f(), \ FUNCTOR ()); \ } \ \ SCYTHE_VIEW_RETURN(T_type, ORDER, STYLE, res) \ } /* Addition operators */ /*! \fn operator+(const Matrix&lhs, * const Matrix&rhs) * * \brief Add two matrices. * * This operator adds the matrices \a lhs and \a rhs together, * returning the result in a new Matrix object. This operator is * overloaded to provide both Matrix by Matrix addition and * Matrix by scalar addition. In the former case, the dimensions of * the two matrices must be the same. * * In addition, we define multiple templates of the overloaded * operator to provide maximal flexibility when working with * matrices with differing matrix_order and/or matrix_style. Each * version of the overloaded operator (Matrix by Matrix, scalar by * Matrix, and Matrix by scalar) provides both a default and * general behavior, using templates. By default, the returned * Matrix is concrete and has the same matrix_order as the * left-hand (or only) Matrix argument. Alternatively, one may * coerce the matrix_order and matrix_style of the returned Matrix * to preferred values by using the full template declaration of * the operator. * * \param lhs The left-hand-side Matrix or scalar. * \param rhs The right-hand-side Matrix or scalar. * * \throw scythe_conformation_error (Level 1) * \throw scythe_alloc_error (Level 1) */ SCYTHE_GENERAL_BINARY_OPERATOR (operator+, std::plus) SCYTHE_BINARY_OPERATOR_DEFS (operator+) /* Subtraction operators */ /*! \fn operator-(const Matrix&lhs, * const Matrix&rhs) * * \brief Subtract two matrices. * * This operator subtracts the Matrix \a rhs from \a lhs, returning * the result in a new Matrix object. This operator is overloaded * to provide both Matrix by Matrix subtraction and Matrix by scalar * subtraction. In the former case, the dimensions of the two * matrices must be the same. * * In addition, we define multiple templates of the overloaded * operator to provide maximal flexibility when working with * matrices with differing matrix_order and/or matrix_style. Each * version of the overloaded operator (Matrix by Matrix, scalar by * Matrix, and Matrix by scalar) provides both a default and * general behavior, using templates. By default, the returned * Matrix is concrete and has the same matrix_order as the * left-hand (or only) Matrix argument. Alternatively, one may * coerce the matrix_order and matrix_style of the returned Matrix * to preferred values by using the full template declaration of * the operator. * * \param lhs The left-hand-side Matrix or scalar. * \param rhs The right-hand-side Matrix or scalar. * * \throw scythe_conformation_error (Level 1) * \throw scythe_alloc_error (Level 1) */ SCYTHE_GENERAL_BINARY_OPERATOR (operator-, std::minus) SCYTHE_BINARY_OPERATOR_DEFS (operator-) /* Element-by-element multiplication operators */ /*! \fn operator%(const Matrix&lhs, * const Matrix&rhs) * * \brief Element multiply two matrices. * * This operator multiplies the elements of the matrices \a lhs and * \a rhs together, returning the result in a new Matrix object. * This operator is overloaded to provide both Matrix by Matrix * element-wise multiplication and Matrix by scalar element-wise * multiplication. In the former case, the dimensions of the two * matrices must be the same. * * In addition, we define multiple templates of the overloaded * operator to provide maximal flexibility when working with * matrices with differing matrix_order and/or matrix_style. Each * version of the overloaded operator (Matrix by Matrix, scalar by * Matrix, and Matrix by scalar) provides both a default and * general behavior, using templates. By default, the returned * Matrix is concrete and has the same matrix_order as the * left-hand (or only) Matrix argument. Alternatively, one may * coerce the matrix_order and matrix_style of the returned Matrix * to preferred values by using the full template declaration of * the operator. * * \param lhs The left-hand-side Matrix or scalar. * \param rhs The right-hand-side Matrix or scalar. * * \throw scythe_conformation_error (Level 1) * \throw scythe_alloc_error (Level 1) */ SCYTHE_GENERAL_BINARY_OPERATOR (operator%, std::multiplies) SCYTHE_BINARY_OPERATOR_DEFS(operator%) /* Element-by-element division */ /*! \fn operator/(const Matrix&lhs, * const Matrix&rhs) * * \brief Divide two matrices. * * This operator divides the Matrix \a lhs from \a rhs, * returning the result in a new Matrix object. This operator is * overloaded to provide both Matrix by Matrix division and * Matrix by scalar division. In the former case, the dimensions of * the two matrices must be the same. * * In addition, we define multiple templates of the overloaded * operator to provide maximal flexibility when working with * matrices with differing matrix_order and/or matrix_style. Each * version of the overloaded operator (Matrix by Matrix, scalar by * Matrix, and Matrix by scalar) provides both a default and * general behavior, using templates. By default, the returned * Matrix is concrete and has the same matrix_order as the * left-hand (or only) Matrix argument. Alternatively, one may * coerce the matrix_order and matrix_style of the returned Matrix * to preferred values by using the full template declaration of * the operator. * * \param lhs The left-hand-side Matrix or scalar. * \param rhs The right-hand-side Matrix or scalar. * * \throw scythe_conformation_error (Level 1) * \throw scythe_alloc_error (Level 1) */ SCYTHE_GENERAL_BINARY_OPERATOR (operator/, std::divides) SCYTHE_BINARY_OPERATOR_DEFS (operator/) /* Element-by-element exponentiation */ /*! \fn operator^(const Matrix&lhs, * const Matrix&rhs) * * \brief Exponentiate one Matrix by another. * * This operator exponentiates the elements of Matrix \a lhs by * those in \a rhs, returning the result in a new Matrix object. * This operator is overloaded to provide both Matrix by Matrix * exponentiation and Matrix by scalar exponentiation. In the * former case, the dimensions of the two matrices must be the same. * * In addition, we define multiple templates of the overloaded * operator to provide maximal flexibility when working with * matrices with differing matrix_order and/or matrix_style. Each * version of the overloaded operator (Matrix by Matrix, scalar by * Matrix, and Matrix by scalar) provides both a default and * general behavior, using templates. By default, the returned * Matrix is concrete and has the same matrix_order as the * left-hand (or only) Matrix argument. Alternatively, one may * coerce the matrix_order and matrix_style of the returned Matrix * to preferred values by using the full template declaration of * the operator. * * \param lhs The left-hand-side Matrix or scalar. * \param rhs The right-hand-side Matrix or scalar. * * \throw scythe_conformation_error (Level 1) * \throw scythe_alloc_error (Level 1) */ SCYTHE_GENERAL_BINARY_OPERATOR (operator^, exponentiate) SCYTHE_BINARY_OPERATOR_DEFS (operator^) /* Negation operators */ // General return type version /*! \brief Negate a Matrix. * * This unary operator returns the negation of \a M. This version * of the operator is a general template and can provide a Matrix * with any matrix_order or matrix_style as its return value. * * We also provide an overloaded default template that returns a * concrete matrix with the same matrix_order as \a M. * * \param M The Matrix to negate. * * \throw scythe_alloc_error (Level 1) */ template inline Matrix operator- (const Matrix& M) { Matrix result(M.rows(), M.cols(), false); std::transform(M.template begin_f(), M.template end_f(), result.template begin_f(), std::negate ()); SCYTHE_VIEW_RETURN(T_type, R_ORDER, R_STYLE, result) } // Default return type version template inline Matrix operator- (const Matrix& M) { return operator- (M); } /* Unary not operators */ /*! \brief Logically NOT a Matrix. * * This unary operator returns NOT \a M. This version of the * operator is a general template and can provide a boolean Matrix * with any matrix_order or matrix_style as its return value. * * We also provide a default template for this function that returns * a concrete boolean with the same matrix_order as \a M. * * \param M The Matrix to NOT. * * \see operator!(const Matrix& M) * * \throw scythe_alloc_error (Level 1) */ template inline Matrix operator! (const Matrix& M) { Matrix result(M.rows(), M.cols(), false); std::transform(M.template begin_f(), M.template end_f(), result.template begin_f(), std::logical_not ()); SCYTHE_VIEW_RETURN(T_type, R_ORDER, R_STYLE, result) } // Default return type version template inline Matrix operator! (const Matrix& M) { return (operator! (M)); } /**** COMPARISON OPERATORS ****/ /* These macros are analogous to those above, except they return * only boolean matrices and use slightly different template * parameter orderings. Kind of redundant, but less confusing than * making omnibus macros that handle both cases. */ #define SCYTHE_GENERAL_BINARY_BOOL_OPERATOR(OP,FUNCTOR) \ template \ inline Matrix \ OP (const Matrix& lhs, \ const Matrix& rhs) \ { \ SCYTHE_CHECK_10(lhs.size() != 1 && rhs.size() != 1 && \ (lhs.rows() != rhs.rows() || lhs.cols() != rhs.cols()), \ scythe_conformation_error, \ "Matrices with dimensions (" << lhs.rows() \ << ", " << lhs.cols() \ << ") and (" << rhs.rows() << ", " << rhs.cols() \ << ") are not conformable"); \ \ if (lhs.size() == 1) { \ Matrix res(rhs.rows(),rhs.cols(),false); \ std::transform(rhs.begin_f(), rhs.end_f(), \ res.template begin_f(), \ std::bind1st(FUNCTOR (), lhs(0))); \ SCYTHE_VIEW_RETURN(T_type, ORDER, STYLE, res) \ } \ \ Matrix res(lhs.rows(), lhs.cols(), false); \ \ if (rhs.size() == 1) { \ std::transform(lhs.begin_f(), lhs.end_f(), \ res.template begin_f (), \ std::bind2nd(FUNCTOR (), rhs(0))); \ } else { \ std::transform(lhs.begin_f(), lhs.end_f(), \ rhs.template begin_f(), \ res.template begin_f(), \ FUNCTOR ()); \ } \ \ SCYTHE_VIEW_RETURN(T_type, ORDER, STYLE, res) \ } #define SCYTHE_BINARY_BOOL_OPERATOR_DMM(OP) \ template \ inline Matrix \ OP (const Matrix& lhs, \ const Matrix& rhs) \ { \ return OP (lhs, rhs); \ } #define SCYTHE_BINARY_BOOL_OPERATOR_GMS(OP) \ template \ inline Matrix \ OP (const Matrix& lhs, \ const typename Matrix::ttype &rhs) \ { \ return (OP \ (lhs, Matrix(rhs))); \ } #define SCYTHE_BINARY_BOOL_OPERATOR_DMS(OP) \ template \ inline Matrix \ OP (const Matrix& lhs, \ const typename Matrix::ttype &rhs) \ { \ return (OP (lhs, rhs)); \ } #define SCYTHE_BINARY_BOOL_OPERATOR_GSM(OP) \ template \ inline Matrix \ OP (const typename Matrix::ttype &lhs, \ const Matrix& rhs) \ { \ return (OP \ (Matrix(lhs), rhs)); \ } #define SCYTHE_BINARY_BOOL_OPERATOR_DSM(OP) \ template \ inline Matrix \ OP (const typename Matrix::ttype &lhs, \ const Matrix& rhs) \ { \ return (OP (lhs, rhs)); \ } #define SCYTHE_BINARY_BOOL_OPERATOR_DEFS(OP) \ SCYTHE_BINARY_BOOL_OPERATOR_DMM(OP) \ SCYTHE_BINARY_BOOL_OPERATOR_GMS(OP) \ SCYTHE_BINARY_BOOL_OPERATOR_DMS(OP) \ SCYTHE_BINARY_BOOL_OPERATOR_GSM(OP) \ SCYTHE_BINARY_BOOL_OPERATOR_DSM(OP) /* Element-wise Equality operator * See equals() method for straight equality checks */ /*! \fn operator==(const Matrix&lhs, * const Matrix&rhs) * * \brief Test Matrix equality. * * This operator compares the elements of \a lhs and \a rhs and * returns a boolean Matrix of true and false values, indicating * whether each pair of compared elements is equal. This operator * is overloaded to provide both Matrix by Matrix equality testing * and Matrix by scalar equality testing. In the former case, the * dimensions of the two matrices must be the same. The boolean * Matrix returned has the same dimensions as \a lhs and \a rhs, or * matches the dimensionality of the larger Matrix object when one * of the two parameters is a scalar or a 1x1 Matrix. * * In addition, we define multiple templates of the overloaded * operator to provide maximal flexibility when working with * matrices with differing matrix_order and/or matrix_style. Each * version of the overloaded operator (Matrix by Matrix, scalar by * Matrix, and Matrix by scalar) provides both a default and * general behavior, using templates. By default, the returned * Matrix is concrete and has the same matrix_order as the * left-hand (or only) Matrix argument. Alternatively, one may * coerce the matrix_order and matrix_style of the returned Matrix * to preferred values by using the full template declaration of * the operator. * * \param lhs The left-hand-side Matrix or scalar. * \param rhs The right-hand-side Matrix or scalar. * * \throw scythe_conformation_error (Level 1) * \throw scythe_alloc_error (Level 1) */ SCYTHE_GENERAL_BINARY_BOOL_OPERATOR (operator==, std::equal_to) SCYTHE_BINARY_BOOL_OPERATOR_DEFS (operator==) /*! \fn operator!=(const Matrix&lhs, * const Matrix&rhs) * * \brief Test Matrix equality. * * This operator compares the elements of \a lhs and \a rhs and * returns a boolean Matrix of true and false values, indicating * whether each pair of compared elements is not equal. This operator * is overloaded to provide both Matrix by Matrix inequality testing * and Matrix by scalar inequality testing. In the former case, the * dimensions of the two matrices must be the same. The boolean * Matrix returned has the same dimensions as \a lhs and \a rhs, or * matches the dimensionality of the larger Matrix object when one * of the two parameters is a scalar or a 1x1 Matrix. * * In addition, we define multiple templates of the overloaded * operator to provide maximal flexibility when working with * matrices with differing matrix_order and/or matrix_style. Each * version of the overloaded operator (Matrix by Matrix, scalar by * Matrix, and Matrix by scalar) provides both a default and * general behavior, using templates. By default, the returned * Matrix is concrete and has the same matrix_order as the * left-hand (or only) Matrix argument. Alternatively, one may * coerce the matrix_order and matrix_style of the returned Matrix * to preferred values by using the full template declaration of * the operator. * * \param lhs The left-hand-side Matrix or scalar. * \param rhs The right-hand-side Matrix or scalar. * * \throw scythe_conformation_error (Level 1) * \throw scythe_alloc_error (Level 1) */ SCYTHE_GENERAL_BINARY_BOOL_OPERATOR (operator!=, std::not_equal_to) SCYTHE_BINARY_BOOL_OPERATOR_DEFS (operator!=) /*! \fn operator<(const Matrix&lhs, * const Matrix&rhs) * * \brief Test Matrix inequality. * * This operator compares the elements of \a lhs and \a rhs and * returns a boolean Matrix of true and false values, indicating * whether each of the left-hand side elements is less than its * corresponding right hand side element. This operator is * overloaded to provide both Matrix by Matrix inequality testing * and Matrix by scalar inequality testing. In the former case, the * dimensions of the two matrices must be the same. The boolean * Matrix returned has the same dimensions as \a lhs and \a rhs, or * matches the dimensionality of the larger Matrix object when one * of the two parameters is a scalar or a 1x1 Matrix. * * In addition, we define multiple templates of the overloaded * operator to provide maximal flexibility when working with * matrices with differing matrix_order and/or matrix_style. Each * version of the overloaded operator (Matrix by Matrix, scalar by * Matrix, and Matrix by scalar) provides both a default and * general behavior, using templates. By default, the returned * Matrix is concrete and has the same matrix_order as the * left-hand (or only) Matrix argument. Alternatively, one may * coerce the matrix_order and matrix_style of the returned Matrix * to preferred values by using the full template declaration of * the operator. * * \param lhs The left-hand-side Matrix or scalar. * \param rhs The right-hand-side Matrix or scalar. * * \throw scythe_conformation_error (Level 1) * \throw scythe_alloc_error (Level 1) */ SCYTHE_GENERAL_BINARY_BOOL_OPERATOR (operator<, std::less) SCYTHE_BINARY_BOOL_OPERATOR_DEFS (operator<) /*! \fn operator<=(const Matrix&lhs, * const Matrix&rhs) * * \brief Test Matrix inequality. * * This operator compares the elements of \a lhs and \a rhs and * returns a boolean Matrix of true and false values, indicating * whether each of the left-hand side elements is less than * or equal to its * corresponding right hand side element. This operator is * overloaded to provide both Matrix by Matrix inequality testing * and Matrix by scalar inequality testing. In the former case, the * dimensions of the two matrices must be the same. The boolean * Matrix returned has the same dimensions as \a lhs and \a rhs, or * matches the dimensionality of the larger Matrix object when one * of the two parameters is a scalar or a 1x1 Matrix. * * In addition, we define multiple templates of the overloaded * operator to provide maximal flexibility when working with * matrices with differing matrix_order and/or matrix_style. Each * version of the overloaded operator (Matrix by Matrix, scalar by * Matrix, and Matrix by scalar) provides both a default and * general behavior, using templates. By default, the returned * Matrix is concrete and has the same matrix_order as the * left-hand (or only) Matrix argument. Alternatively, one may * coerce the matrix_order and matrix_style of the returned Matrix * to preferred values by using the full template declaration of * the operator. * * \param lhs The left-hand-side Matrix or scalar. * \param rhs The right-hand-side Matrix or scalar. * * \throw scythe_conformation_error (Level 1) * \throw scythe_alloc_error (Level 1) */ SCYTHE_GENERAL_BINARY_BOOL_OPERATOR (operator<=, std::less_equal) SCYTHE_BINARY_BOOL_OPERATOR_DEFS (operator<=) /*! \fn operator>(const Matrix&lhs, * const Matrix&rhs) * * \brief Test Matrix inequality. * * This operator compares the elements of \a lhs and \a rhs and * returns a boolean Matrix of true and false values, indicating * whether each of the left-hand side elements is greater than its * corresponding right hand side element. This operator is * overloaded to provide both Matrix by Matrix inequality testing * and Matrix by scalar inequality testing. In the former case, the * dimensions of the two matrices must be the same. The boolean * Matrix returned has the same dimensions as \a lhs and \a rhs, or * matches the dimensionality of the larger Matrix object when one * of the two parameters is a scalar or a 1x1 Matrix. * * In addition, we define multiple templates of the overloaded * operator to provide maximal flexibility when working with * matrices with differing matrix_order and/or matrix_style. Each * version of the overloaded operator (Matrix by Matrix, scalar by * Matrix, and Matrix by scalar) provides both a default and * general behavior, using templates. By default, the returned * Matrix is concrete and has the same matrix_order as the * left-hand (or only) Matrix argument. Alternatively, one may * coerce the matrix_order and matrix_style of the returned Matrix * to preferred values by using the full template declaration of * the operator. * * \param lhs The left-hand-side Matrix or scalar. * \param rhs The right-hand-side Matrix or scalar. * * \throw scythe_conformation_error (Level 1) * \throw scythe_alloc_error (Level 1) */ SCYTHE_GENERAL_BINARY_BOOL_OPERATOR (operator>, std::greater) SCYTHE_BINARY_BOOL_OPERATOR_DEFS (operator>) /*! \fn operator>=(const Matrix&lhs, * const Matrix&rhs) * * \brief Test Matrix inequality. * * This operator compares the elements of \a lhs and \a rhs and * returns a boolean Matrix of true and false values, indicating * whether each of the left-hand side elements is greater than * or equal to its * corresponding right hand side element. This operator is * overloaded to provide both Matrix by Matrix inequality testing * and Matrix by scalar inequality testing. In the former case, the * dimensions of the two matrices must be the same. The boolean * Matrix returned has the same dimensions as \a lhs and \a rhs, or * matches the dimensionality of the larger Matrix object when one * of the two parameters is a scalar or a 1x1 Matrix. * * In addition, we define multiple templates of the overloaded * operator to provide maximal flexibility when working with * matrices with differing matrix_order and/or matrix_style. Each * version of the overloaded operator (Matrix by Matrix, scalar by * Matrix, and Matrix by scalar) provides both a default and * general behavior, using templates. By default, the returned * Matrix is concrete and has the same matrix_order as the * left-hand (or only) Matrix argument. Alternatively, one may * coerce the matrix_order and matrix_style of the returned Matrix * to preferred values by using the full template declaration of * the operator. * * \param lhs The left-hand-side Matrix or scalar. * \param rhs The right-hand-side Matrix or scalar. * * \throw scythe_conformation_error (Level 1) * \throw scythe_alloc_error (Level 1) */ SCYTHE_GENERAL_BINARY_BOOL_OPERATOR (operator>=, std::greater_equal) SCYTHE_BINARY_BOOL_OPERATOR_DEFS (operator>=) /*! \fn operator&(const Matrix&lhs, * const Matrix&rhs) * * \brief Logically AND two matrices. * * This operator logically ANDs the elements of \a lhs and \a rhs * and returns a boolean Matrix of true and false values, with true * values in each position where both matrices' elements evaluate to * true (or the type specific analog to true, typically any non-zero * value). This operator is overloaded to provide both Matrix by * Matrix AND and Matrix by scalar AND. In the former case, the * dimensions of the two matrices must be the same. The boolean * Matrix returned has the same dimensions as \a lhs and \a rhs, or * matches the dimensionality of the larger Matrix object when one * of the two parameters is a scalar or a 1x1 Matrix. * * In addition, we define multiple templates of the overloaded * operator to provide maximal flexibility when working with * matrices with differing matrix_order and/or matrix_style. Each * version of the overloaded operator (Matrix by Matrix, scalar by * Matrix, and Matrix by scalar) provides both a default and * general behavior, using templates. By default, the returned * Matrix is concrete and has the same matrix_order as the * left-hand (or only) Matrix argument. Alternatively, one may * coerce the matrix_order and matrix_style of the returned Matrix * to preferred values by using the full template declaration of * the operator. * * \param lhs The left-hand-side Matrix or scalar. * \param rhs The right-hand-side Matrix or scalar. * * \throw scythe_conformation_error (Level 1) * \throw scythe_alloc_error (Level 1) */ SCYTHE_GENERAL_BINARY_BOOL_OPERATOR (operator&, std::logical_and) SCYTHE_BINARY_BOOL_OPERATOR_DEFS (operator&) /*! \fn operator|(const Matrix&lhs, * const Matrix&rhs) * * \brief Logically OR two matrices. * * This operator logically ORs the elements of \a lhs and \a rhs * and returns a boolean Matrix of true and false values, with true * values in each position where either Matrix's elements evaluate to * true (or the type specific analog to true, typically any non-zero * value). This operator is overloaded to provide both Matrix by * Matrix OR and Matrix by scalar OR. In the former case, the * dimensions of the two matrices must be the same. The boolean * Matrix returned has the same dimensions as \a lhs and \a rhs, or * matches the dimensionality of the larger Matrix object when one * of the two parameters is a scalar or a 1x1 Matrix. * * In addition, we define multiple templates of the overloaded * operator to provide maximal flexibility when working with * matrices with differing matrix_order and/or matrix_style. Each * version of the overloaded operator (Matrix by Matrix, scalar by * Matrix, and Matrix by scalar) provides both a default and * general behavior, using templates. By default, the returned * Matrix is concrete and has the same matrix_order as the * left-hand (or only) Matrix argument. Alternatively, one may * coerce the matrix_order and matrix_style of the returned Matrix * to preferred values by using the full template declaration of * the operator. * * \param lhs The left-hand-side Matrix or scalar. * \param rhs The right-hand-side Matrix or scalar. * * \throw scythe_conformation_error (Level 1) * \throw scythe_alloc_error (Level 1) */ SCYTHE_GENERAL_BINARY_BOOL_OPERATOR (operator|, std::logical_or) SCYTHE_BINARY_BOOL_OPERATOR_DEFS (operator|) /**** INPUT-OUTPUT ****/ /* This function simply copies values from an input stream into a * matrix. It relies on the iterators for bounds checking. */ /*! \brief Populate a Matrix from a stream. * * This operator reads values from a stream and enters them into an * existing Matrix in order. * * \param is The istream to read from. * \param M The Matrix to populate. * * \see operator<<(std::ostream& os, const Matrix& M) * \see Matrix::Matrix(const std::string& file) * * \throw scythe_bounds_error (Level 3) */ template std::istream& operator>> (std::istream& is, Matrix& M) { std::copy(std::istream_iterator (is), std::istream_iterator(), M.begin_f()); return is; } /* Writes a matrix to an ostream in readable format. This is * intended to be used to pretty-print to the terminal. */ /*!\brief Write a Matrix to a stream. * * Writes a matrix to an ostream in a column-aligned format. This * operator is primarily intended for pretty-printing to the * terminal and uses two passes in order to correctly align the * output. If you wish to write a Matrix to disk, Matrix::save() is * probably a better option. * * \param os The ostream to write to. * \param M The Matrix to write out. * * \see operator>>(std::istream& is, Matrix& M) * \see Matrix::save() */ template std::ostream& operator<< (std::ostream& os, const Matrix& M) { /* This function take two passes to figure out appropriate field * widths. Speed isn't really the point here. */ // Store previous io settings std::ios_base::fmtflags preop = os.flags(); uint mlen = os.width(); std::ostringstream oss; oss.precision(os.precision()); oss << std::setiosflags(std::ios::fixed); typename Matrix::const_forward_iterator last = M.end_f(); for (typename Matrix::const_forward_iterator i = M.begin_f(); i != last; ++i) { oss.str(""); oss << (*i); if (oss.str().length() > mlen) mlen = oss.str().length(); } /* Write the stream */ // Change to a fixed with format. Users should control precision os << std::setiosflags(std::ios::fixed); for (uint i = 0; i < M.rows(); ++i) { Matrix row = M(i, _); //for (uint i = 0; i < row.size(); ++i) // os << std::setw(mlen) << row[i] << " "; typename Matrix::const_forward_iterator row_last = row.end_f(); for (typename Matrix::forward_iterator el = row.begin_f(); el != row_last; ++el) { os << std::setw(mlen) << *el << " "; } os << std::endl; } // Restore pre-op flags os.flags(preop); return os; } #ifdef SCYTHE_LAPACK /* A template specialization of operator* for col-major, concrete * matrices of doubles that is only visible when a LAPACK library is * available. This function is an analog of the above function and * the above doxygen documentation serves for both. * * This needs to go below % so it can see the template definition * (since it isn't actually in the template itself. */ template<> inline Matrix<> operator* (const Matrix<>& lhs, const Matrix<>& rhs) { if (lhs.size() == 1 || rhs.size() == 1) return (lhs % rhs); SCYTHE_DEBUG_MSG("Using lapack/blas for matrix multiplication"); SCYTHE_CHECK_10 (lhs.cols() != rhs.rows(), scythe_conformation_error, "Matrices with dimensions (" << lhs.rows() << ", " << lhs.cols() << ") and (" << rhs.rows() << ", " << rhs.cols() << ") are not multiplication-conformable"); Matrix<> result (lhs.rows(), rhs.cols(), false); // Get pointers to the internal arrays and set up some vars double* lhspnt = lhs.getArray(); double* rhspnt = rhs.getArray(); double* resultpnt = result.getArray(); const double one(1.0); const double zero(0.0); int rows = (int) lhs.rows(); int cols = (int) rhs.cols(); int innerDim = (int) rhs.rows(); // Call the lapack routine. lapack::dgemm_("N", "N", &rows, &cols, &innerDim, &one, lhspnt, &rows, rhspnt, &innerDim, &zero, resultpnt, &rows); return result; } #endif } // end namespace scythe #endif /* SCYTHE_MATRIX_H */ scythestat-1.0.3/scythestat/datablock.h0000644000175000017500000002476111765732303015140 00000000000000 /* * Scythe Statistical Library Copyright (C) 2000-2002 Andrew D. Martin * and Kevin M. Quinn; 2002-present Andrew D. Martin, Kevin M. Quinn, * and Daniel Pemstein. All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify under the terms of the GNU General Public License as * published by Free Software Foundation; either version 2 of the * License, or (at your option) any later version. See the text files * COPYING and LICENSE, distributed with this source code, for further * information. * -------------------------------------------------------------------- * scythestat/datablock.h */ /*! \file datablock.h * \brief Definitions of internal Matrix data management classes * * DataBlock and DataBlockReference objects provide the data half of * the data/view container model used by Scythe's matrices. A * DataBlock contains a data array of a given type, some information * about the DataBlock, and a reference count. Matrix objects * provide views to the DataBlock, thus allowing us to provide * Matrix objects that reference subsets of other matrices. When no * matrices remain that reference the DataBlock the reference count * falls to zero and the block is automatically deallocated. * * DataBlock uses a simple doubling/halving memory allocation scheme * but this may change in later releases. * * The DataBlock classes are used exclusively within the library and * do not constitute a part of Scythe's public interface. * * Based on code in Blitz++ (http://www.oonumerics.org/blitz/) by * Todd Veldhuizen . Blitz++ is * distributed under the terms of the GNU GPL. */ #ifndef SCYTHE_DATABLOCK_H #define SCYTHE_DATABLOCK_H #ifdef SCYTHE_COMPILE_DIRECT #include "error.h" #else #include "scythestat/error.h" #endif #ifdef SCYTHE_PTHREAD #include #endif namespace scythe { /* Convenience typedefs */ namespace { // local to this file typedef unsigned int uint; } /*! \brief Handles Matrix data internals. * * Handles data allocation, reallocation, and deletion of blocks of * elements; the actual data Matrix objects point to. Keeps a * reference count. */ template class DataBlock { public: /**** CONSTRUCTORS ****/ /* * Create an empty data block. */ DataBlock () : data_ (0), size_ (0), refs_ (0) {} /* * Create a block of a given size. */ explicit DataBlock (uint size) : data_ (0), size_ (0), refs_ (0) { resize(size); SCYTHE_DEBUG_MSG("Constructed new " << size << "(" << size_ << ") DataBlock at address " << data_); } /* * Create an exact copy of another data block. */ DataBlock (const DataBlock& b) : data_ (b.data_), size_ (b.size_), refs_ (b.refs_) {} /**** DESTRUCTOR ****/ ~DataBlock () { SCYTHE_DEBUG_MSG("Destructing block at " << data_); deallocate(); } /**** REFERENCE COUNTING ****/ inline uint addReference () { SCYTHE_DEBUG_MSG("Added reference to DataBlock at address " << data_); return ++refs_; } inline uint removeReference () { SCYTHE_DEBUG_MSG("Removed reference to DataBlock at address " << data_); return --refs_ ; } inline uint references () { return refs_; } /**** ACCESSORS ****/ inline T_type* data() { return data_; } inline const T_type* data() const { return data_; } inline uint size () const { return size_; } protected: /**** (DE)ALLOCATION AND RESIZING ****/ /* Allocate data given the current block size. */ inline void allocate (uint size) { /* TODO Think about cache boundary allocations for big blocks * see blitz++ */ if (data_ != 0) // Get rid of previous allocation if it exists deallocate(); data_ = new (std::nothrow) T_type[size]; SCYTHE_CHECK_10(data_ == 0, scythe_alloc_error, "Failure allocating DataBlock of size " << size); } /* Deallocate a block's data */ inline void deallocate () { SCYTHE_DEBUG_MSG(" Deallocating DataBlock of size " << size_ << " at address " << data_); delete[] data_; data_ = 0; } public: /* TODO At the moment, references call this method directly. Not * sure if this is the best interface choice. */ /* Resize a block. */ void resize (uint newsize) { if (newsize > size_) grow(newsize); else if (newsize < size_ / 4) shrink(); } protected: /* Make a block larger. Expects to be called by resize and does * not reset the size_ variable. */ inline void grow (uint newsize) { size_ = size_ ? size_ : 1; // make sure not zero /* TODO Can we speed this up? In 20 iters we're at * 1048576 elems doing the math might be more costly... */ while (size_ < newsize) size_ <<= 1; allocate(size_); } /* Make a block smaller. Expects to be called by resize */ inline void shrink () { size_ >>= 1; allocate(size_); } private: /**** INSTANCE VARIABLES ****/ T_type *data_; // The data array uint size_; // The number of elements in the block uint refs_; // The number of views looking at this block }; // end class DataBlock /*! \brief Null data block object. * * A nice little way to represent empty data blocks. */ template class NullDataBlock : public DataBlock { typedef DataBlock T_base; public: NullDataBlock () : DataBlock () { // never want to deallocate (or resize) this one T_base::addReference(); SCYTHE_DEBUG_MSG("Constructed NULL datablock"); } ~NullDataBlock () {} }; // end class NullDataBlock /*! * \brief Handle to DataBlock objects. * * Matrices inherit from this object. It provides a handle into * DataBlock objects and automates cleanup when the referenced * object runs out of referants. */ template class DataBlockReference { public: /**** CONSTRUCTORS ****/ /* Default constructor: points the object at a static null block */ DataBlockReference () : data_ (0), block_ (&nullBlock_) { #ifdef SCYTHE_PTHREAD pthread_mutex_lock (&ndbMutex_); #endif block_->addReference(); #ifdef SCYTHE_PTHREAD pthread_mutex_unlock (&ndbMutex_); #endif } /* New block constructor: creates a new underlying block of a * given size and points at it. */ explicit DataBlockReference (uint size) : data_ (0), block_ (0) { block_ = new (std::nothrow) DataBlock (size); SCYTHE_CHECK_10 (block_ == 0, scythe_alloc_error, "Could not allocate DataBlock object"); data_ = block_->data(); block_->addReference(); } /* Refrence to an existing block constructor: points to an * offset within an existing block. */ DataBlockReference (const DataBlockReference& reference, uint offset = 0) : data_ (reference.data_ + offset), block_ (reference.block_) { #ifdef SCYTHE_PTHREAD bool lock = false; if (block_ == &nullBlock_) { pthread_mutex_lock (&ndbMutex_); lock = true; } #endif block_->addReference(); #ifdef SCYTHE_PTHREAD if (lock) pthread_mutex_unlock (&ndbMutex_); #endif } /**** DESTRUCTOR ****/ /* Automates removal of underlying block objects when refcount * hits nil. */ virtual ~DataBlockReference () { #ifdef SCYTHE_PTHREAD bool lock = false; if (block_ == &nullBlock_) { pthread_mutex_lock (&ndbMutex_); lock = true; } #endif withdrawReference(); #ifdef SCYTHE_PTHREAD if (lock) pthread_mutex_unlock (&ndbMutex_); #endif } protected: /**** MEMBERS CALLED BY DERIVED CLASS ****/ void referenceOther (const DataBlockReference& ref, uint offset = 0) { #ifdef SCYTHE_PTHREAD bool lock = false; if (block_ == &nullBlock_ || ref.block_ == &nullBlock_) { pthread_mutex_lock (&ndbMutex_); lock = true; } #endif withdrawReference (); block_ = ref.block_; block_->addReference(); data_ = ref.data_ + offset; #ifdef SCYTHE_PTHREAD if (lock) pthread_mutex_lock (&ndbMutex_); #endif } void referenceNew (uint size) { #ifdef SCYTHE_PTHREAD bool lock = false; if (block_ == &nullBlock_) { pthread_mutex_lock (&ndbMutex_); lock = true; } #endif /* If we are the only referent to this data block, resize it. * Otherwise, shift the reference to point to a newly * constructed block. */ if (block_->references() == 1) { block_->resize(size); data_ = block_->data(); // This is a pretty good indication // that the interface and implementation are too tightly // coupled for resizing. } else { withdrawReference(); block_ = 0; block_ = new (std::nothrow) DataBlock (size); SCYTHE_CHECK_10(block_ == 0, scythe_alloc_error, "Could not allocate new data block"); data_ = block_->data(); block_->addReference(); } #ifdef SCYTHE_PTHREAD if (lock) pthread_mutex_unlock (&ndbMutex_); #endif } private: /**** INTERNAL MEMBERS ****/ void withdrawReference () { // All calls to withdrawReference are mutex protected and protecting // this too can create a race condition. if (block_->removeReference() == 0 && block_ != &nullBlock_) delete block_; } void referenceNull () { #ifdef SCYTHE_PTHREAD pthread_mutex_lock (&ndbMutex_); #endif withdrawReference(); block_ = &nullBlock_; block_->addReference(); data_ = 0; #ifdef SCYTHE_PTHREAD pthread_mutex_unlock (&ndbMutex_); #endif } /**** INSTANCE VARIABLES ****/ protected: T_type* data_; // Pointer to the underlying data (offset) private: DataBlock* block_; static NullDataBlock nullBlock_; #ifdef SCYTHE_PTHREAD static pthread_mutex_t ndbMutex_; #endif }; // end class DataBlockReference /* Instantiation of the static null memory block */ template NullDataBlock DataBlockReference::nullBlock_; #ifdef SCYTHE_PTHREAD // mutex initialization template pthread_mutex_t DataBlockReference::ndbMutex_ = PTHREAD_MUTEX_INITIALIZER; #endif } // end namespace scythe #endif /* SCYTHE_DATABLOCK_H */ scythestat-1.0.3/scythestat/matrix_bidirectional_iterator.h0000644000175000017500000003235411550656101021307 00000000000000/* * Scythe Statistical Library Copyright (C) 2000-2002 Andrew D. Martin * and Kevin M. Quinn; 2002-present Andrew D. Martin, Kevin M. Quinn, * and Daniel Pemstein. All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify under the terms of the GNU General Public License as * published by Free Software Foundation; either version 2 of the * License, or (at your option) any later version. See the text files * COPYING and LICENSE, distributed with this source code, for further * information. * -------------------------------------------------------------------- * scythestat/matrix_bidirectional_iterator.h * * Bidirectional iterators for the matrix class. * */ /*! \file matrix_bidirectional_iterator.h * \brief Definitions of STL-compliant bidirectional iterators for the * Matrix class. * * Contains definitions of const_matrix_bidirectional_iterator, * matrix_bidirectional_iterator, and related operators. See a * Standard Template Library reference, such as Josuttis (1999), for a * full description of the capabilities of bidirectional iterators. * * These iterators are templated on the type, order and style of the * Matrix they iterate over and their own order, which need not match * the iterated-over matrix. Same-order iteration over concrete * matrices is extremely fast. Cross-grain concrete and/or view * iteration is slower. */ #ifndef SCYTHE_MATRIX_BIDIRECTIONAL_ITERATOR_H #define SCYTHE_MATRIX_BIDIRECTIONAL_ITERATOR_H #include #ifdef SCYTHE_COMPILE_DIRECT #include "defs.h" #include "error.h" #include "matrix.h" #else #include "scythestat/defs.h" #include "scythestat/error.h" #include "scythestat/matrix.h" #endif namespace scythe { /* convenience typedefs */ namespace { // local to this file typedef unsigned int uint; } /* forward declaration of the matrix class */ template class Matrix; /*! \brief An STL-compliant const bidirectional iterator for Matrix. * * Provides bidirectional iteration over const Matrix objects. See * Josuttis (1999), or some other STL reference, for a full * description of the bidirectional iterator interface. * * \see Matrix * \see matrix_bidirectional_iterator * \see const_matrix_forward_iterator * \see matrix_forward_iterator * \see const_matrix_random_access_iterator * \see matrix_random_access_iterator */ template class const_matrix_bidirectional_iterator : public std::iterator { public: /**** TYPEDEFS ***/ typedef const_matrix_bidirectional_iterator self; /* These are a little formal, but useful */ typedef typename std::iterator_traits::value_type value_type; typedef typename std::iterator_traits::iterator_category iterator_category; typedef typename std::iterator_traits::difference_type difference_type; typedef typename std::iterator_traits::pointer pointer; typedef typename std::iterator_traits::reference reference; /**** CONSTRUCTORS ****/ /* Default constructor */ const_matrix_bidirectional_iterator () {} /* Standard constructor */ const_matrix_bidirectional_iterator (const Matrix &M) : pos_ (M.getArray()), matrix_ (&M) { SCYTHE_CHECK_30 (pos_ == 0, scythe_null_error, "Requesting iterator to NULL matrix"); /* The basic story is: when M_STYLE == Concrete and ORDER == * M_ORDER, we only need pos_ and iteration will be as fast as * possible. All other types of iteration need more variables * to keep track of things and are slower. */ if (M_STYLE != Concrete || M_ORDER != ORDER) { offset_ = 0; if (ORDER == Col) { lead_length_ = M.rows(); lead_inc_ = M.rowstride(); trail_inc_ = M.colstride(); } else { lead_length_ = M.cols(); lead_inc_ = M.colstride(); trail_inc_ = M.rowstride(); } jump_ = trail_inc_ + (1 - lead_length_) * lead_inc_; vend_ = pos_ + (lead_length_ - 1) * lead_inc_; vbegin_ = pos_; } #if SCYTHE_DEBUG > 2 size_ = M.size(); start_ = pos_; #endif } /* Copy constructor */ const_matrix_bidirectional_iterator (const self &mi) : pos_ (mi.pos_), matrix_ (mi.matrix_) { if (M_STYLE != Concrete || M_ORDER != ORDER) { offset_ = mi.offset_; lead_length_ = mi.lead_length_; lead_inc_ = mi.lead_inc_; trail_inc_ = mi.trail_inc_; vend_ = mi.vend_; vbegin_ = mi.vbegin_; jump_ = mi.jump_; } #if SCYTHE_DEBUG > 2 size_ = mi.size_; start_ = mi.start_; #endif } /**** EXTRA MODIFIER ****/ /* This function lets us grab an end iterator. It is cheap for * Concrete matrices but somewhat more costly for views. */ inline self& set_end () { if (M_STYLE == Concrete && ORDER == M_ORDER) { pos_ = matrix_->getArray() + matrix_->size(); } else { if (ORDER == Col) { vbegin_ += trail_inc_ * matrix_->cols(); vend_ += trail_inc_ * matrix_->cols(); } else { // ORDER == Rows vbegin_ += trail_inc_ * matrix_->rows(); vend_ += trail_inc_ * matrix_->rows(); } pos_ = vbegin_; offset_ = matrix_->size(); } return *this; } /**** FORWARD ITERATOR FACILITIES ****/ inline self& operator= (const self& mi) { pos_ = mi.pos_; matrix_ = mi.matrix_; if (M_STYLE != Concrete || M_ORDER != ORDER) { offset_ = mi.offset_; lead_length_ = mi.lead_length_; lead_inc_ = mi.lead_inc_; trail_inc_ = mi.trail_inc_; vend_ = mi.vend_; vbegin_ = mi.vbegin_; jump_ = mi.jump_; } #if SCYTHE_DEBUG > 2 size_ = mi.size_; start_ = mi.start_; #endif return *this; } inline const reference operator* () const { SCYTHE_ITER_CHECK_BOUNDS(); return *pos_; } inline const pointer operator-> () const { SCYTHE_ITER_CHECK_BOUNDS(); return pos_; } inline self& operator++ () { if (M_STYLE == Concrete && ORDER == M_ORDER) ++pos_; else { if (pos_ == vend_) { vend_ += trail_inc_; vbegin_ += trail_inc_; pos_ += jump_; } else { pos_ += lead_inc_; } ++offset_; } return *this; } inline self operator++ (int) { self tmp = *this; ++(*this); return tmp; } /* == is only defined for iterators of the same template type * that point to the same matrix. Behavior for any other * comparison is undefined. * * Note that we have to be careful about iterator comparisons * when working with views and cross-grain iterators. * Specifically, we always have to rely on the offset value. * Obviously, with <> checks pos_ can jump all over the place in * cross-grain iterators, but also end iterators point to the * value after the last in the matrix. In some cases, the * equation in += and -= will actually put pos_ inside the * matrix (often in an early position) in this case. */ inline bool operator== (const self& x) const { if (M_STYLE == Concrete && ORDER == M_ORDER) { return pos_ == x.pos_; } else { return offset_ == x.offset_; } } /* Again, != is only officially defined for iterators over the * same matrix although the test will be trivially true for * matrices that don't view the same data, by implementation. */ inline bool operator!= (const self &x) const { return !(*this == x); } /**** BIDIRECTIONAL ITERATOR FACILITES ****/ inline self& operator-- () { if (M_STYLE == Concrete && ORDER == M_ORDER) --pos_; else { if (pos_ == vbegin_) { vend_ -= trail_inc_; vbegin_ -= trail_inc_; pos_ -= jump_; } else { pos_ -= lead_inc_; } --offset_; } return *this; } inline self operator-- (int) { self tmp = *this; --(*this); return tmp; } protected: /**** INSTANCE VARIABLES ****/ T_type* pos_; // pointer to current position in array T_type *vend_; // pointer to end of current vector T_type *vbegin_; // pointer to begin of current vector uint offset_; // logical offset into matrix // TODO Some of these can probably be uints int lead_length_; // Logical length of leading dimension int lead_inc_; // Memory distance between vectors in ldim int trail_inc_; // Memory distance between vectors in tdim int jump_; // Memory distance between end of one ldim vector and // begin of next // Pointer used only for set_end. TODO Cleaner impl. const Matrix* matrix_; // Size variable for range checking #if SCYTHE_DEBUG > 2 uint size_; // Logical matrix size T_type* start_; // only needed for bounds checking #endif }; /*! \brief An STL-compliant bidirectional iterator for Matrix. * * Provides bidirectional iteration over Matrix objects. See * Josuttis (1999), or some other STL reference, for a full * description of the bidirectional iterator interface. * * \see Matrix * \see const_matrix_bidirectional_iterator * \see const_matrix_forward_iterator * \see matrix_forward_iterator * \see const_matrix_random_access_iterator * \see matrix_random_access_iterator */ template class matrix_bidirectional_iterator : public const_matrix_bidirectional_iterator { /**** TYPEDEFS ***/ typedef matrix_bidirectional_iterator self; typedef const_matrix_bidirectional_iterator Base; public: /* These are a little formal, but useful */ typedef typename std::iterator_traits::value_type value_type; typedef typename std::iterator_traits::iterator_category iterator_category; typedef typename std::iterator_traits::difference_type difference_type; typedef typename std::iterator_traits::pointer pointer; typedef typename std::iterator_traits::reference reference; /**** CONSTRUCTORS ****/ /* Default constructor */ matrix_bidirectional_iterator () : Base () {} /* Standard constructor */ matrix_bidirectional_iterator (const Matrix &M) : Base(M) {} /* Copy constructor */ matrix_bidirectional_iterator (const self &mi) : Base (mi) {} /**** EXTRA MODIFIER ****/ inline self& set_end () { Base::set_end(); return *this; } /**** FORWARD ITERATOR FACILITIES ****/ /* We have to override a lot of these to get return values * right.*/ inline self& operator= (const self& mi) { pos_ = mi.pos_; matrix_ = mi.matrix_; if (M_STYLE != Concrete || M_ORDER != ORDER) { offset_ = mi.offset_; lead_length_ = mi.lead_length_; lead_inc_ = mi.lead_inc_; trail_inc_ = mi.trail_inc_; vend_ = mi.vend_; vbegin_ = mi.vbegin_; jump_ = mi.jump_; } #if SCYTHE_DEBUG > 2 size_ = mi.size_; start_ = mi.start_; #endif return *this; } inline reference operator* () const { SCYTHE_ITER_CHECK_BOUNDS(); return *pos_; } inline pointer operator-> () const { SCYTHE_ITER_CHECK_BOUNDS(); return pos_; } inline self& operator++ () { Base::operator++(); return *this; } inline self operator++ (int) { self tmp = *this; ++(*this); return tmp; } inline self& operator-- () { Base::operator--(); return *this; } inline self operator-- (int) { self tmp = *this; --(*this); return tmp; } private: /* Get handles to base members. It boggles the mind */ using Base::pos_; using Base::vend_; using Base::vbegin_; using Base::offset_; using Base::lead_length_; using Base::lead_inc_; using Base::trail_inc_; using Base::jump_; using Base::matrix_; #if SCYTHE_DEBUG > 2 using Base::size_; using Base::start_; #endif }; } // namespace scythe #endif /* SCYTHE_MATRIX_BIDIRECTIONAL_ITERATOR_H */ scythestat-1.0.3/scythestat/algorithm.h0000644000175000017500000001470511764452777015214 00000000000000/* * Scythe Statistical Library * Copyright (C) 2000-2002 Andrew D. Martin and Kevin M. Quinn; * 2002-present Andrew D. Martin, Kevin M. Quinn, and Daniel * Pemstein. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify * under the terms of the GNU General Public License as published by * Free Software Foundation; either version 2 of the License, or (at * your option) any later version. See the text files COPYING * and LICENSE, distributed with this source code, for further * information. * -------------------------------------------------------------------- * scythestat/algorithm.h */ /*! \file algorithm.h * * \brief Generic algorithms for Scythe objects. * * This file provides implementations of a few algorithms that operate * on Scythe objects and also contains the definitions of a handful of * useful function objects. These functions and functors are primarily * intended for use within the library. We add algorithms to this * header as need arises and do not currently attempt to provide a * comprehensive set of generic algorithms for working with Scythe * matrices. * */ #ifndef SCYTHE_ALGORITHM_H #define SCYTHE_ALGORITHM_H #include #include #include #ifdef SCYTHE_COMPILE_DIRECT #include "defs.h" #include "matrix.h" #include "matrix_random_access_iterator.h" #else #include "scythestat/defs.h" #include "scythestat/matrix.h" #include "scythestat/matrix_random_access_iterator.h" #endif // These are just goofy #ifdef SCYTHE_RPACK #undef DO #undef DS #undef SO #undef SS #endif namespace scythe { namespace { typedef unsigned int uint; } /* Matrix forward declaration */ template class Matrix; /*! \brief A Functor encapsulating exponentiation. * * This function object wraps exponentiation operations for use in * generic algorithms. */ template struct exponentiate : std::binary_function { T operator() (T base, T exp) const { return std::pow(base, exp); } }; /*! \brief A Functor encapsulating \f$ax+b\f$. * * This function object wraps the operation \f$ax+b\f$ for use in * generic algorithms, where a is some constant. */ template struct ax_plus_b : std::binary_function { T a_; ax_plus_b (T a) : a_ (a) {} T operator() (T x, T b) const { return (a_ * x + b); } }; /*! \brief Iterate through a Matrix in order. * * This function iterates through a Matrix, \a M, in order, * setting each element in the Matrix to the result of an invocation * of the function object, \a func. The () operator of \a func * should take two unsigned integer parameters (i - the row offset * into \a M; j - the column offset into \a M) and return a result * of type T. * * \param M The Matrix to iterate over. * \param func The functor to execute on each iteration. * */ template void for_each_ij_set (Matrix& M, FUNCTOR func) { if (O == Col) { for (uint j = 0; j < M.cols(); ++j) for (uint i = 0; i < M.rows(); ++i) M(i, j) = func(i, j); } else { for (uint i = 0; i < M.cols(); ++i) for (uint j = 0; j < M.rows(); ++j) M(i, j) = func(i, j); } } /*! \brief Copy the contents of one Matrix into another. * * This function copies the contents of one Matrix into * another, traversing each Matrix in the order specified by the * template terms ORDER1 and ORDER2. This function requires an * explicit template call that specifies ORDER1 and ORDER2. * * \param source The Matrix to copy. * \param dest The Matrix to copy into. */ template void copy(const Matrix& source, Matrix& dest) { std::copy(source.template begin_f(), source.template end_f(), dest.template begin_f()); } /*! \brief Copy the contents of one Matrix into another. * * This function copies the contents of one Matrix into * another, traversing each Matrix in the order specified by the * template terms ORDER1 and ORDER2. If \a source is larger than \a * dest, the function only copies as many elements from \a source as * will fit in \a dest. On the other hand, if \a source is smaller * than \a dest, the function will start over at the beginning of * \a source, recycling the contents of \a source as many times as * necessary to fill \a dest. This function requires an explicit * template call that specifies ORDER1 and ORDER2. * * \param source The Matrix to copy. * \param dest The Matrix to copy into. */ template void copy_recycle (const Matrix& source, Matrix& dest) { if (source.size() == dest.size()) { copy (source, dest); } else if (source.size() > dest.size()) { const_matrix_random_access_iterator s_iter = source.template begin(); std::copy(s_iter, s_iter + dest.size(), dest.template begin_f()); } else { const_matrix_random_access_iterator s_begin = source.template begin (); matrix_random_access_iterator d_iter = dest.template begin(); matrix_random_access_iterator d_end = dest.template end(); while (d_iter != d_end) { unsigned int span = std::min(source.size(), (unsigned int) (d_end - d_iter)); d_iter = std::copy(s_begin, s_begin + span, d_iter); } } } /*! \brief Determine the sign of a number. * * This function compares \a x to (T) 0, returning (T) 1 if \a x is * greater than zero, (T) -1 if \a x is less than zero, and (T) 0 * otherwise. * * \param x The value to check. */ template inline T sgn (const T & x) { if (x > (T) 0) return (T) 1; else if (x < (T) 0) return (T) -1; else return (T) 0; } } // end namespace scythe #endif /* SCYTHE_ALGORITHM_H */ scythestat-1.0.3/scythestat/rng.h0000644000175000017500000014512611764443224014001 00000000000000/* * Scythe Statistical Library Copyright (C) 2000-2002 Andrew D. Martin * and Kevin M. Quinn; 2002-present Andrew D. Martin, Kevin M. Quinn, * and Daniel Pemstein. All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify under the terms of the GNU General Public License as * published by Free Software Foundation; either version 2 of the * License, or (at your option) any later version. See the text files * COPYING and LICENSE, distributed with this source code, for further * information. * -------------------------------------------------------------------- * scythestat/rng.h * * The code for many of the RNGs defined in this file and implemented * in rng.cc is based on that in the R project, version 1.6.0-1.7.1. * This code is available under the terms of the GNU GPL. Original * copyright: * * Copyright (C) 1998 Ross Ihaka * Copyright (C) 2000-2002 The R Development Core Team * Copyright (C) 2003 The R Foundation */ /*! * \file rng.h * * \brief The definition of the random number generator base class. * */ /* Doxygen doesn't deal well with the macros that we use to make * matrix versions of rngs easy to define. */ #ifndef SCYTHE_RNG_H #define SCYTHE_RNG_H #include #include #ifdef HAVE_IEEEFP_H #include #endif #ifdef SCYTHE_COMPILE_DIRECT #include "matrix.h" #include "error.h" #include "algorithm.h" #include "distributions.h" #include "ide.h" #include "la.h" #else #include "scythestat/matrix.h" #include "scythestat/error.h" #include "scythestat/algorithm.h" #include "scythestat/distributions.h" #include "scythestat/ide.h" #include "scythestat/la.h" #endif namespace scythe { /* Shorthand for the matrix versions of the various distributions' * random number generators. */ #define SCYTHE_RNGMETH_MATRIX(NAME, RTYPE, ARGNAMES, ...) \ template \ Matrix \ NAME (unsigned int rows, unsigned int cols, __VA_ARGS__) \ { \ Matrix ret(rows, cols, false); \ typename Matrix::forward_iterator it; \ typename Matrix::forward_iterator last \ = ret.end_f(); \ for (it = ret.begin_f(); it != last; ++it) \ *it = NAME (ARGNAMES); \ SCYTHE_VIEW_RETURN(RTYPE, O, S, ret) \ } \ \ Matrix \ NAME (unsigned int rows, unsigned int cols, __VA_ARGS__) \ { \ return NAME (rows, cols, ARGNAMES); \ } /*! \brief Random number generator. * * This class provides objects capable of generating random numbers * from a variety of probability distributions. This * abstract class forms the foundation of random number generation in * Scythe. Specific random number generators should extend this class * and implement the virtual void function runif(); this function * should take no arguments and return uniformly distributed random * numbers on the interval (0, 1). The rng class provides no * interface for seed-setting or initialization, allowing for maximal * flexibility in underlying implementation. This class does provide * implementations of functions that return random numbers from a wide * variety of commonly (and not-so-commonly) used distributions, by * manipulating the uniform variates returned by runif(). See * rng/mersenne.h and rng/lecuyer.h for the rng implementations * offered by Scythe. * * Each univariate distribution is represented by three overloaded * versions of the same method. The first is a simple method * returning a single value. The remaining method versions return * Matrix values and are equivalent to calling the single-valued * method multiple times to fill a Matrix object. They each take * two arguments describing the number of rows and columns in the * returned Matrix object and as many subsequent arguments as is * necessary to describe the distribution. As is the case * throughout the library, the Matrix-returning versions of the * method include both a general and default template. We * explicitly document only the single-valued versions of the * univariate methods. For matrix-valued distributions we provide * only a single method per distribution. * * \note Doxygen incorrectly parses the macros we use to * automatically generate the Matrix returning versions of the * various univariate methods in this class. Whenever you see the * macro variable __VA_ARGS__ in the public member function list * below, simply substitute in the arguments in the explicitly * documented single-valued version of the method. * */ template class rng { public: /* This declaration allows users to treat rng objects like * functors that generate random uniform numbers. This can be * quite convenient. */ /*! \brief Generate uniformly distributed random variates. * * This operator acts as an alias for runif() and generates * pseudo-random variates from the uniform distribution on the * interval (0, 1). We include this operator to allow rng * objects to behave as function objects. */ double operator() () { return runif(); } /* Returns random uniform numbers on (0, 1). This function must * be implemented by extending classes */ /*! \brief Generate uniformly distributed random variates. * * This method generates pseudo-random variates from the * uniform distribution on the interval (0, 1). * * This function is pure virtual and is implemented by * extending concrete classes, like scythe::mersenne and * scythe::lecuyer. */ double runif () { return as_derived().runif(); } /* No point in declaring these virtual because we have to * override them anyway because C++ isn't too bright. Also, it * is illegal to make template methods virtual */ template Matrix runif(unsigned int rows, unsigned int cols) { Matrix ret(rows, cols, false); typename Matrix::forward_iterator it; typename Matrix::forward_iterator last=ret.end_f(); for (it = ret.begin_f(); it != last; ++it) *it = runif(); return ret; } Matrix runif(unsigned int rows, unsigned int cols) { return runif(rows, cols); } /*! \brief Generate a beta distributed random variate. * * This function returns a pseudo-random variate drawn from the * beta distribution described by the shape parameters \a a and * \a b. * * \param alpha The first positive beta shape parameter. * \param beta the second positive beta shape parameter. * * \see pbeta(double x, double a, double b) * \see dbeta(double x, double a, double b) * \see betafn(double a, double b) * \see lnbetafn(double a, double b) * * \throw scythe_invalid_arg (Level 1) */ double rbeta (double alpha, double beta) { double report; double xalpha, xbeta; // Check for allowable parameters SCYTHE_CHECK_10(alpha <= 0, scythe_invalid_arg, "alpha <= 0"); SCYTHE_CHECK_10(beta <= 0, scythe_invalid_arg, "beta <= 0"); xalpha = rchisq (2 * alpha); xbeta = rchisq (2 * beta); report = xalpha / (xalpha + xbeta); return (report); } SCYTHE_RNGMETH_MATRIX(rbeta, double, SCYTHE_ARGSET(alpha, beta), double alpha, double beta); /*! \brief Generate a non-central hypergeometric disributed * random variate. * * This function returns a pseudo-random variate drawn from the * non-centrial hypergeometric distribution described by the * number of positive outcomes \a m1, the two group size * parameters \a n1 and \a n2, and the odds ratio \a psi. * * \param m1 The number of positive outcomes in both groups. * \param n1 The size of group one. * \param n2 The size of group two. * \param psi The odds ratio * \param delta The precision. * * \throw scythe_convergence_error (Level 0) */ double rnchypgeom(double m1, double n1, double n2, double psi, double delta) { // Calculate mode of mass function double a = psi - 1; double b = -1 * ((n1+m1+2)*psi + n2 - m1); double c = psi * (n1+1) * (m1+1); double q = -0.5 * ( b + sgn(b) * std::sqrt(std::pow(b,2) - 4*a*c)); double root1 = c/q; double root2 = q/a; double el = std::max(0.0, m1-n2); double u = std::min(n1,m1); double mode = std::floor(root1); int exactcheck = 0; if (u(u+1); double *fvec = new double[size]; fvec[static_cast(mode)] = 1.0; double s; // compute the mass function at y if (delta <= 0 || exactcheck==1){ //exact evaluation // sum from mode to u double f = 1.0; s = 1.0; for (double i=(mode+1); i<=u; ++i){ double r = ((n1-i+1)*(m1-i+1))/(i*(n2-m1+i)) * psi; f = f*r; s += f; fvec[static_cast(i)] = f; } // sum from mode to el f = 1.0; for (double i=(mode-1); i>=el; --i){ double r = ((n1-i)*(m1-i))/((i+1)*(n2-m1+i+1)) * psi; f = f/r; s += f; fvec[static_cast(i)] = f; } } else { // approximation double epsilon = delta/10.0; // sum from mode to ustar double f = 1.0; s = 1.0; double i = mode+1; double r; do { if (i>u) break; r = ((n1-i+1)*(m1-i+1))/(i*(n2-m1+i)) * psi; f = f*r; s += f; fvec[static_cast(i)] = f; ++i; } while(f>=epsilon || r>=5.0/6.0); // sum from mode to elstar f = 1.0; i = mode-1; do { if (i(i)] = f; --i; } while(f>=epsilon || r <=6.0/5.0); } double udraw = runif(); double psum = fvec[static_cast(mode)]/s; if (udraw<=psum) return mode; double lower = mode-1; double upper = mode+1; do{ double fl; double fu; if (lower >= el) fl = fvec[static_cast(lower)]; else fl = 0.0; if (upper <= u) fu = fvec[static_cast(upper)]; else fu = 0.0; if (fl > fu) { psum += fl/s; if (udraw<=psum) return lower; --lower; } else { psum += fu/s; if (udraw<=psum) return upper; ++upper; } } while(udraw>psum); delete [] fvec; SCYTHE_THROW(scythe_convergence_error, "Algorithm did not converge"); } SCYTHE_RNGMETH_MATRIX(rnchypgeom, double, SCYTHE_ARGSET(m1, n1, n2, psi, delta), double m1, double n1, double n2, double psi, double delta); /*! \brief Generate a Bernoulli distributed random variate. * * This function returns a pseudo-random variate drawn from the * Bernoulli distribution with probability of success \a p. * * \param p The probability of success on a trial. * * \throw scythe_invalid_arg (Level 1) */ unsigned int rbern (double p) { unsigned int report; double unif; // Check for allowable paramters SCYTHE_CHECK_10(p < 0 || p > 1, scythe_invalid_arg, "p parameter not in[0,1]"); unif = runif (); if (unif < p) report = 1; else report = 0; return (report); } SCYTHE_RNGMETH_MATRIX(rbern, unsigned int, p, double p); /*! \brief Generate a binomial distributed random variate. * * This function returns a pseudo-random variate drawn from the * binomial distribution with \a n trials and \p probability of * success on each trial. * * \param n The number of trials. * \param p The probability of success on each trial. * * \see pbinom(double x, unsigned int n, double p) * \see dbinom(double x, unsigned int n, double p) * * \throw scythe_invalid_arg (Level 1) */ unsigned int rbinom (unsigned int n, double p) { unsigned int report; unsigned int count = 0; double hold; // Check for allowable parameters SCYTHE_CHECK_10(n == 0, scythe_invalid_arg, "n == 0"); SCYTHE_CHECK_10(p < 0 || p > 1, scythe_invalid_arg, "p not in [0,1]"); // Loop and count successes for (unsigned int i = 0; i < n; i++) { hold = runif (); if (hold < p) ++count; } report = count; return (report); } SCYTHE_RNGMETH_MATRIX(rbinom, unsigned int, SCYTHE_ARGSET(n, p), unsigned int n, double p); /*! \brief Generate a \f$\chi^2\f$ distributed random variate. * * This function returns a pseudo-random variate drawn from the * \f$\chi^2\f$distribution with \a df degress of freedom. * * \param df The degrees of freedom. * * \see pchisq(double x, double df) * \see dchisq(double x, double df) * * \throw scythe_invalid_arg (Level 1) */ double rchisq (double df) { double report; // Check for allowable paramter SCYTHE_CHECK_10(df <= 0, scythe_invalid_arg, "Degrees of freedom <= 0"); // Return Gamma(nu/2, 1/2) variate report = rgamma (df / 2, .5); return (report); } SCYTHE_RNGMETH_MATRIX(rchisq, double, df, double df); /*! \brief Generate an exponentially distributed random variate. * * This function returns a pseudo-random variate drawn from the * exponential distribution described by the inverse scale * parameter \a invscale. * * \param invscale The inverse scale parameter. * * \see pexp(double x, double scale) * \see dexp(double x, double scale) * * \throw scythe_invalid_arg (Level 1) */ double rexp (double invscale) { double report; // Check for allowable parameter SCYTHE_CHECK_10(invscale <= 0, scythe_invalid_arg, "Inverse scale parameter <= 0"); report = -std::log (runif ()) / invscale; return (report); } SCYTHE_RNGMETH_MATRIX(rexp, double, invscale, double invscale); /*! \brief Generate an F distributed random variate. * * This function returns a pseudo-random variate drawn from the * F distribution with degress of freedom \a df1 and \a df2. * * \param df1 The positive degrees of freedom for the * \f$chi^2\f$ variate in the nominator of the F statistic. * \param df2 The positive degrees of freedom for the * \f$chi^2\f$ variate in the denominator of the F statistic. * * \see pf(double x, double df1, double df2) * \see df(double x, double df1, double df2) * * \throw scythe_invalid_arg (Level 1) */ double rf (double df1, double df2) { SCYTHE_CHECK_10(df1 <= 0 || df2 <= 0, scythe_invalid_arg, "n1 or n2 <= 0"); return ((rchisq(df1) / df1) / (rchisq(df2) / df2)); } SCYTHE_RNGMETH_MATRIX(rf, double, SCYTHE_ARGSET(df1, df2), double df1, double df2); /*! \brief Generate a gamma distributed random variate. * * This function returns a pseudo-random variate drawn from the * gamma distribution with a given \a shape and \a scale. * * \param shape The strictly positive shape of the distribution. * \param rate The inverse of the strictly positive scale of the distribution. That is, 1 / scale. * * \see pgamma(double x, double shape, double scale) * \see dgamma(double x, double shape, double scale) * \see gammafn(double x) * \see lngammafn(double x) * * \throw scythe_invalid_arg (Level 1) */ double rgamma (double shape, double rate) { double report; // Check for allowable parameters SCYTHE_CHECK_10(shape <= 0, scythe_invalid_arg, "shape <= 0"); SCYTHE_CHECK_10(rate <= 0, scythe_invalid_arg, "rate <= 0"); if (shape > 1) report = rgamma1 (shape) / rate; else if (shape == 1) report = -std::log (runif ()) / rate; else report = rgamma1 (shape + 1) * std::pow (runif (), 1 / shape) / rate; return (report); } SCYTHE_RNGMETH_MATRIX(rgamma, double, SCYTHE_ARGSET(shape, rate), double shape, double rate); /*! \brief Generate a logistically distributed random variate. * * This function returns a pseudo-random variate drawn from the * logistic distribution described by the given \a location and * \a scale variables. * * \param location The location of the distribution. * \param scale The scale of the distribution. * * \see plogis(double x, double location, double scale) * \see dlogis(double x, double location, double scale) * * \throw scythe_invalid_arg (Level 1) */ double rlogis (double location, double scale) { double report; double unif; // Check for allowable paramters SCYTHE_CHECK_10(scale <= 0, scythe_invalid_arg, "scale <= 0"); unif = runif (); report = location + scale * std::log (unif / (1 - unif)); return (report); } SCYTHE_RNGMETH_MATRIX(rlogis, double, SCYTHE_ARGSET(location, scale), double location, double scale); /*! \brief Generate a log-normal distributed random variate. * * This function returns a pseudo-random variate drawn from the * log-normal distribution with given logged mean and standard * deviation. * * \param logmean The logged mean of the distribtion. * \param logsd The strictly positive logged standard deviation * of the distribution. * * \see plnorm(double x, double logmean, double logsd) * \see dlnorm(double x, double logmean, double logsd) * * \throw scythe_invalid_arg (Level 1) */ double rlnorm (double logmean, double logsd) { SCYTHE_CHECK_10(logsd < 0.0, scythe_invalid_arg, "standard deviation < 0"); return std::exp(rnorm(logmean, logsd)); } SCYTHE_RNGMETH_MATRIX(rlnorm, double, SCYTHE_ARGSET(logmean, logsd), double logmean, double logsd); /*! \brief Generate a negative binomial distributed random * variate. * * This function returns a pseudo-random variate drawn from the * negative binomial distribution with given dispersion * parameter and probability of success on each trial. * * \param n The strictly positive target number of successful * trials (dispersion parameters). * \param p The probability of success on each trial. * * \see pnbinom(unsigned int x, double n, double p) * \see dnbinom(unsigned int x, double n, double p) * * \throw scythe_invalid_arg (Level 1) */ unsigned int rnbinom (double n, double p) { SCYTHE_CHECK_10(n == 0 || p <= 0 || p > 1, scythe_invalid_arg, "n == 0, p <= 0, or p > 1"); return rpois(rgamma(n, (1 - p) / p)); } SCYTHE_RNGMETH_MATRIX(rnbinom, unsigned int, SCYTHE_ARGSET(n, p), double n, double p); /*! \brief Generate a normally distributed random variate. * * This function returns a pseudo-random variate drawn from the * normal distribution with given \a mean and \a standard * distribution. * * \param mean The mean of the distribution. * \param sd The standard deviation of the distribution. * * \see pnorm(double x, double mean, double sd) * \see dnorm(double x, double mean, double sd) * * \throw scythe_invalid_arg (Level 1) */ double rnorm (double mean = 0, double sd = 1) { SCYTHE_CHECK_10(sd <= 0, scythe_invalid_arg, "Negative standard deviation"); return (mean + rnorm1 () * sd); } SCYTHE_RNGMETH_MATRIX(rnorm, double, SCYTHE_ARGSET(mean, sd), double mean, double sd); /*! \brief Generate a Poisson distributed random variate. * * This function returns a pseudo-random variate drawn from the * Poisson distribution with expected number of occurrences \a * lambda. * * \param lambda The strictly positive expected number of * occurrences. * * \see ppois(double x, double lambda) * \see dpois(double x, double lambda) * * \throw scythe_invalid_arg (Level 1) */ unsigned int rpois(double lambda) { SCYTHE_CHECK_10(lambda <= 0, scythe_invalid_arg, "lambda <= 0"); unsigned int n; if (lambda < 33) { double cutoff = std::exp(-lambda); n = -1; double t = 1.0; do { ++n; t *= runif(); } while (t > cutoff); } else { bool accept = false; double c = 0.767 - 3.36/lambda; double beta = M_PI/std::sqrt(3*lambda); double alpha = lambda*beta; double k = std::log(c) - lambda - std::log(beta); while (! accept){ double u1 = runif(); double x = (alpha - std::log((1-u1)/u1))/beta; while (x <= -0.5){ u1 = runif(); x = (alpha - std::log((1-u1)/u1))/beta; } n = static_cast(x + 0.5); double u2 = runif(); double lhs = alpha - beta*x + std::log(u2/std::pow(1+std::exp(alpha-beta*x),2)); double rhs = k + n*std::log(lambda) - lnfactorial(n); if (lhs <= rhs) accept = true; } } return n; } SCYTHE_RNGMETH_MATRIX(rpois, unsigned int, lambda, double lambda); /* There is a naming issue here, with respect to the p- and d- * functions in distributions. This is really analagous to rt1- * and dt1- XXX Clear up. Also, we should probably have a * random number generator for both versions of the student t. */ /*! \brief Generate a Student t distributed random variate. * * This function returns a pseudo-random variate drawn from the * Student's t distribution with given mean \a mu, variance \a * sigma2, and degrees of freedom \a nu * * \param mu The mean of the distribution. * \param sigma2 The variance of the distribution. * \param nu The degrees of freedom of the distribution. * * \see dt1(double x, double mu, double sigma2, double nu) * * \throw scythe_invalid_arg (Level 1) */ double rt (double mu, double sigma2, double nu) { double report; double x, z; // Check for allowable paramters SCYTHE_CHECK_10(sigma2 <= 0, scythe_invalid_arg, "Variance parameter sigma2 <= 0"); SCYTHE_CHECK_10(nu <= 0, scythe_invalid_arg, "D.O.F parameter nu <= 0"); z = rnorm1 (); x = rchisq (nu); report = mu + std::sqrt (sigma2) * z * std::sqrt (nu) / std::sqrt (x); return (report); } SCYTHE_RNGMETH_MATRIX(rt1, double, SCYTHE_ARGSET(mu, sigma2, nu), double mu, double sigma2, double nu); /*! \brief Generate a Weibull distributed random variate. * * This function returns a pseudo-random variate drawn from the * Weibull distribution with given \a shape and \a scale. * * \param shape The strictly positive shape of the distribution. * \param scale The strictly positive scale of the distribution. * * \see pweibull(double x, double shape, double scale) * \see dweibull(double x, double shape, double scale) * * \throw scythe_invalid_arg (Level 1) */ double rweibull (double shape, double scale) { SCYTHE_CHECK_10(shape <= 0 || scale <= 0, scythe_invalid_arg, "shape or scale <= 0"); return scale * std::pow(-std::log(runif()), 1.0 / shape); } SCYTHE_RNGMETH_MATRIX(rweibull, double, SCYTHE_ARGSET(shape, scale), double shape, double scale); /*! \brief Generate an inverse \f$\chi^2\f$ distributed random * variate. * * This function returns a pseudo-random variate drawn from the * inverse \f$\chi^2\f$ distribution with \a nu degress of * freedom. * * \param nu The degrees of freedom. * * \see rchisq(double df) * * \throw scythe_invalid_arg (Level 1) */ double richisq (double nu) { double report; // Check for allowable parameter SCYTHE_CHECK_10(nu <= 0, scythe_invalid_arg, "Degrees of freedom <= 0"); // Return Inverse-Gamma(nu/2, 1/2) variate report = rigamma (nu / 2, .5); return (report); } SCYTHE_RNGMETH_MATRIX(richisq, double, nu, double nu); /*! \brief Generate an inverse gamma distributed random variate. * * This function returns a pseudo-random variate drawn from the * inverse gamma distribution with given \a shape and \a scale. * * \param shape The strictly positive shape of the distribution. * \param scale The strictly positive scale of the distribution. * * \see rgamma(double alpha, double beta) * * \throw scythe_invalid_arg (Level 1) */ double rigamma (double alpha, double beta) { double report; // Check for allowable parameters SCYTHE_CHECK_10(alpha <= 0, scythe_invalid_arg, "alpha <= 0"); SCYTHE_CHECK_10(beta <= 0, scythe_invalid_arg, "beta <= 0"); // Return reciprocal of gamma variate report = std::pow (rgamma (alpha, beta), -1); return (report); } SCYTHE_RNGMETH_MATRIX(rigamma, double, SCYTHE_ARGSET(alpha, beta), double alpha, double beta); /* Truncated Distributions */ /*! \brief Generate a truncated normally distributed random * variate. * * This function returns a pseudo-random variate drawn from the * normal distribution with given \a mean and \a variance, * truncated both above and below. It uses the inverse CDF * method. * * \param mean The mean of the distribution. * \param variance The variance of the distribution. * \param below The lower truncation point of the distribution. * \param above The upper truncation point of the distribution. * * \see rtnorm_combo(double mean, double variance, double below, double above) * \see rtbnorm_slice(double mean, double variance, double below, unsigned int iter = 10) * \see rtanorm_slice(double mean, double variance, double above, unsigned int iter = 10) * \see rtbnorm_combo(double mean, double variance, double below, unsigned int iter = 10) * \see rtanorm_combo(double mean, double variance, double above, unsigned int iter = 10) * \see rnorm(double x, double mean, double sd) * * \throw scythe_invalid_arg (Level 1) */ double rtnorm(double mean, double variance, double below, double above) { SCYTHE_CHECK_10(below >= above, scythe_invalid_arg, "Truncation bound not logically consistent"); SCYTHE_CHECK_10(variance <= 0, scythe_invalid_arg, "Variance <= 0"); double sd = std::sqrt(variance); double FA = 0.0; double FB = 0.0; if ((std::fabs((above-mean)/sd) < 8.2) && (std::fabs((below-mean)/sd) < 8.2)){ FA = pnorm1((above-mean)/sd, true, false); FB = pnorm1((below-mean)/sd, true, false); } if ((((above-mean)/sd) < 8.2) && (((below-mean)/sd) <= -8.2) ){ FA = pnorm1((above-mean)/sd, true, false); FB = 0.0; } if ( (((above-mean)/sd) >= 8.2) && (((below-mean)/sd) > -8.2) ){ FA = 1.0; FB = pnorm1((below-mean)/sd, true, false); } if ( (((above-mean)/sd) >= 8.2) && (((below-mean)/sd) <= -8.2)){ FA = 1.0; FB = 0.0; } double term = runif()*(FA-FB)+FB; if (term < 5.6e-17) term = 5.6e-17; if (term > (1 - 5.6e-17)) term = 1 - 5.6e-17; double draw = mean + sd * qnorm1(term); if (draw > above) draw = above; if (draw < below) draw = below; return draw; } SCYTHE_RNGMETH_MATRIX(rtnorm, double, SCYTHE_ARGSET(mean, variance, above, below), double mean, double variance, double above, double below); /*! \brief Generate a truncated normally distributed random * variate. * * This function returns a pseudo-random variate drawn from the * normal distribution with given \a mean and \a variance, * truncated both above and below. It uses a combination of * rejection sampling (when \a below <= mean <= \a above) * sampling method of Robert and Casella (1999), pp. 288-289 * (when \a meam < \a below or \a mean > \a above). * * \param mean The mean of the distribution. * \param variance The variance of the distribution. * \param below The lower truncation point of the distribution. * \param above The upper truncation point of the distribution. * * \see rtnorm(double mean, double variance, double below, double above) * \see rtbnorm_slice(double mean, double variance, double below, unsigned int iter = 10) * \see rtanorm_slice(double mean, double variance, double above, unsigned int iter = 10) * \see rtbnorm_combo(double mean, double variance, double below, unsigned int iter = 10) * \see rtanorm_combo(double mean, double variance, double above, unsigned int iter = 10) * \see rnorm(double x, double mean, double sd) * * \throw scythe_invalid_arg (Level 1) */ double rtnorm_combo(double mean, double variance, double below, double above) { SCYTHE_CHECK_10(below >= above, scythe_invalid_arg, "Truncation bound not logically consistent"); SCYTHE_CHECK_10(variance <= 0, scythe_invalid_arg, "Variance <= 0"); double sd = std::sqrt(variance); if ((((above-mean)/sd > 0.5) && ((mean-below)/sd > 0.5)) || (((above-mean)/sd > 2.0) && ((below-mean)/sd < 0.25)) || (((mean-below)/sd > 2.0) && ((above-mean)/sd > -0.25))) { double x = rnorm(mean, sd); while ((x > above) || (x < below)) x = rnorm(mean,sd); return x; } else { // use the inverse cdf method double FA = 0.0; double FB = 0.0; if ((std::fabs((above-mean)/sd) < 8.2) && (std::fabs((below-mean)/sd) < 8.2)){ FA = pnorm1((above-mean)/sd, true, false); FB = pnorm1((below-mean)/sd, true, false); } if ((((above-mean)/sd) < 8.2) && (((below-mean)/sd) <= -8.2) ){ FA = pnorm1((above-mean)/sd, true, false); FB = 0.0; } if ( (((above-mean)/sd) >= 8.2) && (((below-mean)/sd) > -8.2) ){ FA = 1.0; FB = pnorm1((below-mean)/sd, true, false); } if ( (((above-mean)/sd) >= 8.2) && (((below-mean)/sd) <= -8.2)){ FA = 1.0; FB = 0.0; } double term = runif()*(FA-FB)+FB; if (term < 5.6e-17) term = 5.6e-17; if (term > (1 - 5.6e-17)) term = 1 - 5.6e-17; double x = mean + sd * qnorm1(term); if (x > above) x = above; if (x < below) x = below; return x; } } SCYTHE_RNGMETH_MATRIX(rtnorm_combo, double, SCYTHE_ARGSET(mean, variance, above, below), double mean, double variance, double above, double below); /*! \brief Generate a normally distributed random variate, * truncated below. * * This function returns a pseudo-random variate drawn from the * normal distribution with given \a mean and \a variance, * truncated below. It uses the slice sampling method of * Robert and Casella (1999), pp. 288-289. * * \param mean The mean of the distribution. * \param variance The variance of the distribution. * \param below The lower truncation point of the distribution. * \param iter The number of iterations to use. * * \see rtnorm(double mean, double variance, double below, double above) * \see rtnorm_combo(double mean, double variance, double below, double above) * \see rtanorm_slice(double mean, double variance, double above, unsigned int iter = 10) * \see rtbnorm_combo(double mean, double variance, double below, unsigned int iter = 10) * \see rtanorm_combo(double mean, double variance, double above, unsigned int iter = 10) * \see rnorm(double x, double mean, double sd) * * \throw scythe_invalid_arg (Level 1) */ double rtbnorm_slice (double mean, double variance, double below, unsigned int iter = 10) { SCYTHE_CHECK_10(below < mean, scythe_invalid_arg, "Truncation point < mean"); SCYTHE_CHECK_10(variance <= 0, scythe_invalid_arg, "Variance <= 0"); double z = 0; double x = below + .00001; for (unsigned int i=0; i mean, scythe_invalid_arg, "Truncation point > mean"); SCYTHE_CHECK_10(variance <= 0, scythe_invalid_arg, "Variance <= 0"); double below = -1*above; double newmu = -1*mean; double z = 0; double x = below + .00001; for (unsigned int i=0; i= \a below) and the slice * sampling method of Robert and Casella (1999), pp. 288-289 * (when \a mean < \a below). * * \param mean The mean of the distribution. * \param variance The variance of the distribution. * \param below The lower truncation point of the distribution. * \param iter The number of iterations to run the slice * sampler. * * \see rtnorm(double mean, double variance, double below, double above) * \see rtnorm_combo(double mean, double variance, double below, double above) * \see rtbnorm_slice(double mean, double variance, double below, unsigned int iter = 10) * \see rtanorm_slice(double mean, double variance, double above, unsigned int iter = 10) * \see rtanorm_combo(double mean, double variance, double above, unsigned int iter = 10) * \see rnorm(double x, double mean, double sd) * * \throw scythe_invalid_arg (Level 1) */ double rtbnorm_combo (double mean, double variance, double below, unsigned int iter = 10) { SCYTHE_CHECK_10(variance <= 0, scythe_invalid_arg, "Variance <= 0"); double s = std::sqrt(variance); // do rejection sampling and return value //if (m >= below){ if ((mean/s - below/s ) > -0.5){ double x = rnorm(mean, s); while (x < below) x = rnorm(mean,s); return x; } else if ((mean/s - below/s ) > -5.0 ){ // use the inverse cdf method double above = std::numeric_limits::infinity(); double x = rtnorm(mean, variance, below, above); return x; } else { // do slice sampling and return value double z = 0; double x = below + .00001; for (unsigned int i=0; i \a * above). * * \param mean The mean of the distribution. * \param variance The variance of the distribution. * \param above The upper truncation point of the distribution. * \param iter The number of iterations to run the slice sampler. * * \see rtnorm(double mean, double variance, double below, double above) * \see rtnorm_combo(double mean, double variance, double below, double above) * \see rtbnorm_slice(double mean, double variance, double below, unsigned int iter = 10) * \see rtanorm_slice(double mean, double variance, double above, unsigned int iter = 10) * \see rtbnorm_combo(double mean, double variance, double below, unsigned int iter = 10) * \see rnorm(double x, double mean, double sd) * * \throw scythe_invalid_arg (Level 1) */ double rtanorm_combo (double mean, double variance, double above, const unsigned int iter = 10) { SCYTHE_CHECK_10(variance <= 0, scythe_invalid_arg, "Variance <= 0"); double s = std::sqrt(variance); // do rejection sampling and return value if ((mean/s - above/s ) < 0.5){ double x = rnorm(mean, s); while (x > above) x = rnorm(mean,s); return x; } else if ((mean/s - above/s ) < 5.0 ){ // use the inverse cdf method double below = -std::numeric_limits::infinity(); double x = rtnorm(mean, variance, below, above); return x; } else { // do slice sampling and return value double below = -1*above; double newmu = -1*mean; double z = 0; double x = below + .00001; for (unsigned int i=0; i Matrix rwish(unsigned int v, const Matrix &Sigma) { SCYTHE_CHECK_10(! Sigma.isSquare(), scythe_dimension_error, "Sigma not square"); SCYTHE_CHECK_10(v < Sigma.rows(), scythe_invalid_arg, "v < Sigma.rows()"); Matrix A(Sigma.rows(), Sigma.rows()); Matrix C = cholesky(Sigma); Matrix alpha; for (unsigned int i = 0; i < v; ++i) { alpha = C * rnorm(Sigma.rows(), 1, 0, 1); A += (alpha * (t(alpha))); } return A; } /*! \brief Generate a Dirichlet distributed random variate Matrix. * * This function returns a pseudo-random matrix-valued variate * drawn from the Dirichlet disribution described by the vector * \a alpha. * * \param alpha A vector of non-negative reals. * * \throw scythe_invalid_arg (Level 1) * \throw scythe_dimension_error (Level 1) */ template Matrix rdirich(const Matrix& alpha) { // Check for allowable parameters SCYTHE_CHECK_10(std::min(alpha) <= 0, scythe_invalid_arg, "alpha has elements < 0"); SCYTHE_CHECK_10(! alpha.isColVector(), scythe_dimension_error, "alpha not column vector"); Matrix y(alpha.rows(), 1); double ysum = 0; // We would use std::transform here but rgamma is a function // and wouldn't get inlined. const_matrix_forward_iterator ait; const_matrix_forward_iterator alast = alpha.template end_f(); typename Matrix::forward_iterator yit = y.begin_f(); for (ait = alpha.begin_f(); ait != alast; ++ait) { *yit = rgamma(*ait, 1); ysum += *yit; ++yit; } y /= ysum; return y; } /*! \brief Generate a multivariate normal distributed random * variate Matrix. * * This function returns a pseudo-random matrix-valued variate * drawn from the multivariate normal disribution with means \mu * and variance-covariance matrix \a sigma. * * \param mu A vector containing the distribution means. * \param sigma The distribution variance-covariance matrix. * * \throw scythe_invalid_arg (Level 1) * \throw scythe_dimension_error (Level 1) */ template Matrix rmvnorm(const Matrix& mu, const Matrix& sigma) { unsigned int dim = mu.rows(); SCYTHE_CHECK_10(! mu.isColVector(), scythe_dimension_error, "mu not column vector"); SCYTHE_CHECK_10(! sigma.isSquare(), scythe_dimension_error, "sigma not square"); SCYTHE_CHECK_10(sigma.rows() != dim, scythe_conformation_error, "mu and sigma not conformable"); return(mu + cholesky(sigma) * rnorm(dim, 1, 0, 1)); } /*! \brief Generate a multivariate Student t distributed random * variate Matrix. * * This function returns a pseudo-random matrix-valued variate * drawn from the multivariate Student t disribution with * and variance-covariance matrix \a sigma, and degrees of * freedom \a nu * * \param sigma The distribution variance-covariance matrix. * \param nu The strictly positive degrees of freedom. * * \throw scythe_invalid_arg (Level 1) * \throw scythe_dimension_error (Level 1) */ template Matrix rmvt (const Matrix& sigma, double nu) { Matrix result; SCYTHE_CHECK_10(nu <= 0, scythe_invalid_arg, "D.O.F parameter nu <= 0"); result = rmvnorm(Matrix(sigma.rows(), 1, true, 0), sigma); result /= std::sqrt(rchisq(nu) / nu); return result; } protected: /* Default (and only) constructor */ /*! \brief Default constructor * * Instantiate a random number generator */ rng() : rnorm_count_ (1) // Initialize the normal counter {} /* For Barton and Nackman trick. */ RNGTYPE& as_derived() { return static_cast(*this); } /* Generate Standard Normal variates */ /* These instance variables were static in the old * implementation. Making them instance variables provides * thread safety, as long as two threads don't access the same * rng at the same time w/out precautions. Fixes possible * previous issues with lecuyer. See the similar approach in * rgamma1 below. */ int rnorm_count_; double x2_; double rnorm1 () { double nu1, nu2, rsquared, sqrt_term; if (rnorm_count_ == 1){ // odd numbered passses do { nu1 = -1 +2*runif(); nu2 = -1 +2*runif(); rsquared = ::pow(nu1,2) + ::pow(nu2,2); } while (rsquared >= 1 || rsquared == 0.0); sqrt_term = std::sqrt(-2*std::log(rsquared)/rsquared); x2_ = nu2*sqrt_term; rnorm_count_ = 2; return nu1*sqrt_term; } else { // even numbered passes rnorm_count_ = 1; return x2_; } } /* Generate standard gamma variates */ double accept_; double rgamma1 (double alpha) { int test; double u, v, w, x, y, z, b, c; // Check for allowable parameters SCYTHE_CHECK_10(alpha <= 1, scythe_invalid_arg, "alpha <= 1"); // Implement Best's (1978) simulator b = alpha - 1; c = 3 * alpha - 0.75; test = 0; while (test == 0) { u = runif (); v = runif (); w = u * (1 - u); y = std::sqrt (c / w) * (u - .5); x = b + y; if (x > 0) { z = 64 * std::pow (v, 2) * std::pow (w, 3); if (z <= (1 - (2 * std::pow (y, 2) / x))) { test = 1; accept_ = x; } else if ((2 * (b * std::log (x / b) - y)) >= ::log (z)) { test = 1; accept_ = x; } else { test = 0; } } } return (accept_); } }; } // end namespace scythe #endif /* RNG_H */ scythestat-1.0.3/scythestat/optimize.h0000644000175000017500000007704311764442760015061 00000000000000/* * Scythe Statistical Library Copyright (C) 2000-2002 Andrew D. Martin * and Kevin M. Quinn; 2002-present Andrew D. Martin, Kevin M. Quinn, * and Daniel Pemstein. All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify under the terms of the GNU General Public License as * published by Free Software Foundation; either version 2 of the * License, or (at your option) any later version. See the text files * COPYING and LICENSE, distributed with this source code, for further * information. * -------------------------------------------------------------------- * scythestat/optimize.h * */ /*! * \file optimize.h * \brief Definitions of functions for doing numerical optimization * and related operations. * * This file contains a number of functions that are useful for * numerical optimization and maximum likelihood estimation. In * addition, it contains some basic facilities for evaluating definite * integrals. * * As is the case across Scythe, we provide both general and default * template definitions for the functions in this file that return * Matrix objects. The general definitions allow the user to * customize the matrix_order and matrix_style of the returned Matrix, * while the default versions return concrete matrices of the same * matrix_order as the first (or only) Matrix argument to the * function. In cases where we supply these two types of definitions, * we explicitly document only the general version, although the * default definition will typically appear in the function list * below. * * \note * Doxygen has some difficulty dealing with overloaded templates. * Under certain circumstances it does not correctly process the * definitions of default templates. In these cases, the definition * for the default template will not even appear in the function list. * We provide default templates for all of the Matrix-returning * functions in this file. * */ #ifndef SCYTHE_OPTIMIZE_H #define SCYTHE_OPTIMIZE_H #ifdef SCYTHE_COMPILE_DIRECT #include "matrix.h" #include "algorithm.h" #include "error.h" #include "rng.h" #include "distributions.h" #include "la.h" #include "ide.h" #include "smath.h" #include "stat.h" #else #include "scythestat/matrix.h" #include "scythestat/algorithm.h" #include "scythestat/error.h" #include "scythestat/rng.h" #include "scythestat/distributions.h" #include "scythestat/la.h" #include "scythestat/ide.h" #include "scythestat/smath.h" #include "scythestat/stat.h" #endif /* We want to use an anonymous namespace to make the following consts * and functions local to this file, but mingw doesn't play nice with * anonymous namespaces so we do things differently when using the * cross-compiler. */ #ifdef __MINGW32__ #define SCYTHE_MINGW32_STATIC static #else #define SCYTHE_MINGW32_STATIC #endif namespace scythe { #ifndef __MINGW32__ namespace { #endif /* Functions (private to this file) that do very little... */ template SCYTHE_MINGW32_STATIC T donothing (const Matrix& x) { return (T) 0.0; } template SCYTHE_MINGW32_STATIC T donothing (T& x) { return (T) 0.0; } #ifndef __MINGW32__ } #endif /* Return the machine epsilon * Notes: Algorithm taken from Sedgewick, Robert. 1992. Algorithms * in C++. Addison Wesley. pg. 561 */ /*! \brief Compute the machine epsilon. * * The epsilon function returns the machine epsilon: the smallest * number that, when summed with 1, produces a value greater than * one. */ template T epsilon() { T eps, del, neweps; del = (T) 0.5; eps = (T) 0.0; neweps = (T) 1.0; while ( del > 0 ) { if ( 1 + neweps > 1 ) { /* Then the value might be too large */ eps = neweps; /* ...save the current value... */ neweps -= del; /* ...and decrement a bit */ } else { /* Then the value is too small */ neweps += del; /* ...so increment it */ } del *= 0.5; /* Reduce the adjustment by half */ } return eps; } /*! \brief Calculate the definite integral of a function from a to b. * * This function calculates the definite integral of a univariate * function on the interval \f$[a,b]\f$. * * \param fun The function (or functor) whose definite integral is * to be calculated. This function should both take and return a * single argument of type T. * \param a The starting value of the interval. * \param b The ending value of the interval. * \param N The number of subintervals to calculate. Increasing * this number will improve the accuracy of the estimate but will * also increase run-time. * * \throw scythe_invalid_arg (Level 1) * * \see adaptsimp(FUNCTOR fun, T a, T b, unsigned int& N, double tol = 1e-5) * \note * Users will typically wish to implement \a fun in terms of a * functor. Using a functor provides a generic way in which to * evaluate functions with more than one parameter. Furthermore, * although one can pass a function pointer to this routine, * the compiler cannot inline and fully optimize code * referenced by function pointers. */ template T intsimp (FUNCTOR fun, T a, T b, unsigned int N) { SCYTHE_CHECK_10(a > b, scythe_invalid_arg, "Lower limit larger than upper"); T I = (T) 0; T w = (b - a) / N; for (unsigned int i = 1; i <= N; ++i) I += w * (fun(a +(i - 1) *w) + 4 * fun(a - w / 2 + i * w) + fun(a + i * w)) / 6; return I; } /*! \brief Calculate the definite integral of a function from a to b. * * This function calculates the definite integral of a univariate * function on the interval \f$[a,b]\f$. * * \param fun The function (or functor) whose definite integral is * to be calculated. This function should both take and return a * single argument of type T. * \param a The starting value of the interval. * \param b The ending value of the interval. * \param N The number of subintervals to calculate. Increasing * this number will improve the accuracy of the estimate but will * also increase run-time. * \param tol The accuracy required. Both accuracy and run-time * decrease as this number increases. * * \throw scythe_invalid_arg (Level 1) * * \see intsimp(FUNCTOR fun, T a, T b, unsigned int& N) * * \note * Users will typically wish to implement \a fun in terms of a * functor. Using a functor provides a generic way in which to * evaluate functions with more than one parameter. Furthermore, * although one can pass a function pointer to this routine, * the compiler cannot inline and fully optimize code * referenced by function pointers. */ template T adaptsimp(FUNCTOR fun, T a, T b, unsigned int N, double tol = 1e-5) { SCYTHE_CHECK_10(a > b, scythe_invalid_arg, "Lower limit larger than upper"); T I = intsimp(fun, a, b, N); if (std::fabs(I - intsimp(fun, a, b, N / 2)) > tol) return adaptsimp(fun, a, (a + b) / 2, N, tol) + adaptsimp(fun, (a + b) / 2, b, N, tol); return I; } /*! \brief Calculate gradient of a function using a forward * difference formula. * * This function numerically calculates the gradient of a * vector-valued function at \a theta using a forward difference * formula. * * \param fun The function to calculate the gradient of. This * function should both take and return a single Matrix (vector) of * type T. * \param theta The column vector of values at which to calculate * the gradient of the function. * * \see gradfdifls(FUNCTOR fun, T alpha, const Matrix& theta, const Matrix& p) * \see jacfdif(FUNCTOR fun, const Matrix& theta) * \see hesscdif(FUNCTOR fun, const Matrix& theta) * * \throw scythe_dimension_error (Level 1) * * \note * Users will typically wish to implement \a fun in terms of a * functor. Using a functor provides a generic way in which to * evaluate functions with more than one parameter. Furthermore, * although one can pass a function pointer to this routine, * the compiler cannot inline and fully optimize code * referenced by function pointers. */ template Matrix gradfdif (FUNCTOR fun, const Matrix& theta) { SCYTHE_CHECK_10(! theta.isColVector(), scythe_dimension_error, "Theta not column vector"); unsigned int k = theta.size(); T h = std::sqrt(epsilon()); h = std::sqrt(h); Matrix grad(k, 1); Matrix e; Matrix temp; for (unsigned int i = 0; i < k; ++i) { e = Matrix(k, 1); e[i] = h; temp = theta + e; donothing(temp); // XXX I don't understand this e = temp - theta; grad[i] = (fun(theta + e) - fun(theta)) / e[i]; } return grad; } // Default template version template Matrix gradfdif (FUNCTOR fun, const Matrix& theta) { return gradfdif(fun, theta); } /*! \brief Calculate the first derivative of the function using * a forward difference formula. * * This function numerically calculates the first derivative of a * function with respect to \a alpha at \f$theta + alpha \cdot p\f$ * using a forward difference formula. This function is primarily * useful for linesearches. * * \param fun The function to calculate the first derivative of. * This function should take a single Matrix argument and return * a value of type T. * \param alpha Double the step length. * \param theta A Matrix (vector) of parameter values at which to * calculate the gradient. * \param p A direction vector. * * \see gradfdif(FUNCTOR fun, const Matrix& theta) * \see jacfdif(FUNCTOR fun, const Matrix& theta) * \see hesscdif(FUNCTOR fun, const Matrix& theta) * * \throw scythe_dimension_error (Level 1) * * \note * Users will typically wish to implement \a fun in terms of a * functor. Using a functor provides a generic way in which to * evaluate functions with more than one parameter. Furthermore, * although one can pass a function pointer to this routine, * the compiler cannot inline and fully optimize code * referenced by function pointers. */ template T gradfdifls (FUNCTOR fun, T alpha, const Matrix& theta, const Matrix& p) { SCYTHE_CHECK_10(! theta.isColVector(), scythe_dimension_error, "Theta not column vector"); SCYTHE_CHECK_10(! p.isColVector(), scythe_dimension_error, "p not column vector"); unsigned int k = theta.size(); T h = std::sqrt(epsilon()); h = std::sqrt(h); //T h = std::sqrt(2.2e-16); T deriv; for (unsigned int i = 0; i < k; ++i) { T temp = alpha + h; donothing(temp); T e = temp - alpha; deriv = (fun(theta + (alpha + e) * p) - fun(theta + alpha * p)) / e; } return deriv; } /*! \brief Calculate the Jacobian of a function using a forward * difference formula. * * This function numerically calculates the Jacobian of a * vector-valued function using a forward difference formula. * * \param fun The function to calculate the Jacobian of. This * function should both take and return a Matrix (vector) of type * T. * \param theta The column vector of parameter values at which to * take the Jacobian of \a fun. * * \see gradfdif(FUNCTOR fun, const Matrix& theta) * \see gradfdifls(FUNCTOR fun, T alpha, const Matrix& theta, const Matrix& p) * \see hesscdif(FUNCTOR fun, const Matrix& theta) * * \throw scythe_dimension_error (Level 1) * * \note * Users will typically wish to implement \a fun in terms of a * functor. Using a functor provides a generic way in which to * evaluate functions with more than one parameter. Furthermore, * although one can pass a function pointer to this routine, * the compiler cannot inline and fully optimize code * referenced by function pointers. */ template Matrix jacfdif (FUNCTOR fun, const Matrix& theta) { SCYTHE_CHECK_10(! theta.isColVector(), scythe_dimension_error, "Theta not column vector"); Matrix fval = fun(theta); unsigned int k = theta.rows(); unsigned int n = fval.rows(); T h = std::sqrt(epsilon()); //2.2e-16 h = std::sqrt(h); Matrix J(n,k); Matrix e; Matrix temp; Matrix fthetae; Matrix ftheta; for (int i = 0; i < k; ++i) { e = Matrix(k,1); e[i] = h; temp = theta + e; donothing(temp); /// XXX ?? e = temp - theta; fthetae = fun(theta + e); ftheta = fun(theta); for (unsigned int j = 0; j < n; ++j) { J(j,i) = (fthetae[j] - ftheta[j]) / e[i]; } } return J; } // default template template Matrix jacfdif (FUNCTOR fun, const Matrix& theta) { return jacfdif(fun, theta); } /*! \brief Calculate the Hessian of a function using a central * difference formula. * * This function numerically calculates the Hessian of a * vector-valued function using a central difference formula. * * \param fun The function to calculate the Hessian of. This * function should take a Matrix (vector) of type T and return a * single value of type T. * \param theta The column vector of parameter values at which to * calculate the Hessian. * * \see gradfdif(FUNCTOR fun, const Matrix& theta) * \see gradfdifls(FUNCTOR fun, T alpha, const Matrix& theta, const Matrix& p) * \see jacfdif(FUNCTOR fun, const Matrix& theta) * * \throw scythe_dimension_error * * \note * Users will typically wish to implement \a fun in terms of a * functor. Using a functor provides a generic way in which to * evaluate functions with more than one parameter. Furthermore, * although one can pass a function pointer to this routine, * the compiler cannot inline and fully optimize code * referenced by function pointers. */ template Matrix hesscdif (FUNCTOR fun, const Matrix& theta) { SCYTHE_CHECK_10(! theta.isColVector(), scythe_dimension_error, "Theta not column vector"); T fval = fun(theta); //std::cout << std::endl; //std::cout << "hesscdif theta = " << theta << "\n"; //std::cout << "hesscdif fun(theta) = " << fval << std::endl; unsigned int k = theta.rows(); // stepsize CAREFUL -- THIS IS MACHINE SPECIFIC !!!! T h2 = std::sqrt(epsilon()); //T h2 = (T) 1e-10; T h = std::sqrt(h2); Matrix H(k,k); //std::cout << "h2 = " << h2 << " h = " << h << std::endl; Matrix ei; Matrix ej; Matrix temp; for (unsigned int i = 0; i < k; ++i) { ei = Matrix(k, 1); ei[i] = h; temp = theta + ei; donothing(temp); // XXX Again, I'm baffled ei = temp - theta; for (unsigned int j = 0; j < k; ++j){ ej = Matrix(k,1); ej[j] = h; temp = theta + ej; donothing(temp); // XXX and again ej = temp - theta; if (i == j) { H(i,i) = ( -fun(theta + 2.0 * ei) + 16.0 * fun(theta + ei) - 30.0 * fval + 16.0 * fun(theta - ei) - fun(theta - 2.0 * ei)) / (12.0 * h2); } else { H(i,j) = ( fun(theta + ei + ej) - fun(theta + ei - ej) - fun(theta - ei + ej) + fun(theta - ei - ej)) / (4.0 * h2); } } } //std::cout << "end of hesscdif, H = " << H << "\n"; return H; } // default template template Matrix hesscdif (FUNCTOR fun, const Matrix& theta) { return hesscdif(fun, theta); } /*! \brief Find the step length that minimizes an implied 1-dimensional function. * * This function performs a line search to find the step length * that approximately minimizes an implied one dimensional * function. * * \param fun The function to minimize. This function should take * one Matrix (vector) argument of type T and return a single value * of type T. * \param theta A column vector of parameter values that anchor the * 1-dimensional function. * \param p A direction vector that creates the 1-dimensional * function. * * \see linesearch2(FUNCTOR fun, const Matrix& theta, const Matrix& p, rng& runif) * \see zoom(FUNCTOR fun, T alpha_lo, T alpha_hi, const Matrix& theta, const Matrix& p) * \see BFGS(FUNCTOR fun, const Matrix& theta, rng& runif, unsigned int maxit, T tolerance, bool trace = false) * * \throw scythe_dimension_error (Level 1) * * \note * Users will typically wish to implement \a fun in terms of a * functor. Using a functor provides a generic way in which to * evaluate functions with more than one parameter. Furthermore, * although one can pass a function pointer to this routine, * the compiler cannot inline and fully optimize code * referenced by function pointers. */ template T linesearch1 (FUNCTOR fun, const Matrix& theta, const Matrix& p) { SCYTHE_CHECK_10(! theta.isColVector(), scythe_dimension_error, "Theta not column vector"); SCYTHE_CHECK_10(! p.isColVector(), scythe_dimension_error, "p not column vector"); T alpha_bar = (T) 1.0; T rho = (T) 0.9; T c = (T) 0.5; T alpha = alpha_bar; Matrix fgrad = gradfdif(fun, theta); while (fun(theta + alpha * p) > (fun(theta) + c * alpha * t(fgrad) * p)[0]) { alpha = rho * alpha; } return alpha; } /*! \brief Find the step length that minimizes an implied 1-dimensional function. * * This function performs a line search to find the step length * that approximately minimizes an implied one dimensional * function. * * \param fun The function to minimize. This function should take * one Matrix (vector) argument of type T and return a single value * of type T. * \param theta A column vector of parameter values that anchor the * 1-dimensional function. * \param p A direction vector that creates the 1-dimensional * function. * \param runif A random uniform number generator function object * (an object that returns a random uniform variate on (0,1) when * its () operator is invoked). * * \see linesearch1(FUNCTOR fun, const Matrix& theta, const Matrix& p) * \see zoom(FUNCTOR fun, T alpha_lo, T alpha_hi, const Matrix& theta, const Matrix& p) * \see BFGS(FUNCTOR fun, const Matrix& theta, rng& runif, unsigned int maxit, T tolerance, bool trace = false) * * \throw scythe_dimension_error (Level 1) * * \note * Users will typically wish to implement \a fun in terms of a * functor. Using a functor provides a generic way in which to * evaluate functions with more than one parameter. Furthermore, * although one can pass a function pointer to this routine, * the compiler cannot inline and fully optimize code * referenced by function pointers. */ template T linesearch2 (FUNCTOR fun, const Matrix& theta, const Matrix& p, rng& runif) { SCYTHE_CHECK_10(! theta.isColVector(), scythe_dimension_error, "Theta not column vector"); SCYTHE_CHECK_10(! p.isColVector(), scythe_dimension_error, "p not column vector"); T alpha_last = (T) 0.0; T alpha_cur = (T) 1.0; T alpha_max = (T) 10.0; T c1 = (T) 1e-4; T c2 = (T) 0.5; unsigned int max_iter = 50; T fgradalpha0 = gradfdifls(fun, (T) 0, theta, p); for (unsigned int i = 0; i < max_iter; ++i) { T phi_cur = fun(theta + alpha_cur * p); T phi_last = fun(theta + alpha_last * p); if ((phi_cur > (fun(theta) + c1 * alpha_cur * fgradalpha0)) || ((phi_cur >= phi_last) && (i > 0))) { T alphastar = zoom(fun, alpha_last, alpha_cur, theta, p); return alphastar; } T fgradalpha_cur = gradfdifls(fun, alpha_cur, theta, p); if (std::fabs(fgradalpha_cur) <= -1 * c2 * fgradalpha0) return alpha_cur; if ( fgradalpha_cur >= (T) 0.0) { T alphastar = zoom(fun, alpha_cur, alpha_last, theta, p); return alphastar; } alpha_last = alpha_cur; // runif stuff below is probably not correc KQ 12/08/2006 // I think it should work now DBP 01/02/2007 alpha_cur = runif() * (alpha_max - alpha_cur) + alpha_cur; } return 0.001; } /*! \brief Find minimum of a function once bracketed. * * This function finds the minimum of a function, once bracketed. * * \param fun The function to minimize. This function should take * one Matrix (vector) argument of type T and return a single value * of type T. * \param alpha_lo The lower bracket. * \param alpha_hi The upper bracket. * \param theta A column vector of parameter values that anchor the * 1-dimensional function. * \param p A direction vector that creates the 1-dimensional * * \see linesearch1(FUNCTOR fun, const Matrix& theta, const Matrix& p) * \see linesearch2(FUNCTOR fun, const Matrix& theta, const Matrix& p, rng& runif) * \see BFGS(FUNCTOR fun, const Matrix& theta, rng& runif, unsigned int maxit, T tolerance, bool trace = false) * * \throw scythe_dimension_error (Level 1) * * \note * Users will typically wish to implement \a fun in terms of a * functor. Using a functor provides a generic way in which to * evaluate functions with more than one parameter. Furthermore, * although one can pass a function pointer to this routine, * the compiler cannot inline and fully optimize code * referenced by function pointers. * */ template T zoom (FUNCTOR fun, T alpha_lo, T alpha_hi, const Matrix& theta, const Matrix& p) { SCYTHE_CHECK_10(! theta.isColVector(), scythe_dimension_error, "Theta not column vector"); SCYTHE_CHECK_10(! p.isColVector(), scythe_dimension_error, "p not column vector"); T alpha_j = (alpha_lo + alpha_hi) / 2.0; T phi_0 = fun(theta); T c1 = (T) 1e-4; T c2 = (T) 0.5; T fgrad0 = gradfdifls(fun, (T) 0, theta, p); unsigned int count = 0; unsigned int maxit = 20; while(count < maxit) { T phi_j = fun(theta + alpha_j * p); T phi_lo = fun(theta + alpha_lo * p); if ((phi_j > (phi_0 + c1 * alpha_j * fgrad0)) || (phi_j >= phi_lo)){ alpha_hi = alpha_j; } else { T fgradj = gradfdifls(fun, alpha_j, theta, p); if (std::fabs(fgradj) <= -1 * c2 * fgrad0){ return alpha_j; } if ( fgradj * (alpha_hi - alpha_lo) >= 0){ alpha_hi = alpha_lo; } alpha_lo = alpha_j; } ++count; } return alpha_j; } /*! \brief Find function minimum using the BFGS algorithm. * * Numerically find the minimum of a function using the BFGS * algorithm. * * \param fun The function to minimize. This function should take * one Matrix (vector) argument of type T and return a single value * of type T. * \param theta A column vector of parameter values that anchor the * 1-dimensional function. * \param runif A random uniform number generator function object * (an object that returns a random uniform variate on (0,1) when * its () operator is invoked). * \param maxit The maximum number of iterations. * \param tolerance The convergence tolerance. * \param trace Boolean value determining whether BFGS should print * to stdout (defaults to false). * * \see linesearch1(FUNCTOR fun, const Matrix& theta, const Matrix& p) * \see linesearch2(FUNCTOR fun, const Matrix& theta, const Matrix& p, rng& runif) * \see zoom(FUNCTOR fun, T alpha_lo, T alpha_hi, const Matrix& theta, const Matrix& p) * * \throw scythe_dimension_error (Level 1) * \throw scythe_convergence_error (Level 0) * * \note * Users will typically wish to implement \a fun in terms of a * functor. Using a functor provides a generic way in which to * evaluate functions with more than one parameter. Furthermore, * although one can pass a function pointer to this routine, * the compiler cannot inline and fully optimize code * referenced by function pointers. */ // there were 2 versions of linesearch1-- the latter was what we // had been calling linesearch2 template Matrix BFGS (FUNCTOR fun, const Matrix& theta, rng& runif, unsigned int maxit, T tolerance, bool trace = false) { SCYTHE_CHECK_10(! theta.isColVector(), scythe_dimension_error, "Theta not column vector"); unsigned int n = theta.size(); // H is initial inverse hessian Matrix H = inv(hesscdif(fun, theta)); // gradient at starting values Matrix fgrad = gradfdif(fun, theta); Matrix thetamin = theta; Matrix fgrad_new = fgrad; Matrix I = eye(n); Matrix s; Matrix y; unsigned int count = 0; while( (t(fgrad_new)*fgrad_new)[0] > tolerance) { Matrix p = -1.0 * H * fgrad; //std::cout << "initial H * fgrad = " << H * fgrad << "\n"; //std::cout << "initial p = " << p << "\n"; T alpha = linesearch2(fun, thetamin, p, runif); //T alpha = linesearch1(fun, thetamin, p); //std::cout << "after linesearch p = " << p << "\n"; Matrix thetamin_new = thetamin + alpha * p; fgrad_new = gradfdif(fun, thetamin_new); s = thetamin_new - thetamin; y = fgrad_new - fgrad; T rho = 1.0 / (t(y) * s)[0]; H = (I - rho * s * t(y)) * H *(I - rho * y * t(s)) + rho * s * t(s); thetamin = thetamin_new; fgrad = fgrad_new; ++count; #ifndef SCYTHE_RPACK if (trace) { std::cout << "BFGS iteration = " << count << std::endl; std::cout << "thetamin = " << (t(thetamin)) ; std::cout << "gradient = " << (t(fgrad)) ; std::cout << "t(gradient) * gradient = " << (t(fgrad) * fgrad) ; std::cout << "function value = " << fun(thetamin) << std::endl << std::endl; } #endif //std::cout << "Hessian = " << hesscdif(fun, theta) << "\n"; //std::cout << "H = " << H << "\n"; //std::cout << "alpha = " << alpha << std::endl; //std::cout << "p = " << p << "\n"; //std::cout << "-1 * H * fgrad = " << -1.0 * H * fgrad << "\n"; SCYTHE_CHECK(count > maxit, scythe_convergence_error, "Failed to converge. Try better starting values"); } return thetamin; } // Default template template Matrix BFGS (FUNCTOR fun, const Matrix& theta, rng& runif, unsigned int maxit, T tolerance, bool trace = false) { return BFGS (fun, theta, runif, maxit, tolerance, trace); } /* Solves a system of n nonlinear equations in n unknowns of the form * fun(thetastar) = 0 for thetastar given the function, starting * value theta, max number of iterations, and tolerance. * Uses Broyden's method. */ /*! \brief Solve a system of nonlinear equations. * * Solves a system of n nonlinear equations in n unknowns of the form * \f$fun(\theta^*) = 0\f$ for \f$\theta^*\f$. * * \param fun The function to solve. The function should both take * and return a Matrix of type T. * \param theta A column vector of parameter values at which to * start the solve procedure. * \param maxit The maximum number of iterations. * \param tolerance The convergence tolerance. * * \throw scythe_dimension_error (Level 1) * \throw scythe_convergence_error (Level 1) * * \note * Users will typically wish to implement \a fun in terms of a * functor. Using a functor provides a generic way in which to * evaluate functions with more than one parameter. Furthermore, * although one can pass a function pointer to this routine, * the compiler cannot inline and fully optimize code * referenced by function pointers. */ template Matrix nls_broyden(FUNCTOR fun, const Matrix& theta, unsigned int maxit = 5000, T tolerance = 1e-6) { SCYTHE_CHECK_10(! theta.isColVector(), scythe_dimension_error, "Theta not column vector"); Matrix thetastar = theta; Matrix B = jacfdif(fun, thetastar); Matrix fthetastar; Matrix p; Matrix thetastar_new; Matrix fthetastar_new; Matrix s; Matrix y; for (unsigned int i = 0; i < maxit; ++i) { fthetastar = fun(thetastar); p = lu_solve(B, -1 * fthetastar); T alpha = (T) 1.0; thetastar_new = thetastar + alpha*p; fthetastar_new = fun(thetastar_new); s = thetastar_new - thetastar; y = fthetastar_new - fthetastar; B = B + ((y - B * s) * t(s)) / (t(s) * s); thetastar = thetastar_new; if (max(fabs(fthetastar_new)) < tolerance) return thetastar; } SCYTHE_THROW_10(scythe_convergence_error, "Failed to converge. Try better starting values or increase maxit"); return thetastar; } // default template template Matrix nls_broyden (FUNCTOR fun, const Matrix& theta, unsigned int maxit = 5000, T tolerance = 1e-6) { return nls_broyden(fun, theta, maxit, tolerance); } } // namespace scythe #endif /* SCYTHE_OPTIMIZE_H */ scythestat-1.0.3/scythestat/la.h0000644000175000017500000007215511550656101013601 00000000000000/* * Scythe Statistical Library Copyright (C) 2000-2002 Andrew D. Martin * and Kevin M. Quinn; 2002-present Andrew D. Martin, Kevin M. Quinn, * and Daniel Pemstein. All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify under the terms of the GNU General Public License as * published by Free Software Foundation; either version 2 of the * License, or (at your option) any later version. See the text files * COPYING and LICENSE, distributed with this source code, for further * information. * -------------------------------------------------------------------- * scythestat/la.h * */ /*! * \file la.h * \brief Definitions and implementations for functions that perform * common linear algebra manipulations on Scythe Matrix objects. * * This file provides a number of common linear algebraic functions * for use with the Matrix class. These functions include common * operations such as transposition, a number of utility functions for * creating useful matrices like the identity matrix, and efficient * implementations for common operations like the cross-product. * * \note As is the case throughout the library, we provide both * general and default template definitions of the Matrix-returning * functions in this file, explicitly providing documentation for only * the general template versions. */ #ifndef SCYTHE_LA_H #define SCYTHE_LA_H #ifdef SCYTHE_COMPILE_DIRECT #include "matrix.h" #include "algorithm.h" #include "error.h" #ifdef SCYTHE_LAPACK #include "lapack.h" #endif #else #include "scythestat/matrix.h" #include "scythestat/algorithm.h" #include "scythestat/error.h" #ifdef SCYTHE_LAPACK #include "scythestat/lapack.h" #endif #endif #include #include #include namespace scythe { namespace { typedef unsigned int uint; } /* Matrix transposition */ /*!\brief Transpose a Matrix. * * This function transposes \a M, returning a Matrix \a R where each * element of \a M, \f$M_ij\f$ is placed in position \f$R_ji\f$. * Naturally, the returned Matrix has M.cols() rows and M.rows() * columns. * * \param M The Matrix to transpose. * * \throw scythe_alloc_error (Level 1) * */ template Matrix t (const Matrix& M) { uint rows = M.rows(); uint cols = M.cols(); Matrix ret(cols, rows, false); if (PO == Col) copy(M, ret); else copy(M, ret); SCYTHE_VIEW_RETURN(T, RO, RS, ret) } template Matrix t (const Matrix& M) { return t(M); } /* Ones matrix generation */ /*! * \brief Create a matrix of ones. * * This function creates a matrix of ones, with the given dimensions * \a rows and \a cols. * * \param rows The number of rows in the resulting Matrix. * \param cols The number of columns in the resulting Matrix. * * \see eye (unsigned int k) * * \throw scythe_alloc_error (Level 1) */ template Matrix ones (unsigned int rows, unsigned int cols) { return Matrix (rows, cols, true, (T) 1); } template Matrix ones (unsigned int rows, unsigned int cols) { return ones(rows, cols); } template Matrix ones (unsigned int rows, unsigned int cols) { return ones(rows, cols); } inline Matrix ones (unsigned int rows, unsigned int cols) { return ones(rows, cols); } /* Identity Matrix generation */ // This functor contains the working parts of the eye algorithm. namespace { template struct eye_alg { T operator() (uint i, uint j) { if (i == j) return (T) 1.0; return (T) 0.0; } }; } /*!\brief Create a \a k by \a k identity Matrix. * * This function creates a \a k by \a k Matrix with 1s along the * diagonal and 0s on the off-diagonal. This template is overloaded * multiple times to provide default type, matrix_order, and * matrix_style. The default call to eye returns a Concrete Matrix * containing double precision floating point numbers, in * column-major order. The user can write explicit template calls * to generate matrices with other orders and/or styles. * * \param k The dimension of the identity Matrix. * * \see diag(const Matrix& M) * \see ones(unsigned int rows, unsigned int cols) * * \throw scythe_alloc_error (Level 1) * */ template Matrix eye (unsigned int k) { Matrix ret(k, k, false); for_each_ij_set(ret, eye_alg()); SCYTHE_VIEW_RETURN(T, O, S, ret) } template Matrix eye (uint k) { return eye(k); } template Matrix eye (uint k) { return eye(k); } inline Matrix eye (uint k) { return eye(k); } /* Create a k x 1 vector-additive sequence matrix */ // The seqa algorithm namespace { template struct seqa_alg { T cur_; T inc_; seqa_alg(T start, T inc) : cur_ (start), inc_ (inc) {} T operator() () { T ret = cur_; cur_ += inc_; return ret; } }; } /*! * \brief Create a \a rows x 1 vector-additive sequence Matrix. * * This function creates a \a rows x 1 Matrix \f$v\f$, where * \f$v_i = \mbox{start} + i \cdot \mbox{incr}\f$. * * This function is defined by a series of templates. This template * is the most general, requiring the user to explicitly instantiate * the template in terms of element type, matrix_order and * matrix_style. Further versions allow for explicit instantiation * based just on type and matrix_order (with matrix_style defaulting * to Concrete) and just on type (with matrix_style defaulting to * Col). Finally, the default version of th function generates * column-major concrete Matrix of doubles. * * \param start Desired start value. * \param incr Amount to add in each step of the sequence. * \param rows Total number of rows in the Matrix. * * \throw scythe_alloc_error (Level 1) */ template Matrix seqa (T start, T incr, uint rows) { Matrix ret(rows, 1, false); generate(ret.begin_f(), ret.end_f(), seqa_alg(start, incr)); SCYTHE_VIEW_RETURN(T, O, S, ret) } template Matrix seqa (T start, T incr, uint rows) { return seqa(start, incr, rows); } template Matrix seqa (T start, T incr, uint rows) { return seqa(start, incr, rows); } inline Matrix seqa (double start, double incr, uint rows) { return seqa(start, incr, rows); } /* Uses the STL sort to sort a Matrix in ascending row-major order */ /*! * \brief Sort a Matrix. * * This function returns a copy of \a M, sorted in ascending order. * The sorting order is determined by the template parameter * SORT_ORDER or, by default, to matrix_order of \a M. * * \param M The Matrix to sort. * * \see sortc * * \throw scythe_alloc_error (Level 1) */ template Matrix sort (const Matrix& M) { Matrix ret = M; std::sort(ret.template begin(), ret.template end()); SCYTHE_VIEW_RETURN(T, RO, RS, ret) } template Matrix sort (const Matrix& M) { return sort(M); } template Matrix sort (const Matrix& M) { return sort(M); } /*!\brief Sort the columns of a Matrix. * * This function returns a copy of \a M, with each column sorted in * ascending order. * * \param M The Matrix to sort. * * \see sort * * \throw scythe_alloc_error (Level 1) */ template Matrix sortc (const Matrix& M) { Matrix ret = M; // TODO need to figure out a way to do fully optimized // vector iteration for (uint col = 0; col < ret.cols(); ++col) { Matrix column = ret(_, col); std::sort(column.begin(), column.end()); } SCYTHE_VIEW_RETURN(T, RO, RS, ret) } template Matrix sortc(const Matrix& M) { return sortc(M); } /* Column bind two matrices */ /*! * \brief Column bind two matrices. * * This function column binds two matrices, \a A and \a B. * * \param A The left-hand Matrix. * \param B The right-hand Matrix. * * \see rbind(const Matrix& A, * const Matrix& B) * * \throw scythe_conformation_error (Level 1) * \throw scythe_alloc_error (Level 1) */ template Matrix cbind (const Matrix& A, const Matrix& B) { SCYTHE_CHECK_10(A.rows() != B.rows(), scythe_conformation_error, "Matrices have different numbers of rows"); Matrix ret(A.rows(), A.cols() + B.cols(), false); std::copy(B.template begin_f(), B.template end_f(), std::copy(A.template begin_f(), A.template end_f(), ret.template begin_f())); SCYTHE_VIEW_RETURN(T, RO, RS, ret) } template Matrix cbind (const Matrix& A, const Matrix& B) { return cbind(A, B); } /* Row bind two matrices */ /*! * \brief Row bind two matrices. * * This function row binds two matrices, \a A and \a B. * * \param A The upper Matrix. * \param B The lower Matrix. * * \see cbind(const Matrix& A, * const Matrix& B) * * \throw scythe_alloc_error (Level 1) * \throw scythe_conformation_error (Level 1) */ template Matrix rbind (const Matrix& A, const Matrix& B) { SCYTHE_CHECK_10(A.cols() != B.cols(), scythe_conformation_error, "Matrices have different numbers of columns"); Matrix ret(A.rows() + B.rows(), A.cols(), false); std::copy(B.template begin_f(), B.template end_f(), std::copy(A.template begin_f(), A.template end_f(), ret.template begin_f())); SCYTHE_VIEW_RETURN(T, RO, RS, ret) } template Matrix rbind (const Matrix& A, const Matrix& B) { return rbind(A, B); } /* Calculates the order of each element in a Matrix */ // Functor encapsulating the meat of the algorithm namespace { template struct order_alg { Matrix M_; order_alg (const Matrix& M) : M_ (M) {} uint operator() (T x) { Matrix diff = (M_ < x); return std::accumulate(diff.begin_f(), diff.end_f(), (uint) 0); } }; } /*! * \brief Calculate the rank-order of each element in a Matrix. * * This function calculates the rank-order of each element in a * Matrix, returning a Matrix in which the \e i'th element * indicates the order position of the \e i'th element of \a M. * The returned Matrix contains unsigned integers. * * \param M A column vector. * * \throw scythe_alloc_error (Level 1) */ /* NOTE This function used to only work on column vectors. I see no * reason to maintain this restriction. */ template Matrix order (const Matrix& M) { Matrix ranks(M.rows(), M.cols(), false); std::transform(M.begin_f(), M.end_f(), ranks.template begin_f(), order_alg(M)); SCYTHE_VIEW_RETURN(uint, RO, RS, ranks) } template Matrix order (const Matrix& M) { return order(M); } /* Selects all the rows of Matrix A for which binary column vector e * has an element equal to 1 */ /*! * \brief Locate rows for which a binary column vector equals 1 * This function identifies all the rows of a Matrix \a M for which * the binary column vector \a e has an element equal to 1, * returning a Matrix * \param M The Matrix of interest. * \param e A boolean column vector. * * \see unique(const Matrix& M) * * \throw scythe_conformation_error (Level 1) * \throw scythe_dimension_error (Level 1) * \throw scythe_alloc_error (Level 1) */ template Matrix selif (const Matrix& M, const Matrix& e) { SCYTHE_CHECK_10(M.rows() != e.rows(), scythe_conformation_error, "Data matrix and selection vector have different number of rows"); SCYTHE_CHECK_10(! e.isColVector(), scythe_dimension_error, "Selection matrix is not a column vector"); uint N = std::accumulate(e.begin_f(), e.end_f(), (uint) 0); Matrix res(N, M.cols(), false); int cnt = 0; for (uint i = 0; i < e.size(); ++i) { if (e[i]) { Matrix Mvec = M(i, _); // TODO again, need optimized vector iteration std::copy(Mvec.begin_f(), Mvec.end_f(), res(cnt++, _).begin_f()); } } SCYTHE_VIEW_RETURN(T, RO, RS, res) } template Matrix selif (const Matrix& M, const Matrix& e) { return selif(M, e); } /* Find unique elements in a matrix and return a sorted row vector */ /*! * \brief Find unique elements in a Matrix. * * This function identifies all of the unique elements in a Matrix, * and returns them in a sorted row vector. * * \param M The Matrix to search. * * \see selif(const Matrix& M, const Matrix& e) * * \throw scythe_alloc_error (Level 1) */ template Matrix unique (const Matrix& M) { std::set u(M.begin_f(), M.end_f()); Matrix res(1, u.size(), false); std::copy(u.begin(), u.end(), res.begin_f()); SCYTHE_VIEW_RETURN(T, RO, RS, res) } template Matrix unique (const Matrix& M) { return unique(M); } /* NOTE I killed reshape. It seems redundant with resize. DBP */ /* Make vector out of unique elements of a symmetric Matrix. */ /*! * \brief Vectorize a symmetric Matrix. * * This function returns a column vector containing only those * elements necessary to reconstruct the symmetric Matrix, \a M. In * practice, this means extracting one triangle of \a M and * returning it as a vector. * * Note that the symmetry check in this function (active at error * level 3) is quite costly. * * \param M A symmetric Matrix. * * \throw scythe_dimension_error (Level 3) * \throw scythe_alloc_error (Level 1) * * \see xpnd(const Matrix& v) */ template Matrix vech (const Matrix& M) { SCYTHE_CHECK_30(! M.isSymmetric(), scythe_dimension_error, "Matrix not symmetric"); Matrix res((uint) (0.5 * (M.size() - M.rows())) + M.rows(), 1, false); typename Matrix::forward_iterator it = res.begin_f(); /* We want to traverse M in storage order if possible so we take * the upper triangle of row-order matrices and the lower triangle * of column-order matrices. */ if (M.storeorder() == Col) { for (uint i = 0; i < M.rows(); ++i) { Matrix strip = M(i, i, M.rows() - 1, i); it = std::copy(strip.begin_f(), strip.end_f(), it); } } else { for (uint j = 0; j < M.cols(); ++j) { Matrix strip = M(j, j, j, M.cols() - 1); it = std::copy(strip.begin_f(), strip.end_f(), it); } } SCYTHE_VIEW_RETURN(T, RO, RS, res) } template Matrix vech (const Matrix& M) { return vech(M); } /*! Expand a vector into a symmetric Matrix. * * This function takes the vector \a v and returns a symmetric * Matrix containing the elements of \a v within each triangle. * * \param \a v The vector expand. * * \see vech(const Matrix& M) * * \throw scythe_dimension_error (Level 1) * \throw scythe_alloc_error (Level 1) */ template Matrix xpnd (const Matrix& v) { double size_d = -.5 + .5 * std::sqrt(1. + 8 * v.size()); SCYTHE_CHECK_10(std::fmod(size_d, 1.) != 0., scythe_dimension_error, "Input vector can't generate square matrix"); uint size = (uint) size_d; Matrix res(size, size, false); /* It doesn't matter if we travel in order here. * TODO Might want to use iterators. */ uint cnt = 0; for (uint i = 0; i < size; ++i) for (uint j = i; j < size; ++j) res(i, j) = res(j, i) = v[cnt++]; SCYTHE_VIEW_RETURN(T, RO, RS, res) } template Matrix xpnd (const Matrix& v) { return xpnd(v); } /* Get the diagonal of a Matrix. */ /*! * \brief Return the diagonal of a Matrix. * * This function returns the diagonal of a Matrix in a row vector. * * \param M The Matrix one wishes to extract the diagonal of. * * \see crossprod (const Matrix &M) * * \throw scythe_alloc_error (Level 1) */ template Matrix diag (const Matrix& M) { Matrix res(std::min(M.rows(), M.cols()), 1, false); /* We want to use iterators to maximize speed for both concretes * and views, but we always want to tranvers M in order to avoid * slowing down concretes. */ uint incr = 1; if (PO == Col) incr += M.rows(); else incr += M.cols(); typename Matrix::const_iterator pit; typename Matrix::forward_iterator rit = res.begin_f(); for (pit = M.begin(); pit < M.end(); pit += incr) *rit++ = *pit; SCYTHE_VIEW_RETURN(T, RO, RS, res) } template Matrix diag (const Matrix& M) { return diag(M); } /* Fast calculation of A*B+C. */ namespace { // Algorithm when one matrix is 1x1 template void gaxpy_alg(Matrix& res, const Matrix& X, const Matrix& B, T constant) { res = Matrix(X.rows(), X.cols(), false); if (maj_col()) std::transform(X.template begin_f(), X.template end_f(), B.template begin_f(), res.template begin_f(), ax_plus_b(constant)); else std::transform(X.template begin_f(), X.template end_f(), B.template begin_f(), res.template begin_f(), ax_plus_b(constant)); } } /*! Fast caclulation of \f$AB + C\f$. * * This function calculates \f$AB + C\f$ efficiently, traversing the * matrices in storage order where possible, and avoiding the use of * extra temporary matrix objects. * * Matrices conform when \a A, \a B, and \a C are chosen with * dimensions * \f$((m \times n), (1 \times 1), (m \times n))\f$, * \f$((1 \times 1), (n \times k), (n \times k))\f$, or * \f$((m \times n), (n \times k), (m \times k))\f$. * * Scythe will use LAPACK/BLAS routines to compute \f$AB+C\f$ * with column-major matrices of double-precision floating point * numbers if LAPACK/BLAS is available and you compile your program * with the SCYTHE_LAPACK flag enabled. * * \param A A \f$1 \times 1\f$ or \f$m \times n\f$ Matrix. * \param B A \f$1 \times 1\f$ or \f$n \times k\f$ Matrix. * \param C A \f$m \times n\f$ or \f$n \times k\f$ or * \f$m \times k\f$ Matrix. * * \throw scythe_conformation_error (Level 0) * \throw scythe_alloc_error (Level 1) */ template Matrix gaxpy (const Matrix& A, const Matrix& B, const Matrix& C) { Matrix res; if (A.isScalar() && B.rows() == C.rows() && B.cols() == C.cols()) { // Case 1: 1x1 * nXk + nXk gaxpy_alg(res, B, C, A[0]); } else if (B.isScalar() && A.rows() == C.rows() && A.cols() == C.cols()) { // Case 2: m x n * 1 x 1 + m x n gaxpy_alg(res, A, C, B[0]); } else if (A.cols() == B.rows() && A.rows() == C.rows() && B.cols() == C.cols()) { // Case 3: m x n * n x k + m x k res = Matrix (A.rows(), B.cols(), false); /* These are identical to matrix mult, one optimized for * row-major and one for col-major. */ T tmp; if (RO == Col) { // col-major optimized for (uint j = 0; j < B.cols(); ++j) { for (uint i = 0; i < A.rows(); ++i) res(i, j) = C(i, j); for (uint l = 0; l < A.cols(); ++l) { tmp = B(l, j); for (uint i = 0; i < A.rows(); ++i) res(i, j) += tmp * A(i, l); } } } else { // row-major optimized for (uint i = 0; i < A.rows(); ++i) { for (uint j = 0; j < B.cols(); ++j) res(i, j) = C(i, j); for (uint l = 0; l < B.rows(); ++l) { tmp = A(i, l); for (uint j = 0; j < B.cols(); ++j) res(i, j) += tmp * B(l,j); } } } } else { SCYTHE_THROW(scythe_conformation_error, "Expects (m x n * 1 x 1 + m x n)" << "or (1 x 1 * n x k + n x k)" << "or (m x n * n x k + m x k)"); } SCYTHE_VIEW_RETURN(T, RO, RS, res) } template Matrix gaxpy (const Matrix& A, const Matrix& B, const Matrix& C) { return gaxpy(A,B,C); } /*! Fast caclulation of \f$A'A\f$. * * This function calculates \f$A'A\f$ efficiently, traversing the * matrices in storage order where possible, and avoiding the use of * the temporary matrix objects. * * Scythe will use LAPACK/BLAS routines to compute the cross-product * of column-major matrices of double-precision floating point * numbers if LAPACK/BLAS is available and you compile your program * with the SCYTHE_LAPACK flag enabled. * * \param A The Matrix to return the cross product of. * * \see diag (const Matrix& M) */ template Matrix crossprod (const Matrix& A) { /* When rows > 1, we provide differing implementations of the * algorithm depending on A's ordering to maximize strided access. * * The non-vector version of the algorithm fills in a triangle and * then copies it over. */ Matrix res; T tmp; if (A.rows() == 1) { res = Matrix(A.cols(), A.cols(), true); for (uint k = 0; k < A.rows(); ++k) { for (uint i = 0; i < A.cols(); ++i) { tmp = A(k, i); for (uint j = i; j < A.cols(); ++j) { res(j, i) = res(i, j) += tmp * A(k, j); } } } } else { if (PO == Row) { // row-major optimized /* TODO: This is a little slower than the col-major. Improve. */ res = Matrix(A.cols(), A.cols(), true); for (uint k = 0; k < A.rows(); ++k) { for (uint i = 0; i < A.cols(); ++i) { tmp = A(k, i); for (uint j = i; j < A.cols(); ++j) { res(i, j) += tmp * A(k, j); } } } for (uint i = 0; i < A.cols(); ++i) for (uint j = i + 1; j < A.cols(); ++j) res(j, i) = res(i, j); } else { // col-major optimized res = Matrix(A.cols(), A.cols(), false); for (uint j = 0; j < A.cols(); ++j) { for (uint i = j; i < A.cols(); ++i) { tmp = (T) 0; for (uint k = 0; k < A.rows(); ++k) tmp += A(k, i) * A(k, j); res(i, j) = tmp; } } for (uint i = 0; i < A.cols(); ++i) for (uint j = i + 1; j < A.cols(); ++j) res(i, j) = res(j, i); } } SCYTHE_VIEW_RETURN(T, RO, RS, res) } template Matrix crossprod (const Matrix& M) { return crossprod(M); } #ifdef SCYTHE_LAPACK /* Template specializations of for col-major, concrete * matrices of doubles that are only available when a lapack library * is available. */ template<> inline Matrix<> gaxpy (const Matrix<>& A, const Matrix<>& B, const Matrix<>& C) { SCYTHE_DEBUG_MSG("Using lapack/blas for gaxpy"); Matrix<> res; if (A.isScalar() && B.rows() == C.rows() && B.cols() == C.cols()) { // Case 1: 1x1 * nXk + nXk gaxpy_alg(res, B, C, A[0]); } else if (B.isScalar() && A.rows() == C.rows() && A.cols() == C.cols()) { // Case 2: m x n * 1 x 1 + m x n gaxpy_alg(res, A, C, B[0]); } else if (A.cols() == B.rows() && A.rows() == C.rows() && B.cols() == C.cols()) { res = C; // NOTE: this copy may eat up speed gains, but can't be // avoided. // Case 3: m x n * n x k + m x k double* Apnt = A.getArray(); double* Bpnt = B.getArray(); double* respnt = res.getArray(); const double one(1.0); int rows = (int) res.rows(); int cols = (int) res.cols(); int innerDim = A.cols(); lapack::dgemm_("N", "N", &rows, &cols, &innerDim, &one, Apnt, &rows, Bpnt, &innerDim, &one, respnt, &rows); } return res; } template<> inline Matrix<> crossprod(const Matrix<>& A) { SCYTHE_DEBUG_MSG("Using lapack/blas for crossprod"); // Set up some constants const double zero = 0.0; const double one = 1.0; // Set up return value and arrays Matrix<> res(A.cols(), A.cols(), false); double* Apnt = A.getArray(); double* respnt = res.getArray(); int rows = (int) A.rows(); int cols = (int) A.cols(); lapack::dsyrk_("L", "T", &cols, &rows, &one, Apnt, &rows, &zero, respnt, &cols); lapack::make_symmetric(respnt, cols); return res; } #endif } // end namespace scythe #endif /* SCYTHE_LA_H */ scythestat-1.0.3/scythestat/ide.h0000644000175000017500000020271611550656101013744 00000000000000/* * Scythe Statistical Library Copyright (C) 2000-2002 Andrew D. Martin * and Kevin M. Quinn; 2002-present Andrew D. Martin, Kevin M. Quinn, * and Daniel Pemstein. All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify under the terms of the GNU General Public License as * published by Free Software Foundation; either version 2 of the * License, or (at your option) any later version. See the text files * COPYING and LICENSE, distributed with this source code, for further * information. * -------------------------------------------------------------------- * scythestat/ide.h * * */ /*! \file ide.h * * \brief Definitions for inversion and decomposition functions that * operate on Scythe's Matrix objects. * * This file provides a number of common inversion and decomposition * routines that operate on Matrix objects. It also provides related * functions for solving linear systems of equations and calculating * the determinant of a Matrix. * * Scythe will use LAPACK/BLAS routines to perform these operations on * concrete column-major matrices of double-precision floating point * numbers if LAPACK/BLAS is available and you compile your program * with the SCYTHE_LAPACK flag enabled. * * \note As is the case throughout the library, we provide both * general and default template definitions of the Matrix-returning * functions in this file, explicitly providing documentation for only * the general template versions. As is also often the case, Doxygen * does not always correctly add the default template definition to * the function list below; there is always a default template * definition available for every function. */ /* TODO: This interface exposes the user to too much implementation. * We need a solve function and a solver object. By default, solve * would run lu_solve and the solver factory would return lu_solvers * (or perhaps a solver object encapsulating an lu_solver). Users * could choose cholesky when appropriate. Down the road, qr or svd * would become the default and we'd be able to handle non-square * matrices. Instead of doing an lu_decomp or a cholesky and keeping * track of the results to repeatedly solve for different b's with A * fixed in Ax=b, you'd just call the operator() on your solver object * over and over, passing the new b each time. No decomposition * specific solvers (except as toggles to the solver object and * solve function). We'd still provide cholesky and lu_decomp. We * could also think about a similar approach to inversion (one * inversion function with an option for method). * * If virtual dispatch in C++ wasn't such a performance killer (no * compiler optimization across virtual calls!!!) there would be an * obvious implementation of this interface using simple polymorphism. * Unfortunately, we need compile-time typing to maintain performance * and makes developing a clean interface that doesn't force users to * be template wizards much harder. Initial experiments with the * Barton and Nackman trick were ugly. The engine approach might work * a bit better but has its problems too. This is not going to get * done for the 1.0 release, but it is something we should come back * to. * */ #ifndef SCYTHE_IDE_H #define SCYTHE_IDE_H #ifdef SCYTHE_COMPILE_DIRECT #include "matrix.h" #include "error.h" #include "defs.h" #ifdef SCYTHE_LAPACK #include "lapack.h" #include "stat.h" #endif #else #include "scythestat/matrix.h" #include "scythestat/error.h" #include "scythestat/defs.h" #ifdef SCYTHE_LAPACK #include "scythestat/lapack.h" #include "scythestat/stat.h" #endif #endif #include #include #include namespace scythe { namespace { typedef unsigned int uint; } /*! * \brief Cholesky decomposition of a symmetric positive-definite * matrix. * * This function performs Cholesky decomposition. That is, given a * symmetric positive definite Matrix, \f$A\f$, cholesky() returns a * lower triangular Matrix \f$L\f$ such that \f$A = LL^T\f$. This * function is faster than lu_decomp() and, therefore, preferable in * cases where one's Matrix is symmetric positive definite. * * \param A The symmetric positive definite Matrix to decompose. * * \see chol_solve(const Matrix &, const Matrix &) * \see chol_solve(const Matrix &, const Matrix &, const Matrix &) * \see lu_decomp(Matrix, Matrix&, Matrix&, Matrix&) * * \throw scythe_alloc_error (Level 1) * \throw scythe_dimension_error (Level 1) * \throw scythe_null_error (Level 1) * \throw scythe_type_error (Level 2) * \throw scythe_alloc_error (Level 1) * */ template Matrix cholesky (const Matrix& A) { SCYTHE_CHECK_10(! A.isSquare(), scythe_dimension_error, "Matrix not square"); SCYTHE_CHECK_10(A.isNull(), scythe_null_error, "Matrix is NULL"); // Rounding errors can make this problematic. Leaving out for now //SCYTHE_CHECK_20(! A.isSymmetric(), scythe_type_error, // "Matrix not symmetric"); Matrix temp (A.rows(), A.cols(), false); T h; if (PO == Row) { // row-major optimized for (uint i = 0; i < A.rows(); ++i) { for (uint j = i; j < A.cols(); ++j) { h = A(i,j); for (uint k = 0; k < i; ++k) h -= temp(i, k) * temp(j, k); if (i == j) { SCYTHE_CHECK_20(h <= (T) 0, scythe_type_error, "Matrix not positive definite"); temp(i,i) = std::sqrt(h); } else { temp(j,i) = (((T) 1) / temp(i,i)) * h; temp(i,j) = (T) 0; } } } } else { // col-major optimized for (uint j = 0; j < A.cols(); ++j) { for (uint i = j; i < A.rows(); ++i) { h = A(i, j); for (uint k = 0; k < j; ++k) h -= temp(j, k) * temp(i, k); if (i == j) { SCYTHE_CHECK_20(h <= (T) 0, scythe_type_error, "Matrix not positive definite"); temp(j,j) = std::sqrt(h); } else { temp(i,j) = (((T) 1) / temp(j,j)) * h; temp(j,i) = (T) 0; } } } } SCYTHE_VIEW_RETURN(T, RO, RS, temp) } template Matrix cholesky (const Matrix& A) { return cholesky(A); } namespace { /* This internal routine encapsulates the * algorithm used within chol_solve and lu_solve. */ template inline void solve(const Matrix& L, const Matrix& U, Matrix b, T* x, T* y) { T sum; /* TODO: Consider optimizing for ordering. Experimentation * shows performance gains are probably minor (compared col-major * with and without lapack solve routines). */ // solve M*y = b for (uint i = 0; i < b.size(); ++i) { sum = T (0); for (uint j = 0; j < i; ++j) { sum += L(i,j) * y[j]; } y[i] = (b[i] - sum) / L(i, i); } // solve M'*x = y if (U.isNull()) { // A= LL^T for (int i = b.size() - 1; i >= 0; --i) { sum = T(0); for (uint j = i + 1; j < b.size(); ++j) { sum += L(j,i) * x[j]; } x[i] = (y[i] - sum) / L(i, i); } } else { // A = LU for (int i = b.size() - 1; i >= 0; --i) { sum = T(0); for (uint j = i + 1; j < b.size(); ++j) { sum += U(i,j) * x[j]; } x[i] = (y[i] - sum) / U(i, i); } } } } /*!\brief Solve \f$Ax=b\f$ for x via backward substitution, given a * lower triangular matrix resulting from Cholesky decomposition * * This function solves the system of equations \f$Ax = b\f$ via * backward substitution. \a L is the lower triangular matrix generated * by Cholesky decomposition such that \f$A = LL'\f$. * * This function is intended for repeatedly solving systems of * equations based on \a A. That is \a A stays constant while \a * b varies. * * \param A A symmetric positive definite Matrix. * \param b A column vector with as many rows as \a A. * \param M The lower triangular matrix from the Cholesky decomposition of \a A. * * \see chol_solve(const Matrix&, const Matrix&) * \see cholesky(const Matrix&) * \see lu_solve (const Matrix&, const Matrix&, const Matrix&, const Matrix&, const Matrix&) * \see lu_solve (Matrix, const Matrix&) * * \throw scythe_alloc_error (Level 1) * \throw scythe_null_error (Level 1) * \throw scythe_dimension_error (Level 1) * \throw scythe_conformation_error (Level 1) * */ template Matrix chol_solve (const Matrix& A, const Matrix& b, const Matrix& M) { SCYTHE_CHECK_10(A.isNull(), scythe_null_error, "A is NULL") SCYTHE_CHECK_10(! b.isColVector(), scythe_dimension_error, "b must be a column vector"); SCYTHE_CHECK_10(A.rows() != b.rows(), scythe_conformation_error, "A and b do not conform"); SCYTHE_CHECK_10(A.rows() != M.rows(), scythe_conformation_error, "A and M do not conform"); SCYTHE_CHECK_10(! M.isSquare(), scythe_dimension_error, "M must be square"); T *y = new T[A.rows()]; T *x = new T[A.rows()]; solve(M, Matrix<>(), b, x, y); Matrix result(A.rows(), 1, x); delete[]x; delete[]y; return result; } template Matrix chol_solve (const Matrix& A, const Matrix& b, const Matrix& M) { return chol_solve(A,b,M); } /*!\brief Solve \f$Ax=b\f$ for x via backward substitution, * using Cholesky decomposition * * This function solves the system of equations \f$Ax = b\f$ via * backward substitution and Cholesky decomposition. \a A must be a * symmetric positive definite matrix for this method to work. This * function calls cholesky() to perform the decomposition. * * \param A A symmetric positive definite matrix. * \param b A column vector with as many rows as \a A. * * \see chol_solve(const Matrix&, const Matrix&, const Matrix&) * \see cholesky(const Matrix&) * \see lu_solve (const Matrix&, const Matrix&, const Matrix&, const Matrix&, const Matrix&) * \see lu_solve (Matrix, const Matrix&) * * \throw scythe_alloc_error (Level 1) * \throw scythe_null_error (Level 1) * \throw scythe_conformation_error (Level 1) * \throw scythe_dimension_error (Level 1) * \throw scythe_type_error (Level 2) * \throw scythe_alloc_error (Level 1) * */ template Matrix chol_solve (const Matrix& A, const Matrix& b) { /* NOTE: cholesky() call does check for square/posdef of A, * and the overloaded chol_solve call handles dimensions */ return chol_solve(A, b, cholesky(A)); } template Matrix chol_solve (const Matrix& A, const Matrix& b) { return chol_solve(A, b); } /*!\brief Calculates the inverse of a symmetric positive definite * matrix, given a lower triangular matrix resulting from Cholesky * decomposition. * * This function returns the inverse of a symmetric positive * definite matrix. Unlike the one-parameter version, this function * requires the caller to perform Cholesky decomposition on the * matrix to invert, ahead of time. * * \param A The symmetric positive definite matrix to invert. * \param M The lower triangular matrix from the Cholesky decomposition of \a A. * * \see invpd(const Matrix&) * \see inv(const Matrix&, const Matrix&, const Matrix&, const Matrix&) * \see inv(const Matrix&) * \see cholesky(const Matrix&) * * \throw scythe_alloc_error (Level 1) * \throw scythe_null_error (Level 1) * \throw scythe_conformation_error (Level 1) * \throw scythe_dimension_error (Level 1) */ template Matrix invpd (const Matrix& A, const Matrix& M) { SCYTHE_CHECK_10(A.isNull(), scythe_null_error, "A is NULL") SCYTHE_CHECK_10(! A.isSquare(), scythe_dimension_error, "A is not square") SCYTHE_CHECK_10(A.rows() != M.cols() || A.cols() != M.rows(), scythe_conformation_error, "A and M do not conform"); // for chol_solve block T *y = new T[A.rows()]; T *x = new T[A.rows()]; Matrix b(A.rows(), 1); // full of zeros Matrix null; // For final answer Matrix Ainv(A.rows(), A.cols(), false); for (uint k = 0; k < A.rows(); ++k) { b[k] = (T) 1; solve(M, null, b, x, y); b[k] = (T) 0; for (uint l = 0; l < A.rows(); ++l) Ainv(l,k) = x[l]; } delete[] y; delete[] x; SCYTHE_VIEW_RETURN(T, RO, RS, Ainv) } template Matrix invpd (const Matrix& A, const Matrix& M) { return invpd(A, M); } /*!\brief Calculate the inverse of a symmetric positive definite * matrix. * * This function returns the inverse of a symmetric positive definite * matrix, using cholesky() to do the necessary decomposition. This * method is significantly faster than the generalized inverse * function. * * \param A The symmetric positive definite matrix to invert. * * \see invpd(const Matrix&, const Matrix&) * \see inv (const Matrix&, const Matrix&, const Matrix&, const Matrix&) * \see inv (const Matrix&) * * \throw scythe_alloc_error (Level 1) * \throw scythe_null_error (Level 1) * \throw scythe_conformation_error (Level 1) * \throw scythe_dimension_error (Level 1) * \throw scythe_type_error (Level 2) */ template Matrix invpd (const Matrix& A) { // Cholesky checks to see if A is square and symmetric return invpd(A, cholesky(A)); } template Matrix invpd (const Matrix& A) { return invpd(A); } /* This code is based on Algorithm 3.4.1 of Golub and Van Loan 3rd * edition, 1996. Major difference is in how the output is * structured. Returns the sign of the row permutation (used by * det). Internal function, doesn't need doxygen. */ namespace { template inline T lu_decomp_alg(Matrix& A, Matrix& L, Matrix& U, Matrix& perm_vec) { if (A.isRowVector()) { L = Matrix (1, 1, true, 1); // all 1s U = A; perm_vec = Matrix(1, 1); // all 0s return (T) 0; } L = U = Matrix(A.rows(), A.cols(), false); perm_vec = Matrix (A.rows() - 1, 1, false); uint pivot; T temp; T sign = (T) 1; for (uint k = 0; k < A.rows() - 1; ++k) { pivot = k; // find pivot for (uint i = k; i < A.rows(); ++i) { if (std::fabs(A(pivot,k)) < std::fabs(A(i,k))) pivot = i; } SCYTHE_CHECK_20(A(pivot,k) == (T) 0, scythe_type_error, "Matrix is singular"); // permute if (k != pivot) { sign *= -1; for (uint i = 0; i < A.rows(); ++i) { temp = A(pivot,i); A(pivot,i) = A(k,i); A(k,i) = temp; } } perm_vec[k] = pivot; for (uint i = k + 1; i < A.rows(); ++i) { A(i,k) = A(i,k) / A(k,k); for (uint j = k + 1; j < A.rows(); ++j) A(i,j) = A(i,j) - A(i,k) * A(k,j); } } L = A; for (uint i = 0; i < A.rows(); ++i) { for (uint j = i; j < A.rows(); ++j) { U(i,j) = A(i,j); L(i,j) = (T) 0; L(i,i) = (T) 1; } } return sign; } } /* Calculates the LU Decomposition of a square Matrix */ /* Note that the L, U, and perm_vec must be concrete. A is passed by * value, because it is changed during the decomposition. If A is a * view, it will get mangled, but the decomposition will work fine. * Not sure what the copy/view access trade-off is, but passing a * view might speed things up if you don't care about messing up * your matrix. */ /*! \brief LU decomposition of a square matrix. * * This function performs LU decomposition. That is, given a * non-singular square matrix \a A and three matrix references, \a * L, \a U, and \a perm_vec, lu_decomp fills the latter three * matrices such that \f$LU = A\f$. This method does not actually * calculate the LU decomposition of \a A, but of a row-wise * permutation of \a A. This permutation is recorded in perm_vec. * * \note Note that \a L, \a U, and \a perm_vec must be concrete. * \a A is passed by value because the function modifies it during * the decomposition. Users should generally avoid passing Matrix * views as the first argument to this function because this * results in modification to the Matrix being viewed. * * \param A Non-singular square matrix to decompose. * \param L Lower triangular portion of LU decomposition of A. * \param U Upper triangular portion of LU decomposition of A. * \param perm_vec Permutation vector recording the row-wise permutation of A actually decomposed by the algorithm. * * \see cholesky (const Matrix&) * \see lu_solve (const Matrix&, const Matrix&, const Matrix&, const Matrix&, const Matrix&) * \see lu_solve (Matrix, const Matrix&) * * \throw scythe_null_error (Level 1) * \throw scythe_dimension_error (Level 1) * \throw scythe_type_error (Level 2) */ template void lu_decomp(Matrix A, Matrix& L, Matrix& U, Matrix& perm_vec) { SCYTHE_CHECK_10(A.isNull(), scythe_null_error, "A is NULL") SCYTHE_CHECK_10(! A.isSquare(), scythe_dimension_error, "Matrix A not square"); lu_decomp_alg(A, L, U, perm_vec); } /* lu_solve overloaded: you need A, b + L, U, perm_vec from * lu_decomp. * */ /*! \brief Solve \f$Ax=b\f$ for x via forward and backward * substitution, given the results of a LU decomposition. * * This function solves the system of equations \f$Ax = b\f$ via * forward and backward substitution and LU decomposition. \a A * must be a non-singular square matrix for this method to work. * This function requires the actual LU decomposition to be * performed ahead of time; by lu_decomp() for example. * * This function is intended for repeatedly solving systems of * equations based on \a A. That is \a A stays constant while \a * b varies. * * \param A Non-singular square Matrix to decompose, passed by reference. * \param b Column vector with as many rows as \a A. * \param L Lower triangular portion of LU decomposition of \a A. * \param U Upper triangular portion of LU decomposition of \a A. * \param perm_vec Permutation vector recording the row-wise permutation of \a A actually decomposed by the algorithm. * * \see lu_solve (Matrix, const Matrix&) * \see lu_decomp(Matrix, Matrix&, Matrix&, Matrix&) * \see chol_solve(const Matrix &, const Matrix &) * \see chol_solve(const Matrix &, const Matrix &, const Matrix &) * * \throw scythe_null_error (Level 1) * \throw scythe_dimension_error (Level 1) * \throw scythe_conformation_error (Level 1) */ template Matrix lu_solve (const Matrix& A, const Matrix& b, const Matrix& L, const Matrix& U, const Matrix &perm_vec) { SCYTHE_CHECK_10(A.isNull(), scythe_null_error, "A is NULL") SCYTHE_CHECK_10(! b.isColVector(), scythe_dimension_error, "b is not a column vector"); SCYTHE_CHECK_10(! A.isSquare(), scythe_dimension_error, "A is not square"); SCYTHE_CHECK_10(A.rows() != b.rows(), scythe_conformation_error, "A and b have different row sizes"); SCYTHE_CHECK_10(A.rows() != L.rows() || A.rows() != U.rows() || A.cols() != L.cols() || A.cols() != U.cols(), scythe_conformation_error, "A, L, and U do not conform"); SCYTHE_CHECK_10(perm_vec.rows() + 1 != A.rows(), scythe_conformation_error, "perm_vec does not have exactly one less row than A"); T *y = new T[A.rows()]; T *x = new T[A.rows()]; Matrix bb = row_interchange(b, perm_vec); solve(L, U, bb, x, y); Matrix result(A.rows(), 1, x); delete[]x; delete[]y; return result; } template Matrix lu_solve (const Matrix& A, const Matrix& b, const Matrix& L, const Matrix& U, const Matrix &perm_vec) { return lu_solve(A, b, L, U, perm_vec); } /*! \brief Solve \f$Ax=b\f$ for x via forward and backward * substitution, using LU decomposition * * This function solves the system of equations \f$Ax = b\f$ via * forward and backward substitution and LU decomposition. \a A * must be a non-singular square matrix for this method to work. * * \param A A non-singular square Matrix to decompose. * \param b A column vector with as many rows as \a A. * * \see lu_solve (const Matrix&, const Matrix&, const Matrix&, const Matrix&, const Matrix&) * \see lu_decomp(Matrix, Matrix&, Matrix&, Matrix&) * \see chol_solve(const Matrix &, const Matrix &) * \see chol_solve(const Matrix &, const Matrix &, const Matrix &) * * \throw scythe_null_error (Level 1) * \throw scythe_dimension_error (Level 1) * \throw scythe_conformation_error (Level 1) * \throw scythe_type_error (Level 2) */ template Matrix lu_solve (Matrix A, const Matrix& b) { // step 1 compute the LU factorization Matrix L, U; Matrix perm_vec; lu_decomp_alg(A, L, U, perm_vec); return lu_solve(A, b, L, U, perm_vec); } template Matrix lu_solve (Matrix A, const Matrix& b) { // Slight code rep here, but very few lines // step 1 compute the LU factorization Matrix L, U; Matrix perm_vec; lu_decomp_alg(A, L, U, perm_vec); return lu_solve(A, b, L, U, perm_vec); } /*!\brief Calculates the inverse of a non-singular square matrix, * given an LU decomposition. * * This function returns the inverse of an arbitrary, non-singular, * square matrix \a A when passed a permutation of an LU * decomposition, such as that returned by lu_decomp(). A * one-parameter version of this function exists that does not * require the user to pre-decompose the system. * * \param A The Matrix to be inverted. * \param L A Lower triangular matrix resulting from decomposition. * \param U An Upper triangular matrix resulting from decomposition. * \param perm_vec The permutation vector recording the row-wise permutation of \a A actually decomposed by the algorithm. * * \see inv (const Matrix&) * \see invpd(const Matrix&) * \see invpd(const Matrix&, const Matrix&) * \see lu_decomp(Matrix, Matrix&, Matrix&, Matrix&) * * \throw scythe_null_error(Level 1) * \throw scythe_dimension_error (Level 1) * \throw scythe_conformation_error (Level 1) */ template Matrix inv (const Matrix& A, const Matrix& L, const Matrix& U, const Matrix& perm_vec) { SCYTHE_CHECK_10(A.isNull(), scythe_null_error, "A is NULL") SCYTHE_CHECK_10 (! A.isSquare(), scythe_dimension_error, "A is not square"); SCYTHE_CHECK_10(A.rows() != L.rows() || A.rows() != U.rows() || A.cols() != L.cols() || A.cols() != U.cols(), scythe_conformation_error, "A, L, and U do not conform"); SCYTHE_CHECK_10(perm_vec.rows() + 1 != A.rows() && !(A.isScalar() && perm_vec.isScalar()), scythe_conformation_error, "perm_vec does not have exactly one less row than A"); // For the final result Matrix Ainv(A.rows(), A.rows(), false); // for the solve block T *y = new T[A.rows()]; T *x = new T[A.rows()]; Matrix b(A.rows(), 1); // full of zeros Matrix bb; for (uint k = 0; k < A.rows(); ++k) { b[k] = (T) 1; bb = row_interchange(b, perm_vec); solve(L, U, bb, x, y); b[k] = (T) 0; for (uint l = 0; l < A.rows(); ++l) Ainv(l,k) = x[l]; } delete[] y; delete[] x; SCYTHE_VIEW_RETURN(T, RO, RS, Ainv) } template Matrix inv (const Matrix& A, const Matrix& L, const Matrix& U, const Matrix& perm_vec) { return inv(A, L, U, perm_vec); } /*!\brief Invert an arbitrary, non-singular, square matrix. * * This function returns the inverse of a non-singular square matrix, * using lu_decomp() to do the necessary decomposition. This method * is significantly slower than the inverse function for symmetric * positive definite matrices, invpd(). * * \param A The Matrix to be inverted. * * \see inv (const Matrix&, const Matrix&, const Matrix&, const Matrix&) * \see invpd(const Matrix&) * \see invpd(const Matrix&, const Matrix&) * * \throw scythe_null_error(Level 1) * \throw scythe_dimension_error (Level 1) * \throw scythe_conformation_error (Level 1) * \throw scythe_type_error (Level 2) */ template Matrix inv (const Matrix& A) { // Make a copy of A for the decomposition (do it with an explicit // copy to a concrete case A is a view) Matrix AA = A; // step 1 compute the LU factorization Matrix L, U; Matrix perm_vec; lu_decomp_alg(AA, L, U, perm_vec); return inv(A, L, U, perm_vec); } template Matrix inv (const Matrix& A) { return inv(A); } /* Interchanges the rows of A with those in vector p */ /*!\brief Interchange the rows of a Matrix according to a * permutation vector. * * This function permutes the rows of Matrix \a A according to \a * perm_vec. Each element i of perm_vec contains a row-number, r. * For each row, i, in \a A, A[i] is interchanged with A[r]. * * \param A The matrix to permute. * \param p The column vector describing the permutations to perform * on \a A. * * \see lu_decomp(Matrix, Matrix&, Matrix&, Matrix&) * * \throw scythe_dimension_error (Level 1) * \throw scythe_conformation_error (Level 1) */ template Matrix row_interchange (Matrix A, const Matrix& p) { SCYTHE_CHECK_10(! p.isColVector(), scythe_dimension_error, "p not a column vector"); SCYTHE_CHECK_10(p.rows() + 1 != A.rows() && ! p.isScalar(), scythe_conformation_error, "p must have one less row than A"); for (uint i = 0; i < A.rows() - 1; ++i) { Matrix vec1 = A(i, _); Matrix vec2 = A(p[i], _); std::swap_ranges(vec1.begin_f(), vec1.end_f(), vec2.begin_f()); } return A; } template Matrix row_interchange (const Matrix& A, const Matrix& p) { return row_interchange(A, p); } /*! \brief Calculate the determinant of a square Matrix. * * This routine calculates the determinant of a square Matrix, using * LU decomposition. * * \param A The Matrix to calculate the determinant of. * * \see lu_decomp(Matrix, Matrix&, Matrix&, Matrix&) * * \throws scythe_dimension_error (Level 1) * \throws scythe_null_error (Level 1) */ template T det (const Matrix& A) { SCYTHE_CHECK_10(! A.isSquare(), scythe_dimension_error, "Matrix is not square") SCYTHE_CHECK_10(A.isNull(), scythe_null_error, "Matrix is NULL") // Make a copy of A for the decomposition (do it here instead of // at parameter pass in case A is a view) Matrix AA = A; // step 1 compute the LU factorization Matrix L, U; Matrix perm_vec; T sign = lu_decomp_alg(AA, L, U, perm_vec); // step 2 calculate the product of diag(U) and sign T det = (T) 1; for (uint i = 0; i < AA.rows(); ++i) det *= AA(i, i); return sign * det; } #ifdef SCYTHE_LAPACK template<> inline Matrix<> cholesky (const Matrix<>& A) { SCYTHE_DEBUG_MSG("Using lapack/blas for cholesky"); SCYTHE_CHECK_10(! A.isSquare(), scythe_dimension_error, "Matrix not square"); SCYTHE_CHECK_10(A.isNull(), scythe_null_error, "Matrix is NULL"); // We have to do an explicit copy within the func to match the // template declaration of the more general template. Matrix<> AA = A; // Get a pointer to the internal array and set up some vars double* Aarray = AA.getArray(); // internal array pointer int rows = (int) AA.rows(); // the dim of the matrix int err = 0; // The output error condition // Cholesky decomposition step lapack::dpotrf_("L", &rows, Aarray, &rows, &err); SCYTHE_CHECK_10(err > 0, scythe_type_error, "Matrix is not positive definite") SCYTHE_CHECK_10(err < 0, scythe_invalid_arg, "The " << err << "th value of the matrix had an illegal value") // Zero out upper triangle for (uint j = 1; j < AA.cols(); ++j) for (uint i = 0; i < j; ++i) AA(i, j) = 0; return AA; } template<> inline Matrix<> chol_solve (const Matrix<>& A, const Matrix<>& b, const Matrix<>& M) { SCYTHE_DEBUG_MSG("Using lapack/blas for chol_solve"); SCYTHE_CHECK_10(A.isNull(), scythe_null_error, "A is NULL") SCYTHE_CHECK_10(! b.isColVector(), scythe_dimension_error, "b must be a column vector"); SCYTHE_CHECK_10(A.rows() != b.rows(), scythe_conformation_error, "A and b do not conform"); SCYTHE_CHECK_10(A.rows() != M.rows(), scythe_conformation_error, "A and M do not conform"); SCYTHE_CHECK_10(! M.isSquare(), scythe_dimension_error, "M must be square"); // The algorithm modifies b in place. We make a copy. Matrix<> bb = b; // Get array pointers and set up some vars const double* Marray = M.getArray(); double* barray = bb.getArray(); int rows = (int) bb.rows(); int cols = (int) bb.cols(); // currently always one, but generalizable int err = 0; // Solve the system lapack::dpotrs_("L", &rows, &cols, Marray, &rows, barray, &rows, &err); SCYTHE_CHECK_10(err > 0, scythe_type_error, "Matrix is not positive definite") SCYTHE_CHECK_10(err < 0, scythe_invalid_arg, "The " << err << "th value of the matrix had an illegal value") return bb; } template<> inline Matrix<> chol_solve (const Matrix<>& A, const Matrix<>& b) { SCYTHE_DEBUG_MSG("Using lapack/blas for chol_solve"); SCYTHE_CHECK_10(A.isNull(), scythe_null_error, "A is NULL") SCYTHE_CHECK_10(! b.isColVector(), scythe_dimension_error, "b must be a column vector"); SCYTHE_CHECK_10(A.rows() != b.rows(), scythe_conformation_error, "A and b do not conform"); // The algorithm modifies both A and b in place, so we make copies Matrix<> AA =A; Matrix<> bb = b; // Get array pointers and set up some vars double* Aarray = AA.getArray(); double* barray = bb.getArray(); int rows = (int) bb.rows(); int cols = (int) bb.cols(); // currently always one, but generalizable int err = 0; // Solve the system lapack::dposv_("L", &rows, &cols, Aarray, &rows, barray, &rows, &err); SCYTHE_CHECK_10(err > 0, scythe_type_error, "Matrix is not positive definite") SCYTHE_CHECK_10(err < 0, scythe_invalid_arg, "The " << err << "th value of the matrix had an illegal value") return bb; } template inline double lu_decomp_alg(Matrix<>& A, Matrix& L, Matrix& U, Matrix& perm_vec) { SCYTHE_DEBUG_MSG("Using lapack/blas for lu_decomp_alg"); SCYTHE_CHECK_10(A.isNull(), scythe_null_error, "A is NULL") SCYTHE_CHECK_10 (! A.isSquare(), scythe_dimension_error, "A is not square"); if (A.isRowVector()) { L = Matrix (1, 1, true, 1); // all 1s U = A; perm_vec = Matrix(1, 1); // all 0s return 0.; } L = U = Matrix(A.rows(), A.cols(), false); perm_vec = Matrix (A.rows(), 1, false); // Get a pointer to the internal array and set up some vars double* Aarray = A.getArray(); // internal array pointer int rows = (int) A.rows(); // the dim of the matrix int* ipiv = (int*) perm_vec.getArray(); // Holds the lu decomp pivot array int err = 0; // The output error condition // Do the decomposition lapack::dgetrf_(&rows, &rows, Aarray, &rows, ipiv, &err); SCYTHE_CHECK_10(err > 0, scythe_type_error, "Matrix is singular"); SCYTHE_CHECK_10(err < 0, scythe_lapack_internal_error, "The " << err << "th value of the matrix had an illegal value"); // Now fill in the L and U matrices. L = A; for (uint i = 0; i < A.rows(); ++i) { for (uint j = i; j < A.rows(); ++j) { U(i,j) = A(i,j); L(i,j) = 0.; L(i,i) = 1.; } } // Change to scythe's rows-1 perm_vec format and c++ indexing // XXX Cutting off the last pivot term may be buggy if it isn't // always just pointing at itself if (perm_vec(perm_vec.size() - 1) != perm_vec.size()) SCYTHE_THROW(scythe_unexpected_default_error, "This is an unexpected error. Please notify the developers.") perm_vec = perm_vec(0, 0, perm_vec.rows() - 2, 0) - 1; // Finally, figure out the sign of perm_vec if (sum(perm_vec > 0) % 2 == 0) return 1; return -1; } /*! \brief The result of a QR decomposition. * * Objects of this type contain three matrices, \a QR, \a tau, and * \a pivot, representing the results of a QR decomposition of a * \f$m \times n\f$ matrix. After decomposition, the upper triangle * of \a QR contains the min(\f$m\f$, \f$n\f$) by \f$n\f$ upper * trapezoidal matrix \f$R\f$, while \a tau and the elements of \a * QR below the diagonal represent the orthogonal matrix \f$Q\f$ as * a product of min(\f$m\f$, \f$n\f$) elementary reflectors. The * vector \a pivot is a permutation vector containing information * about the pivoting strategy used in the factorization. * * \a QR is \f$m \times n\f$, tau is a vector of dimension * min(\f$m\f$, \f$n\f$), and pivot is a vector of dimension * \f$n\f$. * * \see qr_decomp (const Matrix<>& A) */ struct QRdecomp { Matrix<> QR; Matrix<> tau; Matrix<> pivot; }; /*! \brief QR decomposition of a matrix. * * This function performs QR decomposition. That is, given a * \f$m \times n \f$ matrix \a A, qr_decomp computes the QR factorization * of \a A with column pivoting, such that \f$A \cdot P = Q \cdot * R\f$. The resulting QRdecomp object contains three matrices, \a * QR, \a tau, and \a pivot. The upper triangle of \a QR contains the * min(\f$m\f$, \f$n\f$) by \f$n\f$ upper trapezoidal matrix * \f$R\f$, while \a tau and the elements of \a QR below the * diagonal represent the orthogonal matrix \f$Q\f$ as a product of * min(\f$m\f$, \f$n\f$) elementary reflectors. The vector \a pivot * is a permutation vector containing information about the pivoting * strategy used in the factorization. * * \note This function requires BLAS/LAPACK functionality and is * only available on machines that provide these libraries. Make * sure you enable the SCYTHE_LAPACK preprocessor flag if you wish * to use this function. Furthermore, note that this function takes * and returns only column-major concrete matrices. Future versions * of Scythe will provide a native C++ implementation of this * function with support for general matrix templates. * * \param A A matrix to decompose. * * \see QRdecomp * \see lu_decomp(Matrix, Matrix&, Matrix&, Matrix&) * \see cholesky (const Matrix&) * \see qr_solve (const Matrix<>& A, const Matrix<>& b, const QRdecomp& QR) * \see qr_solve (const Matrix<>& A, const Matrix<>& b); * * \throw scythe_null_error (Level 1) * \throw scythe_lapack_internal_error (Level 1) */ inline QRdecomp qr_decomp (const Matrix<>& A) { SCYTHE_DEBUG_MSG("Using lapack/blas for qr_decomp"); SCYTHE_CHECK_10(A.isNull(), scythe_null_error, "A is NULL"); // Set up working variables Matrix<> QR = A; double* QRarray = QR.getArray(); // input/output array pointer int rows = (int) QR.rows(); int cols = (int) QR.cols(); Matrix pivot(cols, 1); // pivot vector int* parray = (int*) pivot.getArray(); // pivot vector array pointer Matrix<> tau = Matrix<>(rows < cols ? rows : cols, 1); double* tarray = tau.getArray(); // tau output array pointer double tmp, *work; // workspace vars int lwork, info; // workspace size var and error info var // Get workspace size lwork = -1; lapack::dgeqp3_(&rows, &cols, QRarray, &rows, parray, tarray, &tmp, &lwork, &info); SCYTHE_CHECK_10(info != 0, scythe_lapack_internal_error, "Internal error in LAPACK routine dgeqp3"); lwork = (int) tmp; work = new double[lwork]; // run the routine for real lapack::dgeqp3_(&rows, &cols, QRarray, &rows, parray, tarray, work, &lwork, &info); SCYTHE_CHECK_10(info != 0, scythe_lapack_internal_error, "Internal error in LAPACK routine dgeqp3"); delete[] work; pivot -= 1; QRdecomp result; result.QR = QR; result.tau = tau; result.pivot = pivot; return result; } /*! \brief Solve \f$Ax=b\f$ given a QR decomposition. * * This function solves the system of equations \f$Ax = b\f$ using * the results of a QR decomposition. This function requires the * actual QR decomposition to be performed ahead of time; by * qr_decomp() for example. * * This function is intended for repeatedly solving systems of * equations based on \a A. That is \a A stays constant while \a b * varies. * * \note This function requires BLAS/LAPACK functionality and is * only available on machines that provide these libraries. Make * sure you enable the SCYTHE_LAPACK preprocessor flag if you wish * to use this function. Furthermore, note that this function takes * and returns only column-major concrete matrices. Future versions * of Scythe will provide a native C++ implementation of this * function with support for general matrix templates. * * \param A A Matrix to decompose. * \param b A Matrix with as many rows as \a A. * \param QR A QRdecomp object containing the result of the QR decomposition of \a A. * * \see QRdecomp * \see qr_solve (const Matrix<>& A, const Matrix<>& b) * \see qr_decomp (const Matrix<>& A) * \see lu_solve (const Matrix&, const Matrix&, const Matrix&, const Matrix&, const Matrix&) * \see lu_solve (Matrix, const Matrix&) * \see chol_solve(const Matrix &, const Matrix &) * \see chol_solve(const Matrix &, const Matrix &, const Matrix &) * * \throw scythe_null_error (Level 1) * \throw scythe_conformation_error (Level 1) * \throw scythe_type_error (Level 1) * \throw scythe_lapack_internal_error (Level 1) */ inline Matrix<> qr_solve(const Matrix<>& A, const Matrix<>& b, const QRdecomp& QR) { SCYTHE_DEBUG_MSG("Using lapack/blas for qr_solve"); SCYTHE_CHECK_10(A.isNull(), scythe_null_error, "A is NULL") SCYTHE_CHECK_10(A.rows() != b.rows(), scythe_conformation_error, "A and b do not conform"); SCYTHE_CHECK_10(A.rows() != QR.QR.rows() || A.cols() != QR.QR.cols(), scythe_conformation_error, "A and QR do not conform"); int taudim = (int) (A.rows() < A.cols() ? A.rows() : A.cols()); SCYTHE_CHECK_10(QR.tau.size() != taudim, scythe_conformation_error, "A and tau do not conform"); SCYTHE_CHECK_10(QR.pivot.size() != A.cols(), scythe_conformation_error, "pivot vector is not the right length"); int rows = (int) QR.QR.rows(); int cols = (int) QR.QR.cols(); int nrhs = (int) b.cols(); int lwork, info; double *work, tmp; double* QRarray = QR.QR.getArray(); double* tarray = QR.tau.getArray(); Matrix<> bb = b; double* barray = bb.getArray(); // Get workspace size lwork = -1; lapack::dormqr_("L", "T", &rows, &nrhs, &taudim, QRarray, &rows, tarray, barray, &rows, &tmp, &lwork, &info); SCYTHE_CHECK_10(info != 0, scythe_lapack_internal_error, "Internal error in LAPACK routine dormqr"); // And now for real lwork = (int) tmp; work = new double[lwork]; lapack::dormqr_("L", "T", &rows, &nrhs, &taudim, QRarray, &rows, tarray, barray, &rows, work, &lwork, &info); SCYTHE_CHECK_10(info != 0, scythe_lapack_internal_error, "Internal error in LAPACK routine dormqr"); lapack::dtrtrs_("U", "N", "N", &taudim, &nrhs, QRarray, &rows, barray, &rows, &info); SCYTHE_CHECK_10(info > 0, scythe_type_error, "Matrix is singular"); SCYTHE_CHECK_10(info < 0, scythe_lapack_internal_error, "Internal error in LAPACK routine dtrtrs"); delete[] work; Matrix<> result(A.cols(), b.cols(), false); for (uint i = 0; i < QR.pivot.size(); ++i) result(i, _) = bb((uint) QR.pivot(i), _); return result; } /*! \brief Solve \f$Ax=b\f$ using QR decomposition. * * This function solves the system of equations \f$Ax = b\f$ using * QR decomposition. This function is intended for repeatedly * solving systems of equations based on \a A. That is \a A stays * constant while \a b varies. * * \note This function used BLAS/LAPACK support functionality and is * only available on machines that provide these libraries. Make * sure you enable the SCYTHE_LAPACK preprocessor flag if you wish * to use this function. Furthermore, note that the function takes * and returns only column-major concrete matrices. Future versions * of Scythe will provide a native C++ implementation of this * function with support for general matrix templates. * * \param A A Matrix to decompose. * \param b A Matrix with as many rows as \a A. * * \see QRdecomp * \see qr_solve (const Matrix<>& A, const Matrix<>& b, const QRdecomp& QR) * \see qr_decomp (const Matrix<>& A) * \see lu_solve (const Matrix&, const Matrix&, const Matrix&, const Matrix&, const Matrix&) * \see lu_solve (Matrix, const Matrix&) * \see chol_solve(const Matrix &, const Matrix &) * \see chol_solve(const Matrix &, const Matrix &, const Matrix &) * * \throw scythe_null_error (Level 1) * \throw scythe_conformation_error (Level 1) * \throw scythe_type_error (Level 1) * \throw scythe_lapack_internal_error (Level 1) */ inline Matrix<> qr_solve (const Matrix<>& A, const Matrix<>& b) { SCYTHE_DEBUG_MSG("Using lapack/blas for qr_solve"); SCYTHE_CHECK_10(A.isNull(), scythe_null_error, "A is NULL") SCYTHE_CHECK_10(A.rows() != b.rows(), scythe_conformation_error, "A and b do not conform"); /* Do decomposition */ // Set up working variables Matrix<> QR = A; double* QRarray = QR.getArray(); // input/output array pointer int rows = (int) QR.rows(); int cols = (int) QR.cols(); Matrix pivot(cols, 1); // pivot vector int* parray = (int*) pivot.getArray(); // pivot vector array pointer Matrix<> tau = Matrix<>(rows < cols ? rows : cols, 1); double* tarray = tau.getArray(); // tau output array pointer double tmp, *work; // workspace vars int lwork, info; // workspace size var and error info var // Get workspace size lwork = -1; lapack::dgeqp3_(&rows, &cols, QRarray, &rows, parray, tarray, &tmp, &lwork, &info); SCYTHE_CHECK_10(info != 0, scythe_lapack_internal_error, "Internal error in LAPACK routine dgeqp3"); lwork = (int) tmp; work = new double[lwork]; // run the routine for real lapack::dgeqp3_(&rows, &cols, QRarray, &rows, parray, tarray, work, &lwork, &info); SCYTHE_CHECK_10(info != 0, scythe_lapack_internal_error, "Internal error in LAPACK routine dgeqp3"); delete[] work; pivot -= 1; /* Now solve the system */ // working vars int nrhs = (int) b.cols(); Matrix<> bb = b; double* barray = bb.getArray(); int taudim = (int) tau.size(); // Get workspace size lwork = -1; lapack::dormqr_("L", "T", &rows, &nrhs, &taudim, QRarray, &rows, tarray, barray, &rows, &tmp, &lwork, &info); SCYTHE_CHECK_10(info != 0, scythe_lapack_internal_error, "Internal error in LAPACK routine dormqr"); // And now for real lwork = (int) tmp; work = new double[lwork]; lapack::dormqr_("L", "T", &rows, &nrhs, &taudim, QRarray, &rows, tarray, barray, &rows, work, &lwork, &info); SCYTHE_CHECK_10(info != 0, scythe_lapack_internal_error, "Internal error in LAPACK routine dormqr"); lapack::dtrtrs_("U", "N", "N", &taudim, &nrhs, QRarray, &rows, barray, &rows, &info); SCYTHE_CHECK_10(info > 0, scythe_type_error, "Matrix is singular"); SCYTHE_CHECK_10(info < 0, scythe_lapack_internal_error, "Internal error in LAPACK routine dtrtrs"); delete[] work; Matrix<> result(A.cols(), b.cols(), false); for (uint i = 0; i < pivot.size(); ++i) result(i, _) = bb(pivot(i), _); return result; } template<> inline Matrix<> invpd (const Matrix<>& A) { SCYTHE_DEBUG_MSG("Using lapack/blas for invpd"); SCYTHE_CHECK_10(A.isNull(), scythe_null_error, "A is NULL") SCYTHE_CHECK_10 (! A.isSquare(), scythe_dimension_error, "A is not square"); // We have to do an explicit copy within the func to match the // template declaration of the more general template. Matrix<> AA = A; // Get a pointer to the internal array and set up some vars double* Aarray = AA.getArray(); // internal array pointer int rows = (int) AA.rows(); // the dim of the matrix int err = 0; // The output error condition // Cholesky decomposition step lapack::dpotrf_("L", &rows, Aarray, &rows, &err); SCYTHE_CHECK_10(err > 0, scythe_type_error, "Matrix is not positive definite") SCYTHE_CHECK_10(err < 0, scythe_invalid_arg, "The " << err << "th value of the matrix had an illegal value") // Inversion step lapack::dpotri_("L", &rows, Aarray, &rows, &err); SCYTHE_CHECK_10(err > 0, scythe_type_error, "The (" << err << ", " << err << ") element of the matrix is zero" << " and the inverse could not be computed") SCYTHE_CHECK_10(err < 0, scythe_invalid_arg, "The " << err << "th value of the matrix had an illegal value") lapack::make_symmetric(Aarray, rows); return AA; } template<> inline Matrix<> invpd (const Matrix<>& A, const Matrix<>& M) { SCYTHE_DEBUG_MSG("Using lapack/blas for invpd"); SCYTHE_CHECK_10(A.isNull(), scythe_null_error, "A is NULL") SCYTHE_CHECK_10 (! A.isSquare(), scythe_dimension_error, "A is not square"); SCYTHE_CHECK_10(A.rows() != M.cols() || A.cols() != M.rows(), scythe_conformation_error, "A and M do not conform"); // We have to do an explicit copy within the func to match the // template declaration of the more general template. Matrix<> MM = M; // Get pointer and set up some vars double* Marray = MM.getArray(); int rows = (int) MM.rows(); int err = 0; // Inversion step lapack::dpotri_("L", &rows, Marray, &rows, &err); SCYTHE_CHECK_10(err > 0, scythe_type_error, "The (" << err << ", " << err << ") element of the matrix is zero" << " and the inverse could not be computed") SCYTHE_CHECK_10(err < 0, scythe_invalid_arg, "The " << err << "th value of the matrix had an illegal value") lapack::make_symmetric(Marray, rows); return MM; } template <> inline Matrix<> inv(const Matrix<>& A) { SCYTHE_DEBUG_MSG("Using lapack/blas for inv"); SCYTHE_CHECK_10(A.isNull(), scythe_null_error, "A is NULL") SCYTHE_CHECK_10 (! A.isSquare(), scythe_dimension_error, "A is not square"); // We have to do an explicit copy within the func to match the // template declaration of the more general template. Matrix<> AA = A; // Get a pointer to the internal array and set up some vars double* Aarray = AA.getArray(); // internal array pointer int rows = (int) AA.rows(); // the dim of the matrix int* ipiv = new int[rows]; // Holds the lu decomp pivot array int err = 0; // The output error condition // LU decomposition step lapack::dgetrf_(&rows, &rows, Aarray, &rows, ipiv, &err); SCYTHE_CHECK_10(err > 0, scythe_type_error, "Matrix is singular"); SCYTHE_CHECK_10(err < 0, scythe_invalid_arg, "The " << err << "th value of the matrix had an illegal value"); // Inversion step; first do a workspace query, then the actual // inversion double work_query = 0; int work_size = -1; lapack::dgetri_(&rows, Aarray, &rows, ipiv, &work_query, &work_size, &err); double* workspace = new double[(work_size = (int) work_query)]; lapack::dgetri_(&rows, Aarray, &rows, ipiv, workspace, &work_size, &err); delete[] ipiv; delete[] workspace; SCYTHE_CHECK_10(err > 0, scythe_type_error, "Matrix is singular"); SCYTHE_CHECK_10(err < 0, scythe_invalid_arg, "Internal error in LAPACK routine dgetri"); return AA; } /*!\brief The result of a singular value decomposition. * * Objects of this type hold the results of a singular value * decomposition (SVD) of an \f$m \times n\f$ matrix \f$A\f$, as * returned by svd(). The SVD takes the form: \f$A = U * \cdot \Sigma \cdot V'\f$. SVD objects contain \a d, which * holds the singular values of \f$A\f$ (the diagonal of * \f$\Sigma\f$) in descending order. Furthermore, depending on the * options passed to svd(), they may hold some or all of the * left singular vectors of \f$A\f$ in \a U and some or all of the * right singular vectors of \f$A\f$ in \a Vt. * * \see svd(const Matrix<>& A, int nu, int nv); */ struct SVD { Matrix<> d; // singular values Matrix<> U; // left singular vectors Matrix<> Vt; // transpose of right singular vectors }; /*!\brief Calculates the singular value decomposition of a matrix, * optionally computing the left and right singular vectors. * * This function returns the singular value decomposition (SVD) of a * \f$m \times n\f$ matrix \a A, optionally computing the left and right * singular vectors. It returns the singular values and vectors in * a SVD object. * * \note This function requires BLAS/LAPACK functionality and is * only available on machines that provide these libraries. Make * sure you enable the SCYTHE_LAPACK preprocessor flag if you wish * to use this function. Furthermore, note that this function takes * and returns only column-major concrete matrices. Future versions * of Scythe will provide a native C++ implementation of this * function with support for general matrix templates. * * \param A The matrix to decompose. * \param nu The number of left singular vectors to compute and return. Values less than zero are equivalent to min(\f$m\f$, \f$n\f$). * \param nv The number of right singular vectors to compute and return. Values less than zero are equivalent to min(\f$m\f$, \f$n\f$). * * \throw scythe_null_error (Level 1) * \throw scythe_convergence_error (Level 1) * \throw scythe_lapack_internal_error (Level 1) * * \see SVD * \see eigen(const Matrix<>& A, bool vectors) */ inline SVD svd (const Matrix<>& A, int nu = -1, int nv = -1) { SCYTHE_DEBUG_MSG("Using lapack/blas for eigen"); SCYTHE_CHECK_10(A.isNull(), scythe_null_error, "Matrix is NULL"); char* jobz; int m = (int) A.rows(); int n = (int) A.cols(); int mn = (int) std::min(A.rows(), A.cols()); Matrix<> U; Matrix<> V; if (nu < 0) nu = mn; if (nv < 0) nv = mn; if (nu <= mn && nv<= mn) { jobz = "S"; U = Matrix<>(m, mn, false); V = Matrix<>(mn, n, false); } else if (nu == 0 && nv == 0) { jobz = "N"; } else { jobz = "A"; U = Matrix<>(m, m, false); V = Matrix<>(n, n, false); } double* Uarray = U.getArray(); double* Varray = V.getArray(); int ldu = (int) U.rows(); int ldvt = (int) V.rows(); Matrix<> X = A; double* Xarray = X.getArray(); Matrix<> d(mn, 1, false); double* darray = d.getArray(); double tmp, *work; int lwork, info; int *iwork = new int[8 * mn]; // get optimal workspace lwork = -1; lapack::dgesdd_(jobz, &m, &n, Xarray, &m, darray, Uarray, &ldu, Varray, &ldvt, &tmp, &lwork, iwork, &info); SCYTHE_CHECK_10(info < 0, scythe_lapack_internal_error, "Internal error in LAPACK routine dgessd"); SCYTHE_CHECK_10(info > 0, scythe_convergence_error, "Did not converge"); lwork = (int) tmp; work = new double[lwork]; // Now for real lapack::dgesdd_(jobz, &m, &n, Xarray, &m, darray, Uarray, &ldu, Varray, &ldvt, work, &lwork, iwork, &info); SCYTHE_CHECK_10(info < 0, scythe_lapack_internal_error, "Internal error in LAPACK routine dgessd"); SCYTHE_CHECK_10(info > 0, scythe_convergence_error, "Did not converge"); delete[] work; if (nu < mn && nu > 0) U = U(0, 0, U.rows() - 1, (unsigned int) std::min(m, nu) - 1); if (nv < mn && nv > 0) V = V(0, 0, (unsigned int) std::min(n, nv) - 1, V.cols() - 1); SVD result; result.d = d; result.U = U; result.Vt = V; return result; } /*!\brief The result of an eigenvalue/vector decomposition. * * Objects of this type hold the results of the eigen() function. * That is the eigenvalues and, optionally, the eigenvectors of a * symmetric matrix of order \f$n\f$. The eigenvalues are stored in * ascending order in the member column vector \a values. The * vectors are stored in the \f$n \times n\f$ matrix \a vectors. * * \see eigen(const Matrix<>& A, bool vectors) */ struct Eigen { Matrix<> values; Matrix<> vectors; }; /*!\brief Calculates the eigenvalues and eigenvectors of a symmetric * matrix. * * This function returns the eigenvalues and, optionally, * eigenvectors of a symmetric matrix \a A of order \f$n\f$. It * returns an Eigen object containing the vector of values, in * ascending order, and, optionally, a matrix holding the vectors. * * \note This function requires BLAS/LAPACK functionality and is * only available on machines that provide these libraries. Make * sure you enable the SCYTHE_LAPACK preprocessor flag if you wish * to use this function. Furthermore, note that this function takes * and returns only column-major concrete matrices. Future versions * of Scythe will provide a native C++ implementation of this * function with support for general matrix templates. * * \param A The Matrix to be decomposed. * \param vectors This boolean value indicates whether or not to * return eigenvectors in addition to eigenvalues. It is set to true * by default. * * \throw scythe_null_error (Level 1) * \throw scythe_dimension_error (Level 1) * \throw scythe_lapack_internal_error (Level 1) * * \see Eigen * \see svd(const Matrix<>& A, int nu, int nv); */ inline Eigen eigen (const Matrix<>& A, bool vectors=true) { SCYTHE_DEBUG_MSG("Using lapack/blas for eigen"); SCYTHE_CHECK_10(! A.isSquare(), scythe_dimension_error, "Matrix not square"); SCYTHE_CHECK_10(A.isNull(), scythe_null_error, "Matrix is NULL"); // Should be symmetric but rounding errors make checking for this // difficult. // Make a copy of A Matrix<> AA = A; // Get a point to the internal array and set up some vars double* Aarray = AA.getArray(); // internal array points int order = (int) AA.rows(); // input matrix is order x order double dignored = 0; // we don't use this option int iignored = 0; // or this one double abstol = 0.0; // tolerance (default) int m; // output value Matrix<> result; // result matrix char getvecs[1]; // are we getting eigenvectors? if (vectors) { getvecs[0] = 'V'; result = Matrix<>(order, order + 1, false); } else { result = Matrix<>(order, 1, false); getvecs[0] = 'N'; } double* eigenvalues = result.getArray(); // pointer to result array int* isuppz = new int[2 * order]; // indices of nonzero eigvecs double tmp; // inital temporary value for getting work-space info int lwork, liwork, *iwork, itmp; // stuff for workspace double *work; // and more stuff for workspace int info = 0; // error code holder // get optimal size for work arrays lwork = -1; liwork = -1; lapack::dsyevr_(getvecs, "A", "L", &order, Aarray, &order, &dignored, &dignored, &iignored, &iignored, &abstol, &m, eigenvalues, eigenvalues + order, &order, isuppz, &tmp, &lwork, &itmp, &liwork, &info); SCYTHE_CHECK_10(info != 0, scythe_lapack_internal_error, "Internal error in LAPACK routine dsyevr"); lwork = (int) tmp; liwork = itmp; work = new double[lwork]; iwork = new int[liwork]; // do the actual operation lapack::dsyevr_(getvecs, "A", "L", &order, Aarray, &order, &dignored, &dignored, &iignored, &iignored, &abstol, &m, eigenvalues, eigenvalues + order, &order, isuppz, work, &lwork, iwork, &liwork, &info); SCYTHE_CHECK_10(info != 0, scythe_lapack_internal_error, "Internal error in LAPACK routine dsyevr"); delete[] isuppz; delete[] work; delete[] iwork; Eigen resobj; if (vectors) { resobj.values = result(_, 0); resobj.vectors = result(0, 1, result.rows() -1, result.cols() - 1); } else { resobj.values = result; } return resobj; } struct GeneralEigen { Matrix > values; Matrix<> vectors; }; inline GeneralEigen geneigen (const Matrix<>& A, bool vectors=true) { SCYTHE_CHECK_10 (! A.isSquare(), scythe_dimension_error, "Matrix not square"); SCYTHE_CHECK_10 (A.isNull(), scythe_null_error, "Matrix is NULL"); Matrix<> AA = A; // Copy A // Get a point to the internal array and set up some vars double* Aarray = AA.getArray(); // internal array points int order = (int) AA.rows(); // input matrix is order x order GeneralEigen result; int info, lwork; double *left, *right, *valreal, *valimag, *work, tmp; valreal = new double[order]; valimag = new double[order]; left = right = (double *) 0; char leftvecs[1], rightvecs[1]; leftvecs[0] = rightvecs[0] = 'N'; if (vectors) { rightvecs[0] = 'V'; result.vectors = Matrix<>(order, order, false); right = result.vectors.getArray(); } // Get working are size lwork = -1; lapack::dgeev_ (leftvecs, rightvecs, &order, Aarray, &order, valreal, valimag, left, &order, right, &order, &tmp, &lwork, &info); SCYTHE_CHECK_10(info != 0, scythe_lapack_internal_error, "Internal error in LAPACK routine dgeev"); lwork = (int) tmp; work = new double[lwork]; // Run for real lapack::dgeev_ (leftvecs, rightvecs, &order, Aarray, &order, valreal, valimag, left, &order, right, &order, work, &lwork, &info); SCYTHE_CHECK_10(info != 0, scythe_lapack_internal_error, "Internal error in LAPACK routine dgeev"); // Pack value into result result.values = Matrix > (order, 1, false); for (unsigned int i = 0; i < result.values.size(); ++i) result.values(i) = std::complex (valreal[i], valimag[i]); // Clean up delete[] valreal; delete[] valimag; delete[] work; return result; } #endif } // end namespace scythe #endif /* SCYTHE_IDE_H */ scythestat-1.0.3/scythestat/defs.h0000644000175000017500000002631311766135266014136 00000000000000/* * Scythe Statistical Library * Copyright (C) 2000-2002 Andrew D. Martin and Kevin M. Quinn; * 2002-present Andrew D. Martin, Kevin M. Quinn, and Daniel * Pemstein. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify * under the terms of the GNU General Public License as published by * Free Software Foundation; either version 2 of the License, or (at * your option) any later version. See the text files COPYING * and LICENSE, distributed with this source code, for further * information. * -------------------------------------------------------------------- * scythestat/defs.h */ /*! \file defs.h * \brief Global Scythe definitions. * * This file provides a variety of global definitions used throughout * the Scythe library. * * The majority of these definitions are used only within the library * itself. Those definitions that are part of the public interface * are documented. * */ /* Doxygen main page text */ /*! \mainpage Scythe Statistical Library: Application Programmers' Interface * * \section intro Introduction * * The Scythe Statistical Library is an open source C++ library for * statistical computation, written by Daniel Pemstein (University of * Mississippi), Kevin M. Quinn (University of California Berkeley), * and Andrew D. Martin (Washington University). It includes a suite * of matrix manipulation functions, a suite of pseudo-random number * generators, and a suite of numerical optimization routines. * Programs written using Scythe are generally much faster than those * written in commonly used interpreted languages, such as R and * MATLAB, and can be compiled on any system with the GNU GCC compiler * (and perhaps with other C++ compilers). One of the primary design * goals of the Scythe developers has been ease of use for non-expert * C++ programmers. We provide ease of use through three primary * mechanisms: (1) operator and function over-loading, (2) numerous * pre-fabricated utility functions, and (3) clear documentation and * example programs. Additionally, Scythe is quite flexible and * entirely extensible because the source code is available to all * users under the GNU General Public License. * * \section thisdoc About This Document * * This document is the application programmer's interface (API) to * Scythe. It provides documentation for every class, function, and * object in Scythe that is part of the library's public interface. * In addition, the sections below explain how to obtain, install, and * compile the library. * * \section obtain Obtaining Scythe * * The most recent version of Scythe is available for download at * http://scythe.wustl.edu. * * \section install Installation * * Scythe installs as a header-only C++ library. After uncompressing, * simply follow the instructions in the INSTALL file included with * Scythe to install the library. Alternatively, you may copy the * source files in scythestat and scythestat/rng into your project * directory and compile directly, using the SCYTHE_COMPILE_DIRECT * pre-processor flag. * * \section compile Compilation * * Scythe should work with the GNU GCC compiler, version 4.4.7 and * greater. Scythe has not been tested with other compilers. Scythe * provides a number of pre-processor flags. The * SCYTHE_COMPILE_DIRECT flag allows the user to compile Scythe sources * directly. The SCYTHE_VIEW_ASSIGNMENT_FLAG flag turns on R-style * recycling in Matrix::operator=() for view matrices. * * The SCYTHE_DEBUG flag controls the amount of error trapping in Scythe. * This level ranges from 0 (virtually no checking) to 3 (all * checking, including Matrix bounds checking, turned on). By * default, the level is set to 3. Reducing the error check level can * substantially improve performance. Here's an example of how to * compile a program with only basic error checking: * * \verbatim $ g++ myprog.cc -DSCYTHE_DEBUG=1 \endverbatim * * The SCYTHE_LAPACK flag enables LAPACK/BLAS support. You must have * the LAPACK and BLAS libraries installed on your system and compile * your program with the appropriate linker flags for this to work. * For example, on linux you can enable LAPACK/BLAS support like this: * * \verbatim $ g++ myprog.cc -DSCYTHE_LAPACK -llapack -lblas -pthread \endverbatim * * The SCYTHE_PTHREAD flag makes the library thread-safe, using the * POSIX Threads library. Users should pass this flag to the compiler * whenever they wish to run multi-threaded code that uses Scythe * matrices. Of course, this will only work on systems sporting the * pthread libraries. For example: * * \verbatim g++ myprog.cc -DSCYTHE_PTHREAD -pthread \endverbatim * * Please note that Scythe matrices are NOT thread-safe when the * library is compiled without this flag. * * Finally, the SCYTHE_RPACK flag activates some code that makes * Scythe play nicely with the R statistical programming environment. * R packages that use Scythe should always use this compilation flag, * and will generally include a line similar to * \verbatim PKG_CPPFLAGS = -DSCYTHE_COMPILE_DIRECT -DSCYTHE_RPACK \endverbatim * in the src/Makevars.in file within the package. * * \section copy Copyright * * Scythe Statistical Library Copyright (C) 2000-2002 Andrew D. Martin * and Kevin M. Quinn; 2002-2012 Andrew D. Martin, Kevin M. Quinn, * and Daniel Pemstein. All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify under the terms of the GNU General Public License as * published by Free Software Foundation; either version 3 of the * License, or (at your option) any later version. See the text files * COPYING and LICENSE, distributed with library's source code, for * further information. * * \section acknowledge Acknowledgments * * We gratefully acknowledge support from the United States National * Science Foundation (Grants SES-0350646 and SES-0350613), the * Department of Political Science, the Weidenbaum Center, and the * Center for Empirical Research in the Law at Washington University, * and the Department of Government and The Institute for Quantitative * Social Science at Harvard University. Neither the foundation, * Washington University, nor Harvard University bear any * responsibility for this software. * * We'd also like to thank the research assistants who have helped us * with Scythe: Matthew Fasman, Steve Haptonstahl, Kate Jensen, Laura * Keys, Kevin Rompala, Joe Sheehan, and Jean Yang. */ #ifndef SCYTHE_DEFS_H #define SCYTHE_DEFS_H /* In many functions returning matrices, we want to allow the user to * get a matrix of any style, but want to work with concretes inside * the function, for efficiency. This macro originally contained the * code: * * if (_STYLE_ == View) \ * return Matrix<_TYPE_,_ORDER_,View>(_MATRIX_); \ * else \ * return _MATRIX_; * * to convert to View before return if necessary. Of course, this is * completely redundant, since the copy constructor gets called on * return anyway, so the body of the macro was replaced with a simple * return. If we change our minds down the road about how to handle * these returns, code changes will be centered on this macro. */ #define SCYTHE_VIEW_RETURN(_TYPE_, _ORDER_, _STYLE_, _MATRIX_) \ return _MATRIX_; /* Some macros to do bounds checking for iterator accesses. The first * two are only called by the [] operator in the random access * iterator. The third macro handles everything for checks on simple * current iterator location accesses. */ #define SCYTHE_ITER_CHECK_POINTER_BOUNDS(POINTER) \ { \ SCYTHE_CHECK_30(POINTER >= start_ + size_ || POINTER < start_, \ scythe_bounds_error, "Iterator access (offset " \ << offset_ << ") out of matrix bounds") \ } #define SCYTHE_ITER_CHECK_OFFSET_BOUNDS(OFFSET) \ { \ SCYTHE_CHECK_30(OFFSET >= size_, scythe_bounds_error, \ "Iterator access (offset " << offset_ << ") out of matrix bounds")\ } #define SCYTHE_ITER_CHECK_BOUNDS() \ { \ if (M_STYLE != Concrete || M_ORDER != ORDER) { \ SCYTHE_ITER_CHECK_OFFSET_BOUNDS(offset_); \ } else { \ SCYTHE_ITER_CHECK_POINTER_BOUNDS(pos_); \ } \ } /*! \namespace scythe * \brief The Scythe library namespace. * * All Scythe library declarations are defined within the scythe * namespace. This prevents name clashing with other libraries' * members or with declarations in users' program code. */ namespace scythe { /*! * \brief Matrix order enumerator. * * Matrix templates may be either column-major or row-major ordered * and this enumerator is used to differentiate between the two * types. * * The enumerator provides two values: Concrete and View. * * \see Matrix */ enum matrix_order { Col, Row }; /*! * \brief Matrix style enumerator. * * Matrix templates may be either concrete matrices or views and * this enumerator is used to differentiate between the two types. * * Concrete matrices provide direct access to an underlying array of * matrix data, while views offer a more general interface to data * arrays, with potentially many views referencing the same * underlying data structure. * * The enum provides two values: Col and Row. * * \see Matrix */ enum matrix_style { Concrete, View }; /*! * \brief A convenient marker for vector submatrix access. * Passing an all_elements object to a two-argument Matrix submatrix * method allows the caller to access a full vector submatrix. We * further define an instance of all_elements named "_" in the * scythe namespace to allow users to easily reference entire * vectors within matrices. * * \see Matrix::operator()(const all_elements, uint) * \see Matrix::operator()(const all_elements, uint) const * \see Matrix::operator()(uint, const all_elements) * \see Matrix::operator()(uint, const all_elements) const * */ struct all_elements { } const _ = {}; // A little helper method to see if more col-order or row-order. // Tie breaks towards col. template bool maj_col() { if ((o1 == Col && o2 == Col) || (o1 == Col && o3 == Col) || (o2 == Col && o3 == Col)) return true; return false; } template bool maj_col() { if ((o1 == Col && o2 == Col) || (o1 == Col && o3 == Col) || (o1 == Col && o4 == Col) || (o2 == Col && o3 == Col) || (o2 == Col && o4 == Col) || (o3 == Col && o4 == Col)) return true; return false; } } // end namespace scythe #endif /* SCYTHE_ERROR_H */ scythestat-1.0.3/scythestat/matrix_random_access_iterator.h0000644000175000017500000004362311763743200021304 00000000000000/* * Scythe Statistical Library Copyright (C) 2000-2002 Andrew D. Martin * and Kevin M. Quinn; 2002-present Andrew D. Martin, Kevin M. Quinn, * and Daniel Pemstein. All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify under the terms of the GNU General Public License as * published by Free Software Foundation; either version 2 of the * License, or (at your option) any later version. See the text files * COPYING and LICENSE, distributed with this source code, for further * information. * -------------------------------------------------------------------- * scythestat/matrix_random_access_iterator.h * * Random access iterators for the matrix class. * */ /*! \file matrix_random_access_iterator.h * \brief Definitions of STL-compliant random access iterators for * the Matrix class. * * Contains definitions of const_matrix_random_access_iterator, * matrix_random_access_iterator, and related operators. See a * Standard Template Library reference, such as Josuttis (1999), for a * full description of the capabilities of random access iterators. * * These iterators are templated on the type, order and style of the * Matrix they iterate over and their own order, which need not match * the iterated-over matrix. Same-order iteration over concrete * matrices is extremely fast. Cross-grain concrete and/or view * iteration is slower. */ #ifndef SCYTHE_MATRIX_RANDOM_ACCESS_ITERATOR_H #define SCYTHE_MATRIX_RANDOM_ACCESS_ITERATOR_H #include #ifdef SCYTHE_COMPILE_DIRECT #include "defs.h" #include "error.h" #include "matrix.h" #else #include "scythestat/defs.h" #include "scythestat/error.h" #include "scythestat/matrix.h" #endif /* The const_matrix_iterator and matrix_iterator classes are * essentially identical, except for the return types of the *, ->, * and [] operators. matrix_iterator extends const_matrix_iterator, * overriding most of its members. */ /* TODO Current setup uses template argument based branches to * handle views and cross-grained orderings differently than simple * in-order concrete matrices. The work for this gets done at * compile time, but we end with a few unused instance variables in * the concrete case. It might be better to specialize the entire * class, although this will lead to a lot of code duplication. We * should bench the difference down the road and see if it is worth * the maintenance hassle. * * At the moment this is looking like it won't be worth it. * Iterator-based operations on concretes provide comparable * performance to element-access based routines in previous versions * of the library, indicating little performance penalty. */ namespace scythe { /* convenience typedefs */ namespace { // local to this file typedef unsigned int uint; } /* forward declaration of the matrix class */ template class Matrix; /*! \brief An STL-compliant const random access iterator for Matrix. * * Provides random access iteration over const Matrix objects. See * Josuttis (1999), or some other STL reference, for a full * description of the random access iterator interface. * * \see Matrix * \see matrix_random_access_iterator * \see const_matrix_forward_iterator * \see matrix_forward_iterator * \see const_matrix_bidirectional_iterator * \see matrix_bidirectional_iterator */ template class const_matrix_random_access_iterator : public std::iterator { public: /**** TYPEDEFS ***/ typedef const_matrix_random_access_iterator self; /* These are a little formal, but useful */ typedef typename std::iterator_traits::value_type value_type; typedef typename std::iterator_traits::iterator_category iterator_category; typedef typename std::iterator_traits::difference_type difference_type; typedef typename std::iterator_traits::pointer pointer; typedef typename std::iterator_traits::reference reference; /**** CONSTRUCTORS ****/ /* Default constructor */ const_matrix_random_access_iterator () {} /* Standard constructor */ const_matrix_random_access_iterator ( const Matrix &M) : start_ (M.getArray()) { SCYTHE_CHECK_30 (start_ == 0, scythe_null_error, "Requesting iterator to NULL matrix"); pos_ = start_; /* The basic story is: when M_STYLE == Concrete and ORDER == * M_ORDER, we only need pos_ and start_ and iteration will be * as fast as possible. All other types of iteration need * more variables to keep track of things and are slower. */ if (M_STYLE != Concrete || M_ORDER != ORDER) { offset_ = 0; if (ORDER == Col) { lead_length_ = M.rows(); lead_inc_ = M.rowstride(); trail_inc_ = M.colstride(); } else { lead_length_ = M.cols(); lead_inc_ = M.colstride(); trail_inc_ = M.rowstride(); } jump_ = trail_inc_ + (1 - lead_length_) * lead_inc_; } #if SCYTHE_DEBUG > 2 size_ = M.size(); #endif } /* Copy constructor */ const_matrix_random_access_iterator (const self &mi) : start_ (mi.start_), pos_ (mi.pos_) { if (M_STYLE != Concrete || M_ORDER != ORDER) { offset_ = mi.offset_; lead_length_ = mi.lead_length_; lead_inc_ = mi.lead_inc_; trail_inc_ = mi.trail_inc_; jump_ = mi.jump_; } #if SCYTHE_DEBUG > 2 size_ = mi.size_; #endif } /**** FORWARD ITERATOR FACILITIES ****/ inline self& operator= (const self& mi) { start_ = mi.start_; pos_ = mi.pos_; if (M_STYLE != Concrete || M_ORDER != ORDER) { offset_ = mi.offset_; lead_length_ = mi.lead_length_; lead_inc_ = mi.lead_inc_; trail_inc_ = mi.trail_inc_; jump_ = mi.jump_; } #if SCYTHE_DEBUG > 2 size_ = mi.size_; #endif return *this; } inline const reference operator* () const { SCYTHE_ITER_CHECK_BOUNDS(); return *pos_; } inline const pointer operator-> () const { SCYTHE_ITER_CHECK_BOUNDS(); return pos_; } inline self& operator++ () { if (M_STYLE == Concrete && ORDER == M_ORDER) ++pos_; else if (++offset_ % lead_length_ == 0) pos_ += jump_; else pos_ += lead_inc_; return *this; } inline self operator++ (int) { self tmp = *this; ++(*this); return tmp; } /* == is only defined for iterators of the same template type * that point to the same matrix. Behavior for any other * comparison is undefined. * * Note that we have to be careful about iterator comparisons * when working with views and cross-grain iterators. * Specifically, we always have to rely on the offset value. * Obviously, with <> checks pos_ can jump all over the place in * cross-grain iterators, but also end iterators point to the * value after the last in the matrix. In some cases, the * equation in += and -= will actually put pos_ inside the * matrix (often in an early position) in this case. */ inline bool operator== (const self& x) const { if (M_STYLE == Concrete && ORDER == M_ORDER) { return pos_ == x.pos_; } else { return offset_ == x.offset_; } } /* Again, != is only officially defined for iterators over the * same matrix although the test will be trivially true for * matrices that don't view the same data, by implementation. */ inline bool operator!= (const self &x) const { return !(*this == x); } /**** BIDIRECTIONAL ITERATOR FACILITIES ****/ inline self& operator-- () { if (M_STYLE == Concrete && ORDER == M_ORDER) --pos_; else if (offset_-- % lead_length_ == 0) pos_ -= jump_; else pos_ -= lead_inc_; return *this; } inline self operator-- (int) { self tmp = *this; --(*this); return tmp; } /**** RANDOM ACCESS ITERATOR FACILITIES ****/ inline const reference operator[] (difference_type n) const { if (M_STYLE == Concrete && ORDER == M_ORDER) { SCYTHE_ITER_CHECK_OFFSET_BOUNDS(start_ + n); return *(start_ + n); } else { uint trailing = n / lead_length_; uint leading = n % lead_length_; T_type* place = start_ + leading * lead_inc_ + trailing * trail_inc_; SCYTHE_ITER_CHECK_POINTER_BOUNDS(place); return *place; } } inline self& operator+= (difference_type n) { if (M_STYLE == Concrete && ORDER == M_ORDER) { pos_ += n; } else { offset_ += n; uint trailing = offset_ / lead_length_; uint leading = offset_ % lead_length_; pos_ = start_ + leading * lead_inc_ + trailing * trail_inc_; } return *this; } inline self& operator-= (difference_type n) { if (M_STYLE == Concrete && ORDER == M_ORDER) { pos_ -= n; } else { offset_ -= n; uint trailing = offset_ / lead_length_; uint leading = offset_ % lead_length_; pos_ = start_ + leading * lead_inc_ + trailing * trail_inc_; } return *this; } /* + and - difference operators are outside the class */ inline difference_type operator- (const self& x) const { if (M_STYLE == Concrete && ORDER == M_ORDER) { return pos_ - x.pos_; } else { return offset_ - x.offset_; } } inline difference_type operator< (const self& x) const { if (M_STYLE == Concrete && ORDER == M_ORDER) { return pos_ < x.pos_; } else { return offset_ < x.offset_; } } inline difference_type operator> (const self& x) const { if (M_STYLE == Concrete && ORDER == M_ORDER) { return pos_ > x.pos_; } else { return offset_ > x.offset_; } } inline difference_type operator<= (const self& x) const { if (M_STYLE == Concrete && ORDER == M_ORDER) { return pos_ <= x.pos_; } else { return offset_ <= x.offset_; } } inline difference_type operator>= (const self& x) const { if (M_STYLE == Concrete && ORDER == M_ORDER) { return pos_ >= x.pos_; } else { return offset_ >= x.offset_; } } protected: /**** INSTANCE VARIABLES ****/ T_type* start_; // pointer to beginning of data array T_type* pos_; // pointer to current position in array uint offset_; // Logical offset into matrix // TODO Some of these can probably be uints int lead_length_; // Logical length of leading dimension int lead_inc_; // Memory distance between vectors in ldim int trail_inc_; // Memory distance between vectors in tdim int jump_; // Memory distance between end of one ldim vector and // begin of next // Size variable for range checking #if SCYTHE_DEBUG > 2 uint size_; // Logical matrix size #endif }; /*! \brief An STL-compliant random access iterator for Matrix. * * Provides random access iteration over Matrix objects. See * Josuttis (1999), or some other STL reference, for a full * description of the random access iterator interface. * * \see Matrix * \see const_matrix_random_access_iterator * \see const_matrix_forward_iterator * \see matrix_forward_iterator * \see const_matrix_bidirectional_iterator * \see matrix_bidirectional_iterator */ template class matrix_random_access_iterator : public const_matrix_random_access_iterator { /**** TYPEDEFS ***/ typedef matrix_random_access_iterator self; typedef const_matrix_random_access_iterator Base; public: /* These are a little formal, but useful */ typedef typename std::iterator_traits::value_type value_type; typedef typename std::iterator_traits::iterator_category iterator_category; typedef typename std::iterator_traits::difference_type difference_type; typedef typename std::iterator_traits::pointer pointer; typedef typename std::iterator_traits::reference reference; /**** CONSTRUCTORS ****/ /* Default constructor */ matrix_random_access_iterator () : Base () {} /* Standard constructor */ matrix_random_access_iterator (const Matrix &M) : Base(M) {} /* Copy constructor */ matrix_random_access_iterator (const self &mi) : Base (mi) {} /**** FORWARD ITERATOR FACILITIES ****/ /* We have to override a lot of these to get return values * right.*/ inline self& operator= (const self& mi) { start_ = mi.start_; pos_ = mi.pos_; if (M_STYLE != Concrete || M_ORDER != ORDER) { offset_ = mi.offset_; lead_length_ = mi.lead_length_; lead_inc_ = mi.lead_inc_; trail_inc_ = mi.trail_inc_; jump_ = mi.jump_; } #if SCYTHE_DEBUG > 2 size_ = mi.size_; #endif return *this; } inline reference operator* () const { SCYTHE_ITER_CHECK_BOUNDS(); return *pos_; } inline pointer operator-> () const { SCYTHE_ITER_CHECK_BOUNDS(); return pos_; } inline self& operator++ () { Base::operator++(); return *this; } inline self operator++ (int) { self tmp = *this; ++(*this); return tmp; } /**** BIDIRECTIONAL ITERATOR FACILITIES ****/ inline self& operator-- () { Base::operator--(); return *this; } inline self operator-- (int) { self tmp = *this; --(*this); return tmp; } /**** RANDOM ACCESS ITERATOR FACILITIES ****/ inline reference operator[] (difference_type n) const { if (M_STYLE == Concrete && ORDER == M_ORDER) { SCYTHE_ITER_CHECK_POINTER_BOUNDS(start_ + n); return *(start_ + n); } else { uint trailing = n / lead_length_; uint leading = n % lead_length_; T_type* place = start_ + leading * lead_inc_ + trailing * trail_inc_; SCYTHE_ITER_CHECK_POINTER_BOUNDS(place); return *place; } } inline self& operator+= (difference_type n) { Base::operator+=(n); return *this; } inline self& operator-= (difference_type n) { Base::operator-= (n); return *this; } /* + and - difference_type operators are outside the class */ private: /* Get handles to base members. It boggles the mind */ using Base::start_; using Base::pos_; using Base::offset_; using Base::lead_length_; using Base::lead_inc_; using Base::trail_inc_; using Base::jump_; #if SCYTHE_DEBUG > 2 using Base::size_; #endif }; template inline const_matrix_random_access_iterator operator+ (const_matrix_random_access_iterator x, int n) { x += n; return x; } template inline const_matrix_random_access_iterator operator+ (int n, const_matrix_random_access_iterator x) { x += n; return x; } template inline const_matrix_random_access_iterator operator- (const_matrix_random_access_iterator x, int n) { x -= n; return x; } template inline matrix_random_access_iterator operator+ (matrix_random_access_iterator x, int n) { x += n; return x; } template inline matrix_random_access_iterator operator+ (int n, matrix_random_access_iterator x) { x += n; return x; } template inline matrix_random_access_iterator operator- (matrix_random_access_iterator x, int n) { x -= n; return x; } } // namespace scythe #endif /* SCYTHE_MATRIX_ITERATOR_H */ scythestat-1.0.3/scythestat/error.h0000644000175000017500000005136711764452462014353 00000000000000/* * Scythe Statistical Library Copyright (C) 2000-2002 Andrew D. Martin * and Kevin M. Quinn; 2002-present Andrew D. Martin, Kevin M. Quinn, * and Daniel Pemstein. All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify under the terms of the GNU General Public License as * published by Free Software Foundation; either version 2 of the * License, or (at your option) any later version. See the text files * COPYING and LICENSE, distributed with this source code, for further * information. * -------------------------------------------------------------------- * scythestat/error.h */ /*! \file error.h * * \brief Definitions of Scythe exception classes. * * This file contains the class definitions for * scythe::scythe_exception and its children. These exception classes * describe all of the error conditions generated by Scythe library * routines. * * Furthermore, error.h contains a series of macro definitions that * regulate the inclusion of the library's error checking code in * compiled code. These macros are controlled by the compiler flag * SCYTHE_DEBUG and define four levels of scythe debug * info, SCYTHE_DEBUG = 0, 1, 2, or 3. The library uses these macros to * specify the debug level of thrown exceptions. If we are at level * three, all throws are expanded into actual code, at level 2 only * SCYTHE_THROW_10 AND SCYTHE_THROW_20 calls are expanded, and so on. * Scythe developers should balance exception importance and * efficiency costs when making exception level choices. For example, * bounds checking in matrices is done at level three primarily * because the added branch results in high performance penalties and * out-of-bounds errors shouldn't occur in well-written code, while * conformance checks in matrix multiplication are level 1 because the * checks result in little overhead relative to the cost of matrix * multiplication and conformation errors are easy to introduce by * accident. At level 0, the library performs virtually no error * checking. * * While the various SCYTHE_THROW, SCYTHE_CHECK, and SCYTHE_WARN * macros will only typically be used by library developers, users * should make extensive use the tiered error reporting in Scythe by * setting the compiler flag SCYTHE_DEBUG. If not explicitly set by * the user, the SCYTHE_DEBUG level is automatically set to 3. */ #ifndef SCYTHE_ERROR_H #define SCYTHE_ERROR_H #include #include #include #include #include #include #ifdef SCYTHE_RPACK #include // needed to use Rprintf() #include // needed to allow user interrupts #endif /*! @cond */ #ifdef SCYTHE_DEBUG_LIB #define SCYTHE_DEBUG_MSG(MSG) \ { std::cout << "SCYTHE_DEBUG_LIB: " << MSG << std::endl; } #else #define SCYTHE_DEBUG_MSG(MSG) #endif /*! @endcond */ #define SCYTHE_THROW(EXCEP,MSG) \ { \ std::stringstream _SCYTHE_DEBUG_ss; \ _SCYTHE_DEBUG_ss << MSG; \ throw EXCEP(__FILE__, __func__, __LINE__, \ _SCYTHE_DEBUG_ss.str()); \ } #define SCYTHE_CHECK(CHECK,EXCEP,MSG) \ { \ if (CHECK) \ SCYTHE_THROW(EXCEP,MSG) \ } #define SCYTHE_WARN_RPACK(MSG) \ { \ std::stringstream _SCYTHE_WARN_ss; \ _SCYTHE_WARN_ss << "WARNING in " << __FILE__ << ", " \ << __func__ << ", " << __LINE__ << ": " \ << MSG << "\n"; \ Rprintf(_SCYTHE_WARN_ss.str().c_str()); \ } #define SCYTHE_WARN_STD(MSG) \ std::cerr << "WARNING in " << __FILE__ << ", " \ << __func__ << ", " << __LINE__ << ": " \ << MSG << "\n"; #ifdef SCYTHE_RPACK #define SCYTHE_WARN SCYTHE_WARN_RPACK #else #define SCYTHE_WARN SCYTHE_WARN_STD #endif #define SCYTHE_CHECK_WARN(CHECK,MSG) \ { \ if (CHECK) \ SCYTHE_WARN(MSG) \ } /*! @cond */ #ifndef SCYTHE_DEBUG #define SCYTHE_DEBUG 3 #endif /*! @endcond */ #if SCYTHE_DEBUG > 0 #define SCYTHE_CHECK_10(CHECK,EXCEP,MSG) SCYTHE_CHECK(CHECK,EXCEP,MSG) #else #define SCYTHE_CHECK_10(CHECK, EXCEP, MSG) #endif #if SCYTHE_DEBUG > 1 #define SCYTHE_CHECK_20(CHECK,EXCEP,MSG) SCYTHE_CHECK(CHECK,EXCEP,MSG) #else #define SCYTHE_CHECK_20(CHECK, EXCEP, MSG) #endif #if SCYTHE_DEBUG > 2 #define SCYTHE_CHECK_30(CHECK,EXCEP,MSG) SCYTHE_CHECK(CHECK,EXCEP,MSG) #else #define SCYTHE_CHECK_30(CHECK, EXCEP, MSG) #endif #if SCYTHE_DEBUG > 0 #define SCYTHE_THROW_10(EXCEP,MSG) SCYTHE_THROW(EXCEP,MSG) #else #define SCYTHE_THROW_10(EXCEP,MSG) #endif #if SCYTHE_DEBUG > 1 #define SCYTHE_THROW_20(EXCEP,MSG) SCYTHE_THROW(EXCEP,MSG) #else #define SCYTHE_THROW_20(EXCEP,MSG) #endif #if SCYTHE_DEBUG > 2 #define SCYTHE_THROW_30(EXCEP,MSG) SCYTHE_THROW(EXCEP,MSG) #else #define SCYTHE_THROW_30(EXCEP,MSG) #endif namespace scythe { /* Forward declaration for serr */ class scythe_exception; /**** This file-local variable holds the output of the last * scythe_exception constructed. ****/ #ifdef __MINGW32__ static scythe_exception *serr; #else namespace { scythe_exception *serr; } #endif /**** A replacement for the default terminate handler. This outputs * the string held in serr before calling abort, thereby notifying * the user of why the program crashed. ****/ inline void scythe_terminate (); /**** The scythe exception abstract base class ****/ /*! * \brief The Scythe exception abstract base class. * * The is the base class in Scythe's error handling class tree. * This class extends std::exception and provides fields for * information about the exception, including where the exception * occurred in the library and a message describing the error. */ class scythe_exception:public std::exception { public: scythe_exception (const std::string & head, const std::string & file, const std::string & function, const unsigned int &line, const std::string & message = "", const bool & halt = false) throw () : exception (), head_ (head), file_ (file), function_ (function), line_ (line), message_ (message), call_files_ (), call_funcs_ (), call_lines_ () { std::ostringstream os; os << head_ << " in " << file_ << ", " << function_ << ", " << line_ << ": " << message_ << "!\n\n"; serr = this; std::set_terminate (scythe_terminate); if (halt) { #ifdef SCYTHE_RPACK error("Aborting Scythe C++ execution"); #else std::terminate (); #endif } } scythe_exception (const scythe_exception & e) throw () : exception (), head_ (e.head_), file_ (e.file_), function_ (e.function_), line_ (e.line_), message_ (e.message_), call_files_ (e.call_files_), call_funcs_ (e.call_funcs_), call_lines_ (e.call_lines_) { } scythe_exception & operator= (const scythe_exception & e) throw () { head_ = e.head_; file_ = e.file_; function_ = e.function_; line_ = e.line_; message_ = e.message_; return *this; } virtual ~ scythe_exception () throw () { } /* This function is only called from scythe_terminate, and only * once, so this memory leak is not an issue. We can't just return * os.str().c_str() because that is a dangling pointer after the * function returns... * TODO: Deal with memory leak issue that might affect R packages */ virtual const char *what () const throw () { std::ostringstream os; for (int i = call_files_.size() - 1; i > -1; ++i) { os << "Called from " << call_files_[i] << ", " << call_funcs_[i] << ", " << call_lines_[i] << std::endl; } os << head_ << " in " << file_ << ", " << function_ << ", " << line_ << ": " << message_ << "!"; char *retval = new char[os.str().length()]; std::strcpy(retval, os.str().c_str()); return retval; } virtual std::string message () const throw () { return message_; } virtual void add_caller (const std::string &file, const std::string &function, const unsigned int &line) throw () { /* This if allows one to catch and rethrow an error in the same * function w/out messing things up. Nice to keep try-catch * blocks to a minimum */ if (file != file_ && function != function_) { call_files_.push_back(file); call_funcs_.push_back(function); call_lines_.push_back(line); } } private: std::string head_; std::string file_; std::string function_; unsigned int line_; std::string message_; std::vector call_files_; std::vector call_funcs_; std::vector call_lines_; }; /**** Exception class types, added as needed ****/ /*! * \brief Memory allocation error. * * Library members throw this exception in response to insufficient * memory conditions, such as when one attempts to create a Matrix * object that is bigger than available memory. */ class scythe_alloc_error:public scythe_exception { public: scythe_alloc_error (const std::string & file, const std::string & function, const unsigned int &line, const std::string & message = "", const bool & halt = false) throw () : scythe_exception ("SCYTHE_ALLOCATION_ERROR", file, function, line, message, halt) { } }; /*! * \brief Invalid function argument. * * Library members throw this exception when callers pass incorrect * arguments to a function, such as when one calls the factorial * method with an argument less than 0. */ class scythe_invalid_arg:public scythe_exception { public: scythe_invalid_arg (const std::string & file, const std::string & function, const unsigned int &line, const std::string & message = "", const bool & halt = false) throw () : scythe_exception ("SCYTHE_INVALID ARGUMENT", file, function, line, message, halt) { } }; /*! * \brief File i/o error. * * Library members throw this exception when errors occur during * file reading, writing, or creation, such as when one passes an * invalid file name to the Matrix class's save method. */ class scythe_file_error:public scythe_exception { public: scythe_file_error(const std::string & file, const std::string & function, const unsigned int &line, const std::string & message = "", const bool & halt = false) throw () : scythe_exception ("SCYTHE FILE ERROR", file, function, line, message, halt) { } }; /*! \brief Matrix conformation error. * * Library members throw this exception when a caller passes * non-conforming matrices (matrices of incompatible dimensions) to * a routine, such as when one attempt two row vectors. */ class scythe_conformation_error:public scythe_exception { public: scythe_conformation_error(const std::string & file, const std::string & function, const unsigned int &line, const std::string & message = "", const bool & halt = false) throw () : scythe_exception ("SCYTHE CONFORMATION ERROR", file, function, line, message, halt) { } }; /*! \brief Matrix dimension error. * * Library members throw this exception when a caller passes a * Matrix of the wrong size or shape to a routine. For example, * trying to take the Cholesky decomposition of a non-square Matrix * causes this error. */ class scythe_dimension_error:public scythe_exception { public: scythe_dimension_error (const std::string & file, const std::string & function, const unsigned int &line, const std::string & message = "", const bool & halt = false) throw () : scythe_exception ("SCYTHE DIMENSION ERROR", file, function, line, message, halt) { } }; /*! \brief Null Matrix error. * * Library members throw this exception when a caller passes a null * Matrix to a routine when it expects a non-null argument. For * example, taking the inverse of a null Matrix is impossible, * resulting in this exception. */ class scythe_null_error:public scythe_exception { public: scythe_null_error(const std::string & file, const std::string & function, const unsigned int &line, const std::string & message = "", const bool & halt = false) throw () : scythe_exception ("SCYTHE NULL ERROR", file, function, line, message, halt) { } }; /*! \brief Matrix type error. * * Library members throw this exception when a caller passes a * Matrix that does not satisfy some required property to a routine. * For example, Cholesky decomposition is designed to work on * positive definite matrices; trying to perform Cholesky * decomposition on a Matrix that does not satisfy this requirement * causes this exception. */ class scythe_type_error:public scythe_exception { public: scythe_type_error(const std::string & file, const std::string & function, const unsigned int &line, const std::string & message = "", const bool & halt = false) throw () : scythe_exception ("SCYTHE TYPE ERROR", file, function, line, message, halt) { } }; /*! \brief Element out of bounds error. * * Library members throw this exception when a caller attempts to * access an element outside the bounds of a data structure, such as * when one tries to access the 1000th element of a 200-element * Matrix. */ class scythe_bounds_error:public scythe_exception { public: scythe_bounds_error(const std::string & file, const std::string & function, const unsigned int &line, const std::string & message = "", const bool & halt = false) throw () : scythe_exception ("SCYTHE BOUNDS ERROR", file, function, line, message, halt) { } }; /*! \brief Numerical convergence error. * * Library members throw this exception when a numerical algorithm * fails to converge to a stable value. For example, the BFGS * optimization routine throws this exception when it cannot locate * the minimum of a function to a given tolerance. */ class scythe_convergence_error:public scythe_exception { public: scythe_convergence_error (const std::string & file, const std::string & function, const unsigned int &line, const std::string & message = "", const bool & halt = false) throw () : scythe_exception ("SCYTHE CONVERGENCE ERROR", file, function, line, message, halt) { } }; /*! \brief Numerical underflow or overflow error. * * Library members throw this exception when the result of a * calculation, assignment, or other operation is to small or large * for the data type holding the value. For example, passing * certain values to the gammafn function can result in underflow or * overflow conditions in the resulting calculations. */ class scythe_range_error:public scythe_exception { public: scythe_range_error (const std::string & file, const std::string & function, const unsigned int &line, const std::string & message = "", const bool & halt = false) throw () : scythe_exception ("SCYTHE RANGE ERROR", file, function, line, message, halt) { } }; /*! \brief Numerical precision error. * * Library members throw this exception when a routine cannot * complete a computation effectively and will sacrifice reasonable * precision as a consequence. For example, passing a value too * close to a negative integer to the gammafn function renders the * function incapable of returning an accurate result and thus * generates this exception. */ class scythe_precision_error:public scythe_exception { public: scythe_precision_error (const std::string & file, const std::string & function, const unsigned int &line, const std::string & message = "", const bool & halt = false) throw () : scythe_exception ("SCYTHE PRECISION ERROR", file, function, line, message, halt) { } }; /*! \brief Random number seed error. * * Library members throw this exception when a random number * generator is provided with an illegitimate starting seed value. * For example, the lecuyer class requires seeds within a certain * range to operate properly and will throw this exception when * seeded with a number outside of that range. */ class scythe_randseed_error:public scythe_exception { public: scythe_randseed_error(const std::string & file, const std::string & function, const unsigned int &line, const std::string & message = "", const bool & halt = false) throw () : scythe_exception ("SCYTHE RANDOM SEED ERROR", file, function, line, message, halt) { } }; /*! \brief Matrix style error. * * Library members throw this exception when they are asked to * operate on a Matrix of the incorrect style. Some routines * require specifically a concrete Matrix or view to work correctly. * For example, only views may reference other matrices; invoking * the reference function on a concrete Matrix will generate this * exception. */ class scythe_style_error:public scythe_exception { public: scythe_style_error(const std::string& file, const std::string& function, const unsigned int& line, const std::string& message = "", const bool& halt = false) throw () : scythe_exception("SCYTHE STYLE ERROR", file, function, line, message, halt) {} }; /*! \brief LAPACK Internal Error * * Library members throw this exception when an underlying LAPACK or * BLAS routine indicates that an internal error has occurred. * */ class scythe_lapack_internal_error:public scythe_exception { public: scythe_lapack_internal_error(const std::string& file, const std::string& function, const unsigned int& line, const std::string& message = "", const bool& halt = false) throw () : scythe_exception("SCYTHE LAPACK/BLAS INTERNAL ERROR", file, function, line, message, halt) {} }; /*! \brief Unexpected call to default error. * * This error should not occur. If it occurs in your code, please * contact the Scythe developers to report the problem. * */ class scythe_unexpected_default_error:public scythe_exception { public: scythe_unexpected_default_error(const std::string& file, const std::string& function, const unsigned int& line, const std::string& message = "", const bool& halt = false) throw () : scythe_exception("SCYTHE UNEXPECTED DEFAULT ERROR", file, function, line, message, halt) {} }; // The definition of our terminate handler described above inline void scythe_terminate () { #ifdef SCYTHE_RPACK Rprintf(serr->what()); error("Aborting Scythe C++ execution"); #else std::cerr << serr->what() << std::endl; std::cerr << std::endl; abort (); #endif } } // end namspace SCYTHE #endif /* SCYTHE_ERROR_H */ scythestat-1.0.3/scythestat/smath.h0000644000175000017500000006524211550656101014320 00000000000000/* * Scythe Statistical Library Copyright (C) 2000-2002 Andrew D. Martin * and Kevin M. Quinn; 2002-present Andrew D. Martin, Kevin M. Quinn, * and Daniel Pemstein. All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify under the terms of the GNU General Public License as * published by Free Software Foundation; either version 2 of the * License, or (at your option) any later version. See the text files * COPYING and LICENSE, distributed with this source code, for further * information. * -------------------------------------------------------------------- * scythestat/smath.h * */ /*! * \file smath.h * \brief Definitions for functions that perform common mathematical * operations on every element of a Matrix. * * \note As is the case throughout the library, we provide both * general and default template definitions of the Matrix-returning * functions in this file, explicitly providing documentation for only * the general template versions. As is also often the case, Doxygen * does not always correctly add the default template definition to * the function list below; there is always a default template * definition available for every function. * */ #ifndef SCYTHE_MATH_H #define SCYTHE_MATH_H #ifdef SCYTHE_COMPILE_DIRECT #include "matrix.h" #include "algorithm.h" #include "error.h" #else #include "scythestat/matrix.h" #include "scythestat/algorithm.h" #include "scythestat/error.h" #endif #include #include #include namespace scythe { namespace { typedef unsigned int uint; } /* Almost every function in this file follows one of the two patterns * described by these macros. The first macro handles single-argument * functions. The second handles two-matrix-argument functions (or * scalar-matrix, matrix-scalar. The second macro also permits * cross-type operations (these are limited only by the capabilities * of the underlying functions). */ #define SCYTHE_MATH_OP(NAME, OP) \ template \ Matrix \ NAME (const Matrix& A) \ { \ Matrix res(A.rows(), A.cols(), false); \ std::transform(A.begin_f(), A.end_f(), res.begin_f(), OP); \ return res; \ } \ \ template \ Matrix \ NAME (const Matrix& A) \ { \ return NAME(A); \ } #define SCYTHE_MATH_OP_2ARG(NAME, OP) \ template \ Matrix \ NAME (const Matrix& A, const Matrix& B) \ { \ SCYTHE_CHECK_10 (A.size() != 1 && B.size() != 1 && \ A.size() != B.size(), scythe_conformation_error, \ "Matrices with dimensions (" << A.rows() \ << ", " << A.cols() \ << ") and (" << B.rows() << ", " << B.cols() \ << ") are not conformable"); \ \ Matrix res; \ \ if (A.size() == 1) { \ res.resize2Match(B); \ std::transform(B.template begin_f(), B.template end_f(),\ res.begin_f(), std::bind1st(OP, A(0))); \ } else if (B.size() == 1) { \ res.resize2Match(A); \ std::transform(A.template begin_f(), A.template end_f(),\ res.begin_f(), std::bind2nd(OP, B(0))); \ } else { \ res.resize2Match(A); \ std::transform(A.template begin_f(), A.template end_f(),\ B.template begin_f(), res.begin_f(), OP); \ } \ \ return res; \ } \ \ template \ Matrix \ NAME (const Matrix& A, const Matrix& B) \ { \ return NAME(A, B); \ } \ \ template \ Matrix \ NAME (const Matrix& A, S b) \ { \ return NAME(A, Matrix(b)); \ } \ \ template \ Matrix \ NAME (const Matrix& A, S b) \ { \ return NAME(A, Matrix(b)); \ } \ \ template \ Matrix \ NAME (T a, const Matrix& B) \ { \ return NAME(Matrix(a), B); \ } \ \ template \ Matrix \ NAME (T a, const Matrix& B) \ { \ return NAME(Matrix(a), B); \ } /* calc the inverse cosine of each element of a Matrix */ /*! * \brief Calculate the inverse cosine of each element of a Matrix * * This function calculates the inverse cosine of each element in a Matrix * * \param A The matrix whose inverse cosines are of interest. * * \see tan() * \see tanh() * \see sin() * \see sinh() * \see cos() * \see cosh() * \see acosh() * \see asin() * \see asinh() * \see atan() * \see atanh() * \see atan2() */ SCYTHE_MATH_OP(acos, ::acos) /* calc the inverse hyperbolic cosine of each element of a Matrix */ /*! * \brief Calculate the inverse hyperbolic cosine of each element of a Matrix * * This function calculates the inverse hyperbolic cosine of each element * in a Matrix * * \param A The matrix whose inverse hyperbolic cosines are of interest. * * \see tan() * \see tanh() * \see sin() * \see sinh() * \see cos() * \see cosh() * \see acos() * \see asin() * \see asinh() * \see atan() * \see atanh() * \see atan2() */ SCYTHE_MATH_OP(acosh, ::acosh) /* calc the inverse sine of each element of a Matrix */ /*! * \brief Calculate the inverse sine of each element of a Matrix * * This function calculates the inverse sine of each element * in a Matrix * * \param A The matrix whose inverse sines are of interest. * * \see tan() * \see tanh() * \see sin() * \see sinh() * \see cos() * \see cosh() * \see acos() * \see acosh() * \see asinh() * \see atan() * \see atanh() * \see atan2() */ SCYTHE_MATH_OP(asin, ::asin) /* calc the inverse hyperbolic sine of each element of a Matrix */ /*! * \brief Calculate the inverse hyperbolic sine of each element of a Matrix * * This function calculates the inverse hyperbolic sine of each element * in a Matrix * * \param A The matrix whose inverse hyperbolic sines are of interest. * * \see tan() * \see tanh() * \see sin() * \see sinh() * \see cos() * \see cosh() * \see acos() * \see acosh() * \see asin() * \see atan() * \see atanh() * \see atan2() */ SCYTHE_MATH_OP(asinh, ::asinh) /* calc the inverse tangent of each element of a Matrix */ /*! * \brief Calculate the inverse tangent of each element of a Matrix * * This function calculates the inverse tangent of each element * in a Matrix * * \param A The matrix whose inverse tangents are of interest. * * \see tan() * \see tanh() * \see sin() * \see sinh() * \see cos() * \see cosh() * \see acos() * \see acosh() * \see asin() * \see asin() * \see atanh() * \see atan2() */ SCYTHE_MATH_OP(atan, ::atan) /* calc the inverse hyperbolic tangent of each element of a Matrix */ /*! * \brief Calculate the inverse hyperbolic tangent of each element of a Matrix * * This function calculates the inverse hyperbolic tangent of each element * in a Matrix * * \param A The matrix whose inverse hyperbolic tangents are of interest. * * \see tan() * \see tanh() * \see sin() * \see sinh() * \see cos() * \see cosh() * \see acos() * \see acosh() * \see asin() * \see asinh() * \see atan() * \see atan2() */ SCYTHE_MATH_OP(atanh, ::atanh) /* calc the angle whose tangent is y/x */ /*! * \brief Calculate the angle whose tangent is y/x * * This function calculates the angle whose tangent is y/x, given two * matrices A and B (where y is the ith element of A, and x is the jth element * of matrix B). * * \param A The matrix of y values * \param B The matrix of x values * * \see tan() * \see tanh() * \see sin() * \see sinh() * \see cos() * \see cosh() * \see acos() * \see acosh() * \see asin() * \see asinh() * \see atan() * \see atanh() */ SCYTHE_MATH_OP_2ARG(atan2, std::ptr_fun(::atan2)) /* calc the cube root of each element of a Matrix */ /*! * \brief Calculate the cube root of each element of a Matrix * * This function calculates the cube root of each element * in a Matrix * * \param A The matrix whose cube roots are of interest. * * \see sqrt() */ SCYTHE_MATH_OP(cbrt, ::cbrt) /* calc the ceil of each element of a Matrix */ /*! * \brief Calculate the ceiling of each element of a Matrix * * This function calculates the ceiling of each element * in a Matrix * * \param A The matrix whose ceilings are of interest. * * \see floor() */ SCYTHE_MATH_OP(ceil, ::ceil) /* create a matrix containing the absval of the first input and the * sign of the second */ /*! * \brief Create a matrix containing the absolute value of the first input * and the sign of the second input * * This function creates a matrix containing the absolute value of the first * input, a matrix called A, and the sign of the second input, matrix B. * * \param A The matrix whose absolute values will comprise the resultant matrix. * \param B The matrix whose signs will comprise the resultant matrix */ SCYTHE_MATH_OP_2ARG(copysign, std::ptr_fun(::copysign)) /* calc the cosine of each element of a Matrix */ /*! * \brief Calculate the cosine of each element of a Matrix * * This function calculates the cosine of each element in a Matrix * * \param A The matrix whose cosines are of interest. * * \see tan() * \see tanh() * \see sin() * \see sinh() * \see cosh() * \see acos() * \see acosh() * \see asin() * \see asinh() * \see atan() * \see atanh() * \see atan2() */ SCYTHE_MATH_OP(cos, ::cos) /* calc the hyperbolic cosine of each element of a Matrix */ /*! * \brief Calculate the hyperbolic cosine of each element of a Matrix * * This function calculates the hyperbolic cosine of each element in a Matrix * * \param A The matrix whose hyperbolic cosines are of interest. * * \see tan() * \see tanh() * \see sin() * \see sinh() * \see cos() * \see acos() * \see acosh() * \see asin() * \see asinh() * \see atan() * \see atanh() * \see atan2() */ SCYTHE_MATH_OP(cosh, ::cosh) /* calc the error function of each element of a Matrix */ /*! * \brief Calculate the error function of each element of a Matrix * * This function calculates the error function of each element in a Matrix * * \param A The matrix whose error functions are of interest. * * \see erfc() */ SCYTHE_MATH_OP(erf, ::erf) /* calc the complementary error function of each element of a Matrix */ /*! * \brief Calculate the complementary error function of each element of a Matrix * * This function calculates the complemenatry error function of each * element in a Matrix * * \param A The matrix whose complementary error functions are of interest. * * \see erf() */ SCYTHE_MATH_OP(erfc, ::erfc) /* calc the vaue e^x of each element of a Matrix */ /*! * \brief Calculate the value e^x for each element of a Matrix * * This function calculates the value e^x for each element of a matrix, where * x is the ith element of the matrix A * * \param A The matrix whose elements are to be exponentiated. * * \see expm1() */ SCYTHE_MATH_OP(exp, ::exp) /* calc the exponent - 1 of each element of a Matrix */ /*! * \brief Calculate the value e^(x-1) for each element of a Matrix * * This function calculates the value e^(x-1) for each element of a matrix, where * x is the ith element of the matrix A * * \param A The matrix whose elements are to be exponentiated. * * \see exp() */ SCYTHE_MATH_OP(expm1, ::expm1) /* calc the absval of each element of a Matrix */ /*! * \brief Calculate the absolute value of each element of a Matrix * * This function calculates the absolute value of each element in a Matrix * * \param A The matrix whose absolute values are to be taken. */ SCYTHE_MATH_OP(fabs, ::fabs) /* calc the floor of each element of a Matrix */ /*! * \brief Calculate the floor of each element of a Matrix * * This function calculates the floor of each element * in a Matrix * * \param A The matrix whose floors are of interest. * * \see ceil() */ SCYTHE_MATH_OP(floor, ::floor) /* calc the remainder of the division of each matrix element */ /*! * \brief Calculate the remainder of the division of each matrix element * * This function calculates the remainder when the elements of Matrix A are * divided by the elements of Matrix B. * * \param A The matrix to serve as dividend * \param B the matrix to serve as divisor */ SCYTHE_MATH_OP_2ARG(fmod, std::ptr_fun(::fmod)) /* calc the fractional val of input and return exponents in int * matrix reference */ /*! */ template Matrix frexp (const Matrix& A, Matrix& ex) { SCYTHE_CHECK_10(A.size() != ex.size(), scythe_conformation_error, "The input matrix sizes do not match"); Matrix res(A.rows(), A.cols()); typename Matrix::const_forward_iterator it; typename Matrix::forward_iterator rit = res.begin_f(); typename Matrix::const_forward_iterator it2 = ex.begin_f(); for (it = A.begin_f(); it != A.end_f(); ++it) { *rit = ::frexp(*it, &(*it2)); ++it2; ++rit; } return res; } template Matrix frexp (Matrix& A, Matrix& ex) { return frexp(A,ex); } /* calc the euclidean distance between the two inputs */ /*! * \brief Calculate the euclidean distance between two inputs * * This function calculates the euclidean distance between the elements of Matrix * A and the elements of Matrix B. * * \param A Input matrix * \param B Input matrix */ SCYTHE_MATH_OP_2ARG(hypot, std::ptr_fun(::hypot)) /* return (int) logb */ SCYTHE_MATH_OP(ilogb, ::ilogb) /* compute the bessel func of the first kind of the order 0 */ /*! * \brief Compute the Bessel function of the first kind of the order 0 * * This function computes the Bessel function of the first kind of order 0 * for each element in the input matrix, A. * * \param A Matrix for which the Bessel function is of interest * * \see j1() * \see jn() * \see y0() * \see y1() * \see yn() */ SCYTHE_MATH_OP(j0, ::j0) /* compute the bessel func of the first kind of the order 1 */ /*! * \brief Compute the Bessel function of the first kind of the order 1 * * This function computes the Bessel function of the first kind of order 1 * for each element in the input matrix, A. * * \param A Matrix for which the Bessel function is of interest * * \see j0() * \see jn() * \see y0() * \see y1() * \see yn() */ SCYTHE_MATH_OP(j1, ::j1) /* compute the bessel func of the first kind of the order n * TODO: This definition causes the compiler to issue some warnings. * Fix */ /*! * \brief Compute the Bessel function of the first kind of the order n * * This function computes the Bessel function of the first kind of order n * for each element in the input matrix, A. * * \param n Order of the Bessel function * \param A Matrix for which the Bessel function is of interest * * \see j0() * \see j1() * \see y0() * \see y1() * \see yn() */ SCYTHE_MATH_OP_2ARG(jn, std::ptr_fun(::jn)) /* calc x * 2 ^ex */ /*! * \brief Compute x * 2^ex * * This function computes the value of x * 2^ex, where x is the ith element of * the input matrix A, and ex is the desired value of the exponent. * * \param A Matrix whose elements are to be multiplied * \param ex Matrix of powers to which 2 will be raised. */ SCYTHE_MATH_OP_2ARG(ldexp, std::ptr_fun(::ldexp)) /* compute the natural log of the absval of gamma function */ /*! * \brief Compute the natural log of the absolute value of the gamma function * * This function computes the absolute value of the Gamma Function, evaluated at * each element of the input matrix A. * * \param A Matrix whose elements will serve as inputs for the Gamma Function * * \see log() */ SCYTHE_MATH_OP(lgamma, ::lgamma) /* calc the natural log of each element of a Matrix */ /*! * \brief Compute the natural log of each element of a Matrix * * This function computes the natural log of each element in a matrix, A. * * \param A Matrix whose natural logs are of interest * * \see log10() * \see log1p() * \see logb() */ SCYTHE_MATH_OP(log, ::log) /* calc the base-10 log of each element of a Matrix */ /*! * \brief Compute the log base 10 of each element of a Matrix * * This function computes the log base 10 of each element in a matrix, A. * * \param A Matrix whose logs are of interest * * \see log() * \see log1p() * \see logb() */ SCYTHE_MATH_OP(log10, ::log10) /* calc the natural log of 1 + each element of a Matrix */ /*! * \brief Compute the natural log of 1 + each element of a Matrix * * This function computes the natural log of 1 + each element of a Matrix. * * \param A Matrix whose logs are of interest * * \see log() * \see log10() * \see logb() */ SCYTHE_MATH_OP(log1p, ::log1p) /* calc the logb of each element of a Matrix */ /*! * \brief Compute the logb each element of a Matrix * * This function computes the log base b of each element of a Matrix. * * \param A Matrix whose logs are of interest * * \see log() * \see log10() * \see log1p() */ SCYTHE_MATH_OP(logb, ::logb) /* x = frac + i, return matrix of frac and place i in 2nd matrix */ template Matrix modf (const Matrix& A, Matrix& ipart) { SCYTHE_CHECK_10(A.size() != ipart.size(), scythe_conformation_error, "The input matrix sizes do not match"); Matrix res(A.rows(), A.cols()); typename Matrix::const_forward_iterator it; typename Matrix::forward_iterator rit = res.begin_f(); typename Matrix::const_forward_iterator it2 = ipart.begin_f(); for (it = A.begin_f(); it != A.end_f(); ++it) { *rit = ::modf(*it, &(*it2)); ++it2; ++rit; } return res; } template Matrix modf (Matrix& A, Matrix& ipart) { return modf(A,ipart); } /* calc x^ex of each element of a Matrix */ /*! * \brief Compute x^ex for each element of a matrix * * This function computes x^ex, where x is the ith element of the matrix A, * and ex is the desired exponent. * * \param A Matrix to be exponentiated * \param ex Desired exponent */ SCYTHE_MATH_OP_2ARG(pow, std::ptr_fun(::pow)) /* calc rem == x - n * y */ SCYTHE_MATH_OP_2ARG(remainder, std::ptr_fun(::remainder)) /* return x rounded to nearest int */ /*! * \brief Return x rounded to the nearest integer * * This function returns x, where x is the ith element of the Matrix A, * rounded to the nearest integer. * * \param A Matrix whose elements are to be rounded */ SCYTHE_MATH_OP(rint, ::rint) /* returns x * FLT_RADIX^ex */ SCYTHE_MATH_OP_2ARG(scalbn, std::ptr_fun(::scalbn)) /* calc the sine of x */ /*! * \brief Calculate the sine of each element of a Matrix * * This function calculates the sine of each element in a Matrix * * \param A The matrix whose sines are of interest. * * \see tan() * \see tanh() * \see sinh() * \see cos() * \see cosh() * \see acos() * \see acosh() * \see asin() * \see asinh() * \see atan() * \see atanh() * \see atan2() */ SCYTHE_MATH_OP(sin, ::sin) /* calc the hyperbolic sine of x */ /*! * \brief Calculate the hyperbolic sine of each element of a Matrix * * This function calculates the hyperbolic sine of each element in a Matrix * * \param A The matrix whose hyperbolic sines are of interest. * * \see tan() * \see tanh() * \see sin() * \see cos() * \see cosh() * \see acos() * \see acosh() * \see asin() * \see asinh() * \see atan() * \see atanh() * \see atan2() */ SCYTHE_MATH_OP(sinh, ::sinh) /* calc the sqrt of x */ /*! * \brief Calculate the square root of each element in a matrix * * This function calculates the square root of each element in a Matrix * * \param A The matrix whose roots are of interest. * * \see cbrt() */ SCYTHE_MATH_OP(sqrt, ::sqrt) /* calc the tangent of x */ /*! * \brief Calculate the tangent of each element of a Matrix * * This function calculates the tangent of each element in a Matrix * * \param A The matrix whose tangents are of interest. * * \see sinh() * \see tanh() * \see sin() * \see cos() * \see cosh() * \see acos() * \see acosh() * \see asin() * \see asinh() * \see atan() * \see atanh() * \see atan2() */ SCYTHE_MATH_OP(tan, ::tan) /* calc the hyperbolic tangent of x */ /*! * \brief Calculate the hyperbolic tangent of each element of a Matrix * * This function calculates the hyperbolic tangent of each element in a Matrix * * \param A The matrix whose hyperbolic tangents are of interest. * * \see sinh() * \see tan() * \see sin() * \see cos() * \see cosh() * \see acos() * \see acosh() * \see asin() * \see asinh() * \see atan() * \see atanh() * \see atan2() */ SCYTHE_MATH_OP(tanh, ::tanh) /* bessel function of the second kind of order 0*/ /*! * \brief Compute the Bessel function of the second kind of order 0 * * This function computes the Bessel function of the second kind of order 0 * for each element in the input matrix, A. * * \param A Matrix for which the Bessel function is of interest * * \see j0() * \see j1() * \see jn() * \see y1() * \see yn() */ SCYTHE_MATH_OP(y0, ::y0) /* bessel function of the second kind of order 1*/ /*! * \brief Compute the Bessel function of the second kind of order 1 * * This function computes the Bessel function of the second kind of order 1 * for each element in the input matrix, A. * * \param A Matrix for which the Bessel function is of interest * * \see j0() * \see j1() * \see jn() * \see y0() * \see yn() */ SCYTHE_MATH_OP(y1, ::y1) /* bessel function of the second kind of order n * TODO: This definition causes the compiler to issue some warnings. * Fix */ /*! * \brief Compute the Bessel function of the second kind of order n * * This function computes the Bessel function of the second kind of order n * for each element in the input matrix, A. * * \param n Order of the Bessel function * \param A Matrix for which the Bessel function is of interest * * \see j0() * \see j1() * \see jn() * \see y0() * \see y1() */ SCYTHE_MATH_OP_2ARG(yn, std::ptr_fun(::yn)) } // end namespace scythe #endif /* SCYTHE_MATH_H */ scythestat-1.0.3/scythestat/distributions.h0000644000175000017500000024176111766136051016116 00000000000000/* * Scythe Statistical Library Copyright (C) 2000-2002 Andrew D. Martin * and Kevin M. Quinn; 2002-present Andrew D. Martin, Kevin M. Quinn, * and Daniel Pemstein. All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify under the terms of the GNU General Public License as * published by Free Software Foundation; either version 2 of the * License, or (at your option) any later version. See the text files * COPYING and LICENSE, distributed with this source code, for further * information. * -------------------------------------------------------------------- * scythestat/distributions.h * */ /*! \file distributions.h * * \brief Definitions for probability density functions * (PDFs), cumulative distribution functions (CDFs), and some common * functions (gamma, beta, etc). * * This file provides functions that evaluate the PDFs and CDFs of a * number of probability distributions. In addition, it includes * definitions for another of related functions, such as the gamma * and beta functions. * * The various distribution functions in this file operate on both * scalar quantiles and matrices of quantiles and the * definitions of both forms of these functions appear below. We * provide explicit documentation only for the scalar versions of the * these functions and describe the Matrix versions in the scalar * calls' documents. Much like the operators in matrix.h, we * implement these overloaded versions of the distribution functions * in terms of both generalized and default templates to allow for * explicit control over the template type of the returned Matrix. * */ /* TODO: Figure out how to get doxygen to stop listing erroneous * variables at the end of the doc for this file. They stem from it * misreading the nested macro calls used to generate matrix procs. */ /* TODO: Full R-style versions of these function including arbitrary * recycling of matrix arguments. This is going to have to wait for * variadic templates to be doable without a complete mess. There is * currently a variadic patch available for g++, perhaps we can add a * SCYTHE_VARIADIC flag and include these as option until they become * part of the standard in 2009. Something to come back to after 1.0. */ #ifndef SCYTHE_DISTRIBUTIONS_H #define SCYTHE_DISTRIBUTIONS_H #include #include #include #include #include #include #ifdef HAVE_IEEEFP_H #include #endif #ifdef SCYTHE_COMPILE_DIRECT #include "matrix.h" #include "ide.h" #include "error.h" #else #include "scythestat/matrix.h" #include "scythestat/ide.h" #include "scythestat/error.h" #endif /* Fill in some defs from R that aren't in math.h */ #ifndef M_PI #define M_PI 3.141592653589793238462643383280 #endif #define M_LN_SQRT_2PI 0.918938533204672741780329736406 #define M_LN_SQRT_PId2 0.225791352644727432363097614947 #define M_1_SQRT_2PI 0.39894228040143267793994605993 #define M_2PI 6.28318530717958647692528676655 #define M_SQRT_32 5.656854249492380195206754896838 #ifndef HAVE_TRUNC /*! @cond */ inline double trunc(double x) throw () { if (x >= 0) return std::floor(x); else return std::ceil(x); } /*! @endcond */ #endif /* Many random number generators, pdfs, cdfs, and functions (gamma, * etc) in this file are based on code from the R Project, version * 1.6.0-1.7.1. This code is available under the terms of the GNU * GPL. Original copyright: * * Copyright (C) 1998 Ross Ihaka * Copyright (C) 2000-2002 The R Development Core Team * Copyright (C) 2003 The R Foundation */ namespace scythe { /*! @cond */ /* Forward declarations */ double gammafn (double); double lngammafn (double); double lnbetafn (double, double); double pgamma (double, double, double); double dgamma(double, double, double); double pnorm (double, double, double); /*! @endcond */ /******************** * Helper Functions * ********************/ namespace { /* Evaluate a Chebysheve series at a given point */ double chebyshev_eval (double x, const double *a, int n) { SCYTHE_CHECK_10(n < 1 || n > 1000, scythe_invalid_arg, "n not on [1, 1000]"); SCYTHE_CHECK_10(x < -1.1 || x > 1.1, scythe_invalid_arg, "x not on [-1.1, 1.1]"); double b0, b1, b2; b0 = b1 = b2 = 0; double twox = x * 2; for (int i = 1; i <= n; ++i) { b2 = b1; b1 = b0; b0 = twox * b1 - b2 + a[n - i]; } return (b0 - b2) * 0.5; } /* Computes the log gamma correction factor for x >= 10 */ double lngammacor(double x) { const double algmcs[15] = { +.1666389480451863247205729650822e+0, -.1384948176067563840732986059135e-4, +.9810825646924729426157171547487e-8, -.1809129475572494194263306266719e-10, +.6221098041892605227126015543416e-13, }; SCYTHE_CHECK_10(x < 10, scythe_invalid_arg, "This function requires x >= 10"); SCYTHE_CHECK_10(x >= 3.745194030963158e306, scythe_range_error, "Underflow"); if (x < 94906265.62425156) { double tmp = 10 / x; return chebyshev_eval(tmp * tmp * 2 - 1, algmcs, 5) / x; } return 1 / (x * 12); } /* Evaluates the "deviance part" */ double bd0(double x, double np) { if(std::fabs(x - np) < 0.1 * (x + np)) { double v = (x - np) / (x + np); double s = (x - np) * v; double ej = 2 * x * v; v = v * v; for (int j = 1; ; j++) { ej *= v; double s1 = s + ej / ((j << 1) + 1); if (s1 == s) return s1; s = s1; } } return x * std::log(x / np) + np - x; } /* Computes the log of the error term in Stirling's formula */ double stirlerr(double n) { #define S0 0.083333333333333333333 /* 1/12 */ #define S1 0.00277777777777777777778 /* 1/360 */ #define S2 0.00079365079365079365079365 /* 1/1260 */ #define S3 0.000595238095238095238095238 /* 1/1680 */ #define S4 0.0008417508417508417508417508/* 1/1188 */ /* error for 0, 0.5, 1.0, 1.5, ..., 14.5, 15.0 */ const double sferr_halves[31] = { 0.0, /* n=0 - wrong, place holder only */ 0.1534264097200273452913848, /* 0.5 */ 0.0810614667953272582196702, /* 1.0 */ 0.0548141210519176538961390, /* 1.5 */ 0.0413406959554092940938221, /* 2.0 */ 0.03316287351993628748511048, /* 2.5 */ 0.02767792568499833914878929, /* 3.0 */ 0.02374616365629749597132920, /* 3.5 */ 0.02079067210376509311152277, /* 4.0 */ 0.01848845053267318523077934, /* 4.5 */ 0.01664469118982119216319487, /* 5.0 */ 0.01513497322191737887351255, /* 5.5 */ 0.01387612882307074799874573, /* 6.0 */ 0.01281046524292022692424986, /* 6.5 */ 0.01189670994589177009505572, /* 7.0 */ 0.01110455975820691732662991, /* 7.5 */ 0.010411265261972096497478567, /* 8.0 */ 0.009799416126158803298389475, /* 8.5 */ 0.009255462182712732917728637, /* 9.0 */ 0.008768700134139385462952823, /* 9.5 */ 0.008330563433362871256469318, /* 10.0 */ 0.007934114564314020547248100, /* 10.5 */ 0.007573675487951840794972024, /* 11.0 */ 0.007244554301320383179543912, /* 11.5 */ 0.006942840107209529865664152, /* 12.0 */ 0.006665247032707682442354394, /* 12.5 */ 0.006408994188004207068439631, /* 13.0 */ 0.006171712263039457647532867, /* 13.5 */ 0.005951370112758847735624416, /* 14.0 */ 0.005746216513010115682023589, /* 14.5 */ 0.005554733551962801371038690 /* 15.0 */ }; double nn; if (n <= 15.0) { nn = n + n; if (nn == (int)nn) return(sferr_halves[(int)nn]); return (scythe::lngammafn(n + 1.) - (n + 0.5) * std::log(n) + n - std::log(std::sqrt(2 * M_PI))); } nn = n*n; if (n > 500) return((S0 - S1 / nn) / n); if (n > 80) return((S0 - (S1 - S2 / nn) / nn) / n); if (n > 35) return((S0 - (S1 - (S2 - S3 / nn) / nn) / nn) / n); /* 15 < n <= 35 : */ return((S0 - (S1 - (S2 - (S3 - S4 / nn) / nn) / nn) / nn) / n); #undef S1 #undef S2 #undef S3 #undef S4 } /* Helper for dpois and dgamma */ double dpois_raw (double x, double lambda) { if (lambda == 0) return ( (x == 0) ? 1.0 : 0.0); if (x == 0) return std::exp(-lambda); if (x < 0) return 0.0; return std::exp(-stirlerr(x) - bd0(x, lambda)) / std::sqrt(2 * M_PI * x); } /* helper for pbeta */ double pbeta_raw(double x, double pin, double qin) { double ans, c, finsum, p, ps, p1, q, term, xb, xi, y; int n, i, ib, swap_tail; const double eps = .5 * DBL_EPSILON; const double sml = DBL_MIN; const double lneps = std::log(eps); const double lnsml = std::log(eps); if (pin / (pin + qin) < x) { swap_tail = 1; y = 1 - x; p = qin; q = pin; } else { swap_tail=0; y = x; p = pin; q = qin; } if ((p + q) * y / (p + 1) < eps) { ans = 0; xb = p * std::log(std::max(y,sml)) - std::log(p) - lnbetafn(p,q); if (xb > lnsml && y != 0) ans = std::exp(xb); if (swap_tail) ans = 1-ans; } else { ps = q - std::floor(q); if (ps == 0) ps = 1; xb = p * std::log(y) - lnbetafn(ps, p) - std::log(p); ans = 0; if (xb >= lnsml) { ans = std::exp(xb); term = ans * p; if (ps != 1) { n = (int)std::max(lneps/std::log(y), 4.0); for(i = 1; i <= n; i++){ xi = i; term *= (xi-ps)*y/xi; ans += term/(p+xi); } } } if (q > 1) { xb = p * std::log(y) + q * std::log(1 - y) - lnbetafn(p, q) - std::log(q); ib = (int) std::max(xb / lnsml, 0.0); term = std::exp(xb - ib * lnsml); c = 1 / (1 - y); p1 = q * c / (p + q - 1); finsum = 0; n = (int) q; if(q == n) n--; for (i = 1; i <= n; i++) { if(p1 <= 1 && term / eps <= finsum) break; xi = i; term = (q -xi + 1) * c * term / (p + q - xi); if (term > 1) { ib--; term *= sml; } if (ib == 0) finsum += term; } ans += finsum; } if(swap_tail) ans = 1-ans; ans = std::max(std::min(ans,1.),0.); } return ans; } /* Helper for dbinom */ double dbinom_raw (double x, double n, double p, double q) { double f, lc; if (p == 0) return((x == 0) ? 1.0 : 0.0); if (q == 0) return((x == n) ? 1.0 : 0.0); if (x == 0) { if(n == 0) return 1.0; lc = (p < 0.1) ? -bd0(n, n * q) - n * p : n * std::log(q); return(std::exp(lc)); } if (x == n) { lc = (q < 0.1) ? -bd0(n,n * p) - n * q : n * std::log(p); return(std::exp(lc)); } if (x < 0 || x > n) return 0.0; lc = stirlerr(n) - stirlerr(x) - stirlerr(n-x) - bd0(x,n*p) - bd0(n - x, n * q); f = (M_2PI * x * (n-x)) / n; return (std::exp(lc) / std::sqrt(f)); } /* The normal probability density function implementation. */ #define SIXTEN 16 #define do_del(X) \ xsq = trunc(X * SIXTEN) / SIXTEN; \ del = (X - xsq) * (X + xsq); \ if(log_p) { \ *cum = (-xsq * xsq * 0.5) + (-del * 0.5) + std::log(temp); \ if((lower && x > 0.) || (upper && x <= 0.)) \ *ccum = ::log1p(-std::exp(-xsq * xsq * 0.5) * \ std::exp(-del * 0.5) * temp); \ } \ else { \ *cum = std::exp(-xsq * xsq * 0.5) * std::exp(-del * 0.5) * temp; \ *ccum = 1.0 - *cum; \ } #define swap_tail \ if (x > 0.) {/* swap ccum <--> cum */ \ temp = *cum; if(lower) *cum = *ccum; *ccum = temp; \ } void pnorm_both(double x, double *cum, double *ccum, int i_tail, bool log_p) { const double a[5] = { 2.2352520354606839287, 161.02823106855587881, 1067.6894854603709582, 18154.981253343561249, 0.065682337918207449113 }; const double b[4] = { 47.20258190468824187, 976.09855173777669322, 10260.932208618978205, 45507.789335026729956 }; const double c[9] = { 0.39894151208813466764, 8.8831497943883759412, 93.506656132177855979, 597.27027639480026226, 2494.5375852903726711, 6848.1904505362823326, 11602.651437647350124, 9842.7148383839780218, 1.0765576773720192317e-8 }; const double d[8] = { 22.266688044328115691, 235.38790178262499861, 1519.377599407554805, 6485.558298266760755, 18615.571640885098091, 34900.952721145977266, 38912.003286093271411, 19685.429676859990727 }; const double p[6] = { 0.21589853405795699, 0.1274011611602473639, 0.022235277870649807, 0.001421619193227893466, 2.9112874951168792e-5, 0.02307344176494017303 }; const double q[5] = { 1.28426009614491121, 0.468238212480865118, 0.0659881378689285515, 0.00378239633202758244, 7.29751555083966205e-5 }; double xden, xnum, temp, del, eps, xsq, y; int i, lower, upper; /* Consider changing these : */ eps = DBL_EPSILON * 0.5; /* i_tail in {0,1,2} =^= {lower, upper, both} */ lower = i_tail != 1; upper = i_tail != 0; y = std::fabs(x); if (y <= 0.67448975) { /* qnorm(3/4) = .6744.... -- earlier had 0.66291 */ if (y > eps) { xsq = x * x; xnum = a[4] * xsq; xden = xsq; for (i = 0; i < 3; ++i) { xnum = (xnum + a[i]) * xsq; xden = (xden + b[i]) * xsq; } } else xnum = xden = 0.0; temp = x * (xnum + a[3]) / (xden + b[3]); if(lower) *cum = 0.5 + temp; if(upper) *ccum = 0.5 - temp; if(log_p) { if(lower) *cum = std::log(*cum); if(upper) *ccum = std::log(*ccum); } } else if (y <= M_SQRT_32) { /* Evaluate pnorm for 0.674.. = qnorm(3/4) < |x| <= sqrt(32) * ~= 5.657 */ xnum = c[8] * y; xden = y; for (i = 0; i < 7; ++i) { xnum = (xnum + c[i]) * y; xden = (xden + d[i]) * y; } temp = (xnum + c[7]) / (xden + d[7]); do_del(y); swap_tail; } else if (log_p || (lower && -37.5193 < x && x < 8.2924) || (upper && -8.2929 < x && x < 37.5193) ) { /* Evaluate pnorm for x in (-37.5, -5.657) union (5.657, 37.5) */ xsq = 1.0 / (x * x); xnum = p[5] * xsq; xden = xsq; for (i = 0; i < 4; ++i) { xnum = (xnum + p[i]) * xsq; xden = (xden + q[i]) * xsq; } temp = xsq * (xnum + p[4]) / (xden + q[4]); temp = (M_1_SQRT_2PI - temp) / y; do_del(x); swap_tail; } else { if (x > 0) { *cum = 1.; *ccum = 0.; } else { *cum = 0.; *ccum = 1.; } SCYTHE_THROW_10(scythe_convergence_error, "Did not converge"); } return; } #undef SIXTEN #undef do_del #undef swap_tail /* The standard normal distribution function */ double pnorm1 (double x, bool lower_tail, bool log_p) { SCYTHE_CHECK_10(! finite(x), scythe_invalid_arg, "Quantile x is inifinte (+/-Inf) or NaN"); double p, cp; pnorm_both(x, &p, &cp, (lower_tail ? 0 : 1), log_p); return (lower_tail ? p : cp); } } // anonymous namespace /************* * Functions * *************/ /* The gamma function */ /*! \brief The gamma function. * * Computes the gamma function, evaluated at \a x. * * \param x The value to compute gamma at. * * \see lngammafn(double x) * \see pgamma(double x, double shape, double scale) * \see dgamma(double x, double shape, double scale) * \see rng::rgamma(double shape, double scale) * * \throw scythe_range_error (Level 1) * \throw scythe_precision_error (Level 1) */ inline double gammafn (double x) { const double gamcs[22] = { +.8571195590989331421920062399942e-2, +.4415381324841006757191315771652e-2, +.5685043681599363378632664588789e-1, -.4219835396418560501012500186624e-2, +.1326808181212460220584006796352e-2, -.1893024529798880432523947023886e-3, +.3606925327441245256578082217225e-4, -.6056761904460864218485548290365e-5, +.1055829546302283344731823509093e-5, -.1811967365542384048291855891166e-6, +.3117724964715322277790254593169e-7, -.5354219639019687140874081024347e-8, +.9193275519859588946887786825940e-9, -.1577941280288339761767423273953e-9, +.2707980622934954543266540433089e-10, -.4646818653825730144081661058933e-11, +.7973350192007419656460767175359e-12, -.1368078209830916025799499172309e-12, +.2347319486563800657233471771688e-13, -.4027432614949066932766570534699e-14, +.6910051747372100912138336975257e-15, -.1185584500221992907052387126192e-15, }; double y = std::fabs(x); if (y <= 10) { /* Compute gamma(x) for -10 <= x <= 10 * Reduce the interval and find gamma(1 + y) for 0 <= y < 1 * first of all. */ int n = (int) x; if (x < 0) --n; y = x - n;/* n = floor(x) ==> y in [ 0, 1 ) */ --n; double value = chebyshev_eval(y * 2 - 1, gamcs, 22) + .9375; if (n == 0) return value;/* x = 1.dddd = 1+y */ if (n < 0) { /* compute gamma(x) for -10 <= x < 1 */ /* If the argument is exactly zero or a negative integer */ /* then return NaN. */ SCYTHE_CHECK_10(x == 0 || (x < 0 && x == n + 2), scythe_range_error, "x is 0 or a negative integer"); /* The answer is less than half precision */ /* because x too near a negative integer. */ SCYTHE_CHECK_10(x < -0.5 && std::fabs(x - (int)(x - 0.5) / x) < 67108864.0, scythe_precision_error, "Answer < 1/2 precision because x is too near" << " a negative integer"); /* The argument is so close to 0 that the result * * would overflow. */ SCYTHE_CHECK_10(y < 2.2474362225598545e-308, scythe_range_error, "x too close to 0"); n = -n; for (int i = 0; i < n; i++) value /= (x + i); return value; } else { /* gamma(x) for 2 <= x <= 10 */ for (int i = 1; i <= n; i++) { value *= (y + i); } return value; } } else { /* gamma(x) for y = |x| > 10. */ /* Overflow */ SCYTHE_CHECK_10(x > 171.61447887182298, scythe_range_error,"Overflow"); /* Underflow */ SCYTHE_CHECK_10(x < -170.5674972726612, scythe_range_error, "Underflow"); double value = std::exp((y - 0.5) * std::log(y) - y + M_LN_SQRT_2PI + lngammacor(y)); if (x > 0) return value; SCYTHE_CHECK_10(std::fabs((x - (int)(x - 0.5))/x) < 67108864.0, scythe_precision_error, "Answer < 1/2 precision because x is " << "too near a negative integer"); double sinpiy = std::sin(M_PI * y); /* Negative integer arg - overflow */ SCYTHE_CHECK_10(sinpiy == 0, scythe_range_error, "Overflow"); return -M_PI / (y * sinpiy * value); } } /* The natural log of the absolute value of the gamma function */ /*! \brief The natural log of the absolute value of the gamma * function. * * Computes the natural log of the absolute value of the gamma * function, evaluated at \a x. * * \param x The value to compute log(abs(gamma())) at. * * \see gammafn(double x) * \see pgamma(double x, double shape, double scale) * \see dgamma(double x, double shape, double scale) * \see rng::rgamma(double shape, double scale) * * \throw scythe_range_error (Level 1) * \throw scythe_precision_error (Level 1) */ inline double lngammafn(double x) { SCYTHE_CHECK_10(x <= 0 && x == (int) x, scythe_range_error, "x is 0 or a negative integer"); double y = std::fabs(x); if (y <= 10) return std::log(std::fabs(gammafn(x))); SCYTHE_CHECK_10(y > 2.5327372760800758e+305, scythe_range_error, "Overflow"); if (x > 0) /* i.e. y = x > 10 */ return M_LN_SQRT_2PI + (x - 0.5) * std::log(x) - x + lngammacor(x); /* else: x < -10; y = -x */ double sinpiy = std::fabs(std::sin(M_PI * y)); if (sinpiy == 0) /* Negative integer argument */ throw scythe_exception("UNEXPECTED ERROR", __FILE__, __func__, __LINE__, "ERROR: Should never happen!"); double ans = M_LN_SQRT_PId2 + (x - 0.5) * std::log(y) - x - std::log(sinpiy) - lngammacor(y); SCYTHE_CHECK_10(std::fabs((x - (int)(x - 0.5)) * ans / x) < 1.490116119384765696e-8, scythe_precision_error, "Answer < 1/2 precision because x is " << "too near a negative integer"); return ans; } /* The beta function */ /*! \brief The beta function. * * Computes beta function, evaluated at (\a a, \a b). * * \param a The first parameter. * \param b The second parameter. * * \see lnbetafn(double a, double b) * \see pbeta(double x, double a, double b) * \see dbeta(double x, double a, double b) * \see rng::rbeta(double a, double b) * * \throw scythe_invalid_arg (Level 1) * \throw scythe_range_error (Level 1) * \throw scythe_precision_error (Level 1) */ inline double betafn(double a, double b) { SCYTHE_CHECK_10(a <= 0 || b <= 0, scythe_invalid_arg, "a or b < 0"); if (a + b < 171.61447887182298) /* ~= 171.61 for IEEE */ return gammafn(a) * gammafn(b) / gammafn(a+b); double val = lnbetafn(a, b); SCYTHE_CHECK_10(val < -708.39641853226412, scythe_range_error, "Underflow"); return std::exp(val); } /* The natural log of the beta function */ /*! \brief The natural log of the beta function. * * Computes the natural log of the beta function, * evaluated at (\a a, \a b). * * \param a The first parameter. * \param b The second parameter. * * \see betafn(double a, double b) * \see pbeta(double x, double a, double b) * \see dbeta(double x, double a, double b) * \see rng::rbeta(double a, double b) * * \throw scythe_invalid_arg (Level 1) * \throw scythe_range_error (Level 1) * \throw scythe_precision_error (Level 1) */ inline double lnbetafn (double a, double b) { double p, q; p = q = a; if(b < p) p = b;/* := min(a,b) */ if(b > q) q = b;/* := max(a,b) */ SCYTHE_CHECK_10(p <= 0 || q <= 0,scythe_invalid_arg, "a or b <= 0"); if (p >= 10) { /* p and q are big. */ double corr = lngammacor(p) + lngammacor(q) - lngammacor(p + q); return std::log(q) * -0.5 + M_LN_SQRT_2PI + corr + (p - 0.5) * std::log(p / (p + q)) + q * std::log(1 + (-p / (p + q))); } else if (q >= 10) { /* p is small, but q is big. */ double corr = lngammacor(q) - lngammacor(p + q); return lngammafn(p) + corr + p - p * std::log(p + q) + (q - 0.5) * std::log(1 + (-p / (p + q))); } /* p and q are small: p <= q > 10. */ return std::log(gammafn(p) * (gammafn(q) / gammafn(p + q))); } /* Compute the factorial of a non-negative integer */ /*! \brief The factorial function. * * Computes the factorial of \a n. * * \param n The non-negative integer value to compute the factorial of. * * \see lnfactorial(unsigned int n) * */ inline int factorial (unsigned int n) { if (n == 0) return 1; return n * factorial(n - 1); } /* Compute the natural log of the factorial of a non-negative * integer */ /*! \brief The log of the factorial function. * * Computes the natural log of the factorial of \a n. * * \param n The non-negative integer value to compute the natural log of the factorial of. * * \see factorial(unsigned int n) * */ inline double lnfactorial (unsigned int n) { double x = n+1; double cof[6] = { 76.18009172947146, -86.50532032941677, 24.01409824083091, -1.231739572450155, 0.1208650973866179e-2, -0.5395239384953e-5 }; double y = x; double tmp = x + 5.5 - (x + 0.5) * std::log(x + 5.5); double ser = 1.000000000190015; for (int j = 0; j <= 5; j++) { ser += (cof[j] / ++y); } return(std::log(2.5066282746310005 * ser / x) - tmp); } /********************************* * Fully Specified Distributions * *********************************/ /* These macros provide a nice shorthand for the matrix versions of * the pdf and cdf functions. */ #define SCYTHE_ARGSET(...) __VA_ARGS__ #define SCYTHE_DISTFUN_MATRIX(NAME, XTYPE, ARGNAMES, ...) \ template \ Matrix \ NAME (const Matrix& X, __VA_ARGS__) \ { \ Matrix ret(X.rows(), X.cols(), false); \ const_matrix_forward_iterator xit; \ const_matrix_forward_iterator xlast \ = X.template end_f(); \ typename Matrix::forward_iterator rit \ = ret.begin_f(); \ for (xit = X.template begin_f(); xit != xlast; ++xit) { \ *rit = NAME (*xit, ARGNAMES); \ ++rit; \ } \ SCYTHE_VIEW_RETURN(double, RO, RS, ret) \ } \ \ template \ Matrix \ NAME (const Matrix& X, __VA_ARGS__) \ { \ return NAME (X, ARGNAMES); \ } /**** The Beta Distribution ****/ /* CDFs */ /*! \brief The beta distribution function. * * Computes the value of the beta cumulative distribution function * with shape parameters \a a and \a b at the desired quantile, * \a x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired quantile, between 0 and 1. * \param a The first non-negative beta shape parameter. * \param b The second non-negative beta shape parameter. * * \see dbeta(double x, double a, double b) * \see rng::rbeta(double a, double b) * \see betafn(double a, double b) * \see lnbetafn(double a, double b) * * \throw scythe_invalid_arg (Level 1) * \throw scythe_range_error (Level 1) * \throw scythe_precision_error (Level 1) */ inline double pbeta(double x, double a, double b) { SCYTHE_CHECK_10(a <= 0 || b <= 0,scythe_invalid_arg, "a or b <= 0"); if (x <= 0) return 0.; if (x >= 1) return 1.; return pbeta_raw(x,a,b); } SCYTHE_DISTFUN_MATRIX(pbeta, double, SCYTHE_ARGSET(a, b), double a, double b) /* PDFs */ /*! \brief The beta density function. * * Computes the value of the beta probability density function * with shape parameters \a a and \a b at the desired quantile, * \a x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired quantile, between 0 and 1. * \param a The first non-negative beta shape parameter. * \param b The second non-negative beta shape parameter. * * \see pbeta(double x, double a, double b) * \see rng::rbeta(double a, double b) * \see betafn(double a, double b) * \see lnbetafn(double a, double b) * * \throw scythe_invalid_arg (Level 1) * \throw scythe_range_error (Level 1) * \throw scythe_precision_error (Level 1) */ inline double dbeta(double x, double a, double b) { SCYTHE_CHECK_10((x < 0.0) || (x > 1.0), scythe_invalid_arg, "x not in [0,1]"); SCYTHE_CHECK_10(a < 0.0, scythe_invalid_arg, "a < 0"); SCYTHE_CHECK_10(b < 0.0, scythe_invalid_arg, "b < 0"); return (std::pow(x, (a-1.0)) * std::pow((1.0-x), (b-1.0)) ) / betafn(a,b); } SCYTHE_DISTFUN_MATRIX(dbeta, double, SCYTHE_ARGSET(a, b), double a, double b) /* Returns the natural log of the ordinate of the Beta density * evaluated at x with Shape1 a, and Shape2 b */ /*! \brief The natural log of the ordinate of the beta density * function. * * Computes the value of the natural log of the ordinate of the beta * probability density function * with shape parameters \a a and \a b at the desired quantile, * \a x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired quantile, between 0 and 1. * \param a The first non-negative beta shape parameter. * \param b The second non-negative beta shape parameter. * * \see dbeta(double x, double a, double b) * * \throw scythe_invalid_arg (Level 1) * \throw scythe_range_error (Level 1) * \throw scythe_precision_error (Level 1) */ inline double lndbeta1(double x, double a, double b) { SCYTHE_CHECK_10((x < 0.0) || (x > 1.0), scythe_invalid_arg, "x not in [0,1]"); SCYTHE_CHECK_10(a < 0.0, scythe_invalid_arg, "a < 0"); SCYTHE_CHECK_10(b < 0.0, scythe_invalid_arg, "b < 0"); return (a-1.0) * std::log(x) + (b-1) * std::log(1.0-x) - lnbetafn(a,b); } SCYTHE_DISTFUN_MATRIX(lndbeta1, double, SCYTHE_ARGSET(a, b), double a, double b) /**** The Binomial Distribution ****/ /* CDFs */ /*! \brief The binomial distribution function. * * Computes the value of the binomial cumulative distribution function * with \a n trials and \a p probability of success on each trial, * at the desired quantile \a x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired quantile. * \param n The number of trials. * \param p The probability of success on each trial. * * \see dbinom(double x, unsigned int n, double p) * \see rng::rbinom(unsigned int n, double p) * * \throw scythe_invalid_arg (Level 1) * \throw scythe_range_error (Level 1) * \throw scythe_precision_error (Level 1) */ inline double pbinom(double x, unsigned int n, double p) { SCYTHE_CHECK_10(p < 0 || p > 1, scythe_invalid_arg, "p not in [0,1]"); double X = std::floor(x); if (X < 0.0) return 0; if (n <= X) return 1; return pbeta(1 - p, n - X, X + 1); } SCYTHE_DISTFUN_MATRIX(pbinom, double, SCYTHE_ARGSET(n, p), unsigned int n, double p) /* PDFs */ /*! \brief The binomial density function. * * Computes the value of the binomial probability density function * with \a n trials and \a p probability of success on each trial, * at the desired quantile \a x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired quantile. * \param n The number of trials. * \param p The probability of success on each trial. * * \see pbinom(double x, unsigned int n, double p) * \see rng::rbinom(unsigned int n, double p) * * \throw scythe_invalid_arg (Level 1) * \throw scythe_range_error (Level 1) * \throw scythe_precision_error (Level 1) */ inline double dbinom(double x, unsigned int n, double p) { SCYTHE_CHECK_10(p < 0 || p > 1, scythe_invalid_arg, "p not in [0, 1]"); double X = std::floor(x + 0.5); return dbinom_raw(X, n, p, 1 - p); } SCYTHE_DISTFUN_MATRIX(dbinom, double, SCYTHE_ARGSET(n, p), unsigned int n, double p) /**** The Chi Squared Distribution ****/ /* CDFs */ /*! \brief The \f$\chi^2\f$ distribution function. * * Computes the value of the \f$\chi^2\f$ cumulative distribution * function with \a df degrees of freedom, at the desired quantile * \a x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired quantile. * \param df The degrees of freedom. * \see dchisq(double x, double df) * \see rng::rchisq(double df) * * \throw scythe_invalid_arg (Level 1) * \throw scythe_range_error (Level 1) * \throw scythe_precision_error (Level 1) * \throw scythe_convergence_error (Level 1) * */ inline double pchisq(double x, double df) { return pgamma(x, df/2.0, 2.0); } SCYTHE_DISTFUN_MATRIX(pchisq, double, df, double df) /* PDFs */ /*! \brief The \f$\chi^2\f$ density function. * * Computes the value of the \f$\chi^2\f$ probability density * function with \a df degrees of freedom, at the desired quantile * \a x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired quantile. * \param df The degrees of freedom. * \see pchisq(double x, double df) * \see rng::rchisq(double df) * * \throw scythe_invalid_arg (Level 1) * \throw scythe_range_error (Level 1) * \throw scythe_precision_error (Level 1) * \throw scythe_convergence_error (Level 1) * */ inline double dchisq(double x, double df) { return dgamma(x, df / 2.0, 2.0); } SCYTHE_DISTFUN_MATRIX(dchisq, double, df, double df) /**** The Exponential Distribution ****/ /* CDFs */ /*! \brief The exponential distribution function. * * Computes the value of the exponential cumulative distribution * function with given \a scale, at the desired quantile * \a x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired quantile. * \param scale The positive scale of the function. * * \see dexp(double x, double scale) * \see rng::rexp(double scale) * * \throw scythe_invalid_arg (Level 1) */ inline double pexp(double x, double scale) { SCYTHE_CHECK_10(scale <= 0, scythe_invalid_arg, "scale <= 0"); if (x <= 0) return 0; return (1 - std::exp(-x*scale)); } SCYTHE_DISTFUN_MATRIX(pexp, double, scale, double scale) /* PDFs */ /*! \brief The exponential density function. * * Computes the value of the exponential probability density * function with given \a scale, at the desired quantile * \a x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired quantile. * \param scale The positive scale of the function. * * \see pexp(double x, double scale) * \see rng::rexp(double scale) * * \throw scythe_invalid_arg (Level 1) */ inline double dexp(double x, double scale) { SCYTHE_CHECK_10(scale <= 0, scythe_invalid_arg, "scale <= 0"); if (x < 0) return 0; return std::exp(-x * scale) * scale; } SCYTHE_DISTFUN_MATRIX(dexp, double, scale, double scale) /**** The f Distribution ****/ /* CDFs */ /*! \brief The F distribution function. * * Computes the value of the F cumulative distribution function with * \a df1 and \a df2 degrees of freedom, at the desired quantile \a * x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired quantile. * \param df1 The non-negative degrees of freedom for the * \f$\chi^2\f$ variate in the nominator of the F statistic. * \param df2 The non-negative degrees of freedom for the * \f$\chi^2\f$ variate in the denominator of the F statistic. * * * \see df(double x, double df1, double df2) * \see rng::rf(double df1, double df2) * * \throw scythe_invalid_arg (Level 1) * \throw scythe_range_error (Level 1) * \throw scythe_precision_error (Level 1) * \throw scythe_convergence_error (Level 1) */ inline double pf(double x, double df1, double df2) { SCYTHE_CHECK_10(df1 <= 0 || df2 <= 0, scythe_invalid_arg, "df1 or df2 <= 0"); if (x <= 0) return 0; if (df2 > 4e5) return pchisq(x*df1,df1); if (df1 > 4e5) return 1-pchisq(df2/x,df2); return (1-pbeta(df2 / (df2 + df1 * x), df2 / 2.0, df1 / 2.0)); } SCYTHE_DISTFUN_MATRIX(pf, double, SCYTHE_ARGSET(df1, df2), double df1, double df2) /* PDFs */ /*! \brief The F density function. * * Computes the value of the F probability density function with * \a df1 and \a df2 degrees of freedom, at the desired quantile \a * x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired quantile. * \param df1 The non-negative degrees of freedom for the * \f$\chi^2\f$ variate in the nominator of the F statistic. * \param df2 The non-negative degrees of freedom for the * \f$\chi^2\f$ variate in the denominator of the F statistic. * * \see df(double x, double df1, double df2) * \see rng::rf(double df1, double df2) * * \throw scythe_invalid_arg (Level 1) * \throw scythe_range_error (Level 1) * \throw scythe_precision_error (Level 1) * \throw scythe_convergence_error (Level 1) */ inline double df(double x, double df1, double df2) { double dens; SCYTHE_CHECK_10(df1 <= 0 || df2 <= 0, scythe_invalid_arg, "df1 or df2 <= 0"); if (x <= 0) return 0; double f = 1 / (df2 + x * df1); double q = df2 * f; double p = x * df1 * f; if (df1 >= 2) { f = df1 * q / 2; dens = dbinom_raw((df1 - 2) / 2,(df1 + df2 - 2) / 2, p, q); } else { f = (df1 * df1 * q) /(2 * p * (df1 + df2)); dens = dbinom_raw(df1 / 2,(df1 + df2)/ 2, p, q); } return f*dens; } SCYTHE_DISTFUN_MATRIX(df, double, SCYTHE_ARGSET(df1, df2), double df1, double df2) /**** The Gamma Distribution ****/ /* CDFs */ /*! \brief The gamma distribution function. * * Computes the value of the gamma cumulative distribution * function with given \a shape and \a scale, at the desired quantile * \a x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired quantile. * \param shape The non-negative shape of the distribution. * \param scale The non-negative scale of the distribution. * * \see dgamma(double x, double shape, double scale) * \see rng::rgamma(double shape, double scale) * \see gammafn(double x) * \see lngammafn(double x) * * \throw scythe_invalid_arg (Level 1) * \throw scythe_range_error (Level 1) * \throw scythe_precision_error (Level 1) * \throw scythe_convergence_error (Level 1) */ inline double pgamma (double x, double shape, double scale) { const double xbig = 1.0e+8, xlarge = 1.0e+37, alphlimit = 1000.;/* normal approx. for shape > alphlimit */ int lower_tail = 1; double pn1, pn2, pn3, pn4, pn5, pn6, arg, a, b, c, an, osum, sum; long n; int pearson; /* check that we have valid values for x and shape */ SCYTHE_CHECK_10(shape <= 0. || scale <= 0., scythe_invalid_arg, "shape or scale <= 0"); x /= scale; if (x <= 0.) return 0.0; /* use a normal approximation if shape > alphlimit */ if (shape > alphlimit) { pn1 = std::sqrt(shape) * 3. * (std::pow(x/shape, 1./3.) + 1. / (9. * shape) - 1.); return pnorm(pn1, 0., 1.); } /* if x is extremely large __compared to shape__ then return 1 */ if (x > xbig * shape) return 1.0; if (x <= 1. || x < shape) { pearson = 1;/* use pearson's series expansion. */ arg = shape * std::log(x) - x - lngammafn(shape + 1.); c = 1.; sum = 1.; a = shape; do { a += 1.; c *= x / a; sum += c; } while (c > DBL_EPSILON); arg += std::log(sum); } else { /* x >= max( 1, shape) */ pearson = 0;/* use a continued fraction expansion */ arg = shape * std::log(x) - x - lngammafn(shape); a = 1. - shape; b = a + x + 1.; pn1 = 1.; pn2 = x; pn3 = x + 1.; pn4 = x * b; sum = pn3 / pn4; for (n = 1; ; n++) { a += 1.;/* = n+1 -shape */ b += 2.;/* = 2(n+1)-shape+x */ an = a * n; pn5 = b * pn3 - an * pn1; pn6 = b * pn4 - an * pn2; if (std::fabs(pn6) > 0.) { osum = sum; sum = pn5 / pn6; if (std::fabs(osum - sum) <= DBL_EPSILON * std::min(1., sum)) break; } pn1 = pn3; pn2 = pn4; pn3 = pn5; pn4 = pn6; if (std::fabs(pn5) >= xlarge) { /* re-scale terms in continued fraction if they are large */ pn1 /= xlarge; pn2 /= xlarge; pn3 /= xlarge; pn4 /= xlarge; } } arg += std::log(sum); } lower_tail = (lower_tail == pearson); sum = std::exp(arg); return (lower_tail) ? sum : 1 - sum; } SCYTHE_DISTFUN_MATRIX(pgamma, double, SCYTHE_ARGSET(shape, scale), double shape, double scale) /* PDFs */ /*! \brief The gamma density function. * * Computes the value of the gamma probability density * function with given \a shape and \a scale, at the desired quantile * \a x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired quantile. * \param shape The non-negative shape of the distribution. * \param scale The non-negative scale of the distribution. * * \see pgamma(double x, double shape, double scale) * \see rng::rgamma(double shape, double scale) * \see gammafn(double x) * \see lngammafn(double x) * * \throw scythe_invalid_arg (Level 1) * \throw scythe_range_error (Level 1) * \throw scythe_precision_error (Level 1) * \throw scythe_convergence_error (Level 1) */ inline double dgamma(double x, double shape, double scale) { SCYTHE_CHECK_10(shape <= 0 || scale <= 0,scythe_invalid_arg, "shape or scale <= 0"); if (x < 0) return 0.0; if (x == 0) { SCYTHE_CHECK_10(shape < 1,scythe_invalid_arg, "x == 0 and shape < 1"); if (shape > 1) return 0.0; return 1 / scale; } if (shape < 1) { double pr = dpois_raw(shape, x/scale); return pr * shape / x; } /* else shape >= 1 */ double pr = dpois_raw(shape - 1, x / scale); return pr / scale; } SCYTHE_DISTFUN_MATRIX(dgamma, double, SCYTHE_ARGSET(shape, scale), double shape, double scale) /**** The Logistic Distribution ****/ /* CDFs */ /*! \brief The logistic distribution function. * * Computes the value of the logistic cumulative distribution * function with given \a location and \a scale, at the desired * quantile \a x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired quantile. * \param location The location of the distribution. * \param scale The positive scale of the distribution. * * \see dlogis(double x, double location, double scale) * \see rng::rlogis(double location, double scale) * * \throw scythe_invalid_arg (Level 1) */ inline double plogis (double x, double location, double scale) { SCYTHE_CHECK_10(scale <= 0.0, scythe_invalid_arg, "scale <= 0"); double X = (x-location) / scale; X = std::exp(-X); return 1 / (1+X); } SCYTHE_DISTFUN_MATRIX(plogis, double, SCYTHE_ARGSET(location, scale), double location, double scale) /* PDFs */ /*! \brief The logistic density function. * * Computes the value of the logistic probability density * function with given \a location and \a scale, at the desired * quantile \a x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired quantile. * \param location The location of the distribution. * \param scale The positive scale of the distribution. * * \see plogis(double x, double location, double scale) * \see rng::rlogis(double location, double scale) * * \throw scythe_invalid_arg (Level 1) */ inline double dlogis(double x, double location, double scale) { SCYTHE_CHECK_10(scale <= 0.0, scythe_invalid_arg, "scale <= 0"); double X = (x - location) / scale; double e = std::exp(-X); double f = 1.0 + e; return e / (scale * f * f); } SCYTHE_DISTFUN_MATRIX(dlogis, double, SCYTHE_ARGSET(location, scale), double location, double scale) /**** The Log Normal Distribution ****/ /* CDFs */ /*! \brief The log-normal distribution function. * * Computes the value of the log-normal cumulative distribution * function with mean \a logmean and standard * deviation \a logsd, at the desired quantile \a x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired quantile. * \param logmean The mean of the distribution. * \param logsd The positive standard deviation of the distribution. * * \see dlnorm(double x, double logmean, double logsd) * \see rng::rlnorm(double logmean, double logsd) * \see pnorm(double x, double logmean, double logsd) * * \throw scythe_invalid_arg (Level 1) * \throw scythe_convergence_error (Level 1) */ inline double plnorm (double x, double logmean, double logsd) { SCYTHE_CHECK_10(logsd <= 0, scythe_invalid_arg, "logsd <= 0"); if (x > 0) return pnorm(std::log(x), logmean, logsd); return 0; } SCYTHE_DISTFUN_MATRIX(plnorm, double, SCYTHE_ARGSET(logmean, logsd), double logmean, double logsd) /* PDFs */ /*! \brief The log-normal density function. * * Computes the value of the log-normal probability density * function with mean \a logmean and standard * deviation \a logsd, at the desired quantile \a x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired quantile. * \param logmean The mean of the distribution. * \param logsd The positive standard deviation of the distribution. * * \see plnorm(double x, double logmean, double logsd) * \see rng::rlnorm(double logmean, double logsd) * \see dnorm(double x, double logmean, double logsd) * * \throw scythe_invalid_arg (Level 1) */ inline double dlnorm(double x, double logmean, double logsd) { SCYTHE_CHECK_10(logsd <= 0, scythe_invalid_arg, "logsd <= 0"); if (x == 0) return 0; double y = (std::log(x) - logmean) / logsd; return (1 / (std::sqrt(2 * M_PI))) * std::exp(-0.5 * y * y) / (x * logsd); } SCYTHE_DISTFUN_MATRIX(dlnorm, double, SCYTHE_ARGSET(logmean, logsd), double logmean, double logsd) /**** The Negative Binomial Distribution ****/ /* CDFs */ /*! \brief The negative binomial distribution function. * * Computes the value of the negative binomial cumulative distribution * function with \a n target number of successful trials and \a p * probability of success on each trial, at the desired quantile \a * x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired non-negative, integer, quantile. * \param n The positive target number of successful trials * (dispersion parameter). * \param p The probability of success on each trial. * * \see dnbinom(unsigned int x, double n, double p) * \see rng::rnbinom(double n, double p) * * \throw scythe_invalid_arg (Level 1) * \throw scythe_range_error (Level 1) * \throw scythe_precision_error (Level 1) */ inline double pnbinom(unsigned int x, double n, double p) { SCYTHE_CHECK_10(n == 0 || p <= 0 || p >= 1, scythe_invalid_arg, "n == 0 or p not in (0,1)"); return pbeta(p, n, x + 1); } SCYTHE_DISTFUN_MATRIX(pnbinom, unsigned int, SCYTHE_ARGSET(n, p), double n, double p) /* PDFs */ /*! \brief The negative binomial density function. * * Computes the value of the negative binomial probability density * function with \a n target number of successful trials and \a p * probability of success on each trial, at the desired quantile \a * x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired non-negative, integer, quantile. * \param n The positive target number of successful trials * (dispersion parameter). * \param p The probability of success on each trial. * * \see dnbinom(unsigned int x, double n, double p) * \see rng::rnbinom(double n, double p) * * \throw scythe_invalid_arg (Level 1) * \throw scythe_range_error (Level 1) * \throw scythe_precision_error (Level 1) */ inline double dnbinom(unsigned int x, double n, double p) { SCYTHE_CHECK_10(n == 0 || p <= 0 || p >= 1, scythe_invalid_arg, "n == 0 or p not in (0,1)"); double prob = dbinom_raw(n, x + n, p, 1 - p); double P = (double) n / (n + x); return P * prob; } SCYTHE_DISTFUN_MATRIX(dnbinom, unsigned int, SCYTHE_ARGSET(n, p), double n, double p) /**** The Normal Distribution ****/ /* CDFs */ /*! \brief The normal distribution function. * * Computes the value of the normal cumulative distribution * function with given \a mean and standard deviation \a sd, at the * desired quantile \a x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired quantile. * \param mean The mean of the distribution. * \param sd The positive standard deviation of the distribution. * * \see dnorm(double x, double mean, double sd) * \see rng::rnorm(double mean, double sd) * * \throw scythe_invalid_arg (Level 1) * \throw scythe_convergence_error (Level 1) */ inline double pnorm (double x, double mean, double sd) { SCYTHE_CHECK_10(sd <= 0, scythe_invalid_arg, "negative standard deviation"); return pnorm1((x - mean) / sd, true, false); } SCYTHE_DISTFUN_MATRIX(pnorm, double, SCYTHE_ARGSET(mean, sd), double mean, double sd) /* PDFs */ /*! \brief The normal density function. * * Computes the value of the normal probability density * function with given \a mean and standard deviation \a sd, at the * desired quantile \a x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired quantile. * \param mean The mean of the distribution. * \param sd The positive standard deviation of the distribution. * * \see pnorm(double x, double mean, double sd) * \see rng::rnorm(double mean, double sd) * * \throw scythe_invalid_arg (Level 1) */ inline double dnorm(double x, double mean, double sd) { SCYTHE_CHECK_10(sd <= 0, scythe_invalid_arg, "negative standard deviation"); double X = (x - mean) / sd; return (M_1_SQRT_2PI * std::exp(-0.5 * X * X) / sd); } SCYTHE_DISTFUN_MATRIX(dnorm, double, SCYTHE_ARGSET(mean, sd), double mean, double sd) /* Return the natural log of the normal PDF */ /*! \brief The natural log of normal density function. * * Computes the value of the natural log of the normal probability * density function with given \a mean and standard deviation \a sd, * at the desired quantile \a x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired quantile. * \param mean The mean of the distribution. * \param sd The positive standard deviation of the distribution. * * \see dnorm(double x, double mean, double sd) * \see pnorm(double x, double mean, double sd) * \see rng::rnorm(double mean, double sd) * * \throw scythe_invalid_arg (Level 1) */ inline double lndnorm (double x, double mean, double sd) { SCYTHE_CHECK_10(sd <= 0, scythe_invalid_arg, "negative standard deviation"); double X = (x - mean) / sd; return -(M_LN_SQRT_2PI + 0.5 * X * X + std::log(sd)); } SCYTHE_DISTFUN_MATRIX(lndnorm, double, SCYTHE_ARGSET(mean, sd), double mean, double sd) /* Quantile functions */ /*! \brief The standard normal quantile function. * * Computes the value of the standard normal quantile function * at the desired probability \a in_p. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param in_p The desired probability. * * \see pnorm(double x, double mean, double sd) * \see dnorm(double x, double mean, double sd) * \see rng::rnorm(double mean, double sd) * * \throw scythe_invalid_arg (Level 1) */ inline double qnorm1 (double in_p) { double p0 = -0.322232431088; double q0 = 0.0993484626060; double p1 = -1.0; double q1 = 0.588581570495; double p2 = -0.342242088547; double q2 = 0.531103462366; double p3 = -0.0204231210245; double q3 = 0.103537752850; double p4 = -0.453642210148e-4; double q4 = 0.38560700634e-2; double xp = 0.0; double p = in_p; if (p > 0.5) p = 1 - p; SCYTHE_CHECK_10(p < 10e-20, scythe_range_error, "p outside accuracy limit"); if (p == 0.5) return xp; double y = std::sqrt (std::log (1.0 / std::pow (p, 2))); xp = y + ((((y * p4 + p3) * y + p2) * y + p1) * y + p0) / ((((y * q4 + q3) * y + q2) * y + q1) * y + q0); if (in_p < 0.5) xp = -1 * xp; return xp; } SCYTHE_DISTFUN_MATRIX(qnorm1, double, in_p, double in_p) /**** The Poisson Distribution ****/ /* CDFs */ /*! \brief The Poisson distribution function. * * Computes the value of the Poisson cumulative distribution * function with expected number of occurrences \a lambda, at the * desired quantile \a x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired integer quantile. * \param lambda The expected positive number of occurrences. * * \see dpois(unsigned int x, double lambda) * \see rng::rpois(double lambda) * * \throws scythe_invalid_arg (Level 1) * \throw scythe_range_error (Level 1) * \throw scythe_precision_error (Level 1) * \throw scythe_convergence_error (Level 1) */ inline double ppois(unsigned int x, double lambda) { SCYTHE_CHECK_10(lambda<=0.0, scythe_invalid_arg, "lambda <= 0"); if (lambda == 1) return 1; return 1 - pgamma(lambda, x + 1, 1.0); } SCYTHE_DISTFUN_MATRIX(ppois, unsigned int, lambda, double lambda) /* PDFs */ /*! \brief The Poisson density function. * * Computes the value of the Poisson probability density * function with expected number of occurrences \a lambda, at the * desired quantile \a x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired integer quantile. * \param lambda The expected positive number of occurrences. * * \see ppois(unsigned int x, double lambda) * \see rng::rpois(double lambda) * * \throws scythe_invalid_arg (Level 1) */ inline double dpois(unsigned int x, double lambda) { SCYTHE_CHECK_10(lambda<=0.0, scythe_invalid_arg, "lambda <= 0"); // compute log(x!) double xx = x+1; double cof[6] = { 76.18009172947146, -86.50532032941677, 24.01409824083091, -1.231739572450155, 0.1208650973866179e-2, -0.5395239384953e-5 }; double y = xx; double tmp = xx + 5.5 - (xx + 0.5) * std::log(xx + 5.5); double ser = 1.000000000190015; for (int j = 0; j <= 5; j++) { ser += (cof[j] / ++y); } double lnfactx = std::log(2.5066282746310005 * ser / xx) - tmp; return (std::exp( -1*lnfactx + x * std::log(lambda) - lambda)); } SCYTHE_DISTFUN_MATRIX(dpois, unsigned int, lambda, double lambda) /**** The t Distribution ****/ /* CDFs */ /*! \brief The Student t distribution function. * * Computes the value of the Student t cumulative distribution * function with \a n degrees of freedom, at the desired quantile * \a x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired quantile. * \param n The positive degrees of freedom of the distribution. * * \see dt(double x, bool b1, bool b2) * \see rng::rt1(double mu, double sigma2, double nu) * * \throw scythe_invalid_arg (Level 1) * \throw scythe_convergence_error (Level 1) * \throw scythe_range_error (Level 1) * \throw scythe_precision_error (Level 1) */ inline double pt(double x, double n) { double val; SCYTHE_CHECK_10(n <= 0, scythe_invalid_arg, "n <= 0"); if (n > 4e5) { val = 1/(4*n); return pnorm1(x * (1 - val) / ::sqrt(1 + x * x * 2. * val), true, false); } val = pbeta(n / (n + x * x), n / 2.0, 0.5); val /= 2; if (x <= 0) return val; else return 1 - val; } SCYTHE_DISTFUN_MATRIX(pt, double, n, double n) /* PDFs */ /*! \brief The Student t distribution function. * * Computes the value of the Student t cumulative distribution * function with \a n degrees of freedom, at the desired quantile * \a x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired quantile. * \param n The positive degrees of freedom of the distribution. * * \see pt(double x, bool b1, bool b2) * \see rng::rt1(double mu, double sigma2, double nu) * * \throw scythe_invalid_arg (Level 1) * \throw scythe_range_error (Level 1) * \throw scythe_precision_error (Level 1) */ inline double dt(double x, double n) { double u; SCYTHE_CHECK_10(n <= 0, scythe_invalid_arg, "n <= 0"); double t = -bd0(n/2., (n + 1) / 2.) + stirlerr((n + 1) / 2.) - stirlerr(n / 2.); if(x*x > 0.2*n) u = std::log(1+x*x/n)*n/2; else u = -bd0(n/2., (n+x*x)/2.) + x*x/2; return std::exp(t-u)/std::sqrt(2*M_PI*(1+x*x/n)); } SCYTHE_DISTFUN_MATRIX(dt, double, n, double n) /* Returns the univariate Student-t density evaluated at x * with mean mu, scale sigma^2, and nu degrees of freedom. * * TODO: Do we want a pt for this distribution? */ /*! \brief The univariate Student t density function. * * Computes the value of the univariate Student t probability * density function with mean \a mu, variance \a sigma2, * and degrees of freedom \a nu, at the desired quantile \a x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired quantile. * \param mu The mean of the distribution. * \param sigma2 The variance of the distribution. * \param nu The degrees of freedom of the distribution. * * \see rng::rt1(double mu, double sigma2, double nu) * \see dt(double x, bool b1, bool b2) * \see pt(double x, bool b1, bool b2) * * \throw scythe_invalid_arg (Level 1) * \throw scythe_range_error (Level 1) * \throw scythe_precision_error (Level 1) */ inline double dt1(double x, double mu, double sigma2, double nu) { double logdens = lngammafn((nu + 1.0) /2.0) - std::log(std::sqrt(nu * M_PI)) - lngammafn(nu / 2.0) - std::log(std::sqrt(sigma2)) - (nu + 1.0) / 2.0 * std::log(1.0 + (std::pow((x - mu), 2.0)) / (nu * sigma2)); return(std::exp(logdens)); } SCYTHE_DISTFUN_MATRIX(dt1, double, SCYTHE_ARGSET(mu, sigma2, nu), double mu, double sigma2, double nu) /* Returns the natural log of the univariate Student-t density * evaluated at x with mean mu, scale sigma^2, and nu * degrees of freedom */ /*! \brief The natural log of the univariate Student t density * function. * * Computes the value of the natural log of the univariate Student t * probability density function with mean \a mu, variance \a sigma2, * and degrees of freedom \a nu, at the desired quantile \a x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired quantile. * \param mu The mean of the distribution. * \param sigma2 The variance of the distribution. * \param nu The degrees of freedom of the distribution. * * \see rng::rt1(double mu, double sigma2, double nu) * \see dt(double x, bool b1, bool b2) * \see pt(double x, bool b1, bool b2) * * \throw scythe_invalid_arg (Level 1) * \throw scythe_range_error (Level 1) * \throw scythe_precision_error (Level 1) */ inline double lndt1(double x, double mu, double sigma2, double nu) { double logdens = lngammafn((nu+1.0)/2.0) - std::log(std::sqrt(nu*M_PI)) - lngammafn(nu/2.0) - std::log(std::sqrt(sigma2)) - (nu+1.0)/2.0 * std::log(1.0 + (std::pow((x-mu),2.0)) /(nu * sigma2)); return(logdens); } SCYTHE_DISTFUN_MATRIX(lndt1, double, SCYTHE_ARGSET(mu, sigma2, nu), double mu, double sigma2, double nu) /**** The Uniform Distribution ****/ /* CDFs */ /*! \brief The uniform distribution function. * * Computes the value of the uniform cumulative distribution * function evaluated on the interval [\a a, \a b], at the desired * quantile \a x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired quantile x. * \param a The lower end-point of the distribution. * \param b The upper end-point of the distribution. * * \see dunif(double x, double a, double b) * \see rng::runif() * * \throw scythe_invalid_arg (Level 1) */ inline double punif(double x, double a, double b) { SCYTHE_CHECK_10(b <= a, scythe_invalid_arg, "b <= a"); if (x <= a) return 0.0; if (x >= b) return 1.0; return (x - a) / (b - a); } SCYTHE_DISTFUN_MATRIX(punif, double, SCYTHE_ARGSET(a, b), double a, double b) /* PDFs */ /*! \brief The uniform density function. * * Computes the value of the uniform probability density * function evaluated on the interval [\a a, \a b], at the desired * quantile \a x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired quantile x. * \param a The lower end-point of the distribution. * \param b The upper end-point of the distribution. * * \see punif(double x, double a, double b) * \see rng::runif() * * \throw scythe_invalid_arg (Level 1) */ inline double dunif(double x, double a, double b) { SCYTHE_CHECK_10(b <= a, scythe_invalid_arg, "b <= a"); if (a <= x && x <= b) return 1.0 / (b - a); return 0.0; } SCYTHE_DISTFUN_MATRIX(dunif, double, SCYTHE_ARGSET(a, b), double a, double b) /**** The Weibull Distribution ****/ /* CDFs */ /*! \brief The Weibull distribution function. * * Computes the value of the Weibull cumulative distribution * function with given \a shape and \a scale, at the desired * quantile \a x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired quantile. * \param shape The positive shape of the distribution. * \param scale The positive scale of the distribution. * * \see dweibull(double x, double shape, double scale) * \see rng::rweibull(double shape, double scale) * * \throw scythe_invalid_arg (Level 1) */ inline double pweibull(double x, double shape, double scale) { SCYTHE_CHECK_10(shape <= 0 || scale <= 0, scythe_invalid_arg, "shape or scale <= 0"); if (x <= 0) return 0.0; return 1 - std::exp(-std::pow(x / scale, shape)); } SCYTHE_DISTFUN_MATRIX(pweibull, double, SCYTHE_ARGSET(shape, scale), double shape, double scale) /* PDFs */ /*! \brief The Weibull density function. * * Computes the value of the Weibull probability density * function with given \a shape and \a scale, at the desired * quantile \a x. * * It is also possible to call this function with a Matrix of * doubles as its first argument. In this case the function will * return a Matrix of doubles of the same dimension as \a x, * containing the result of evaluating this function at each value * in \a x, given the remaining fixed parameters. By default, the * returned Matrix will be concrete and have the same matrix_order * as \a x, but you may invoke a generalized version of the function * with an explicit template call. * * \param x The desired quantile. * \param shape The positive shape of the distribution. * \param scale The positive scale of the distribution. * * \see pweibull(double x, double shape, double scale) * \see rng::rweibull(double shape, double scale) * * \throw scythe_invalid_arg (Level 1) */ inline double dweibull(double x, double shape, double scale) { SCYTHE_CHECK_10(shape <= 0 || scale <= 0, scythe_invalid_arg, "shape or scale <= 0"); if (x < 0) return 0.; double tmp1 = std::pow(x / scale, shape - 1); double tmp2 = tmp1*(x / scale); return shape * tmp1 * std::exp(-tmp2) / scale; } SCYTHE_DISTFUN_MATRIX(dweibull, double, SCYTHE_ARGSET(shape, scale), double shape, double scale) /* Multivariate Normal */ // TODO: distribution function. Plain old (non-logged) dmvnorm. /*! \brief The natural log of the multivariate normal density * function. * * Computes the value of the natural log of the multivariate normal * probability density function with vector of mean \a mu and * variance-covariance matrix \a Sigma, at the vector of desired * quantiles \a x. * * \param x The vector of desired quantiles. * \param mu The vector of means. * \param Sigma The variance-covariance matrix. * * \see rng:rmvnorm(const Matrix& mu, const Matrix& sigma) * * \throw scythe_dimension_error (Level 1) * \throw scythe_conformation_error (Level 1) * \throw scythe_null_error (Level 1) */ template double lndmvn (const Matrix& x, const Matrix& mu, const Matrix& Sigma) { SCYTHE_CHECK_10(! x.isColVector(), scythe_dimension_error, "x is not a column vector"); SCYTHE_CHECK_10(! mu.isColVector(), scythe_dimension_error, "mu is not a column vector"); SCYTHE_CHECK_10(! Sigma.isSquare(), scythe_dimension_error, "Sigma is not square"); SCYTHE_CHECK_10(mu.rows()!=Sigma.rows() || x.rows()!=Sigma.rows(), scythe_conformation_error, "mu, x and Sigma have mismatched row lengths") int k = (int) mu.rows(); return ( (-k/2.0)*std::log(2*M_PI) -0.5 * std::log(det(Sigma)) -0.5 * (t(x - mu)) * invpd(Sigma) * (x-mu) )[0]; } } // end namespace scythe #endif /* SCYTHE_DISTRIBUTIONS_H */ scythestat-1.0.3/scythestat/stat.h0000644000175000017500000004415111764443316014164 00000000000000/* * Scythe Statistical Library Copyright (C) 2000-2002 Andrew D. Martin * and Kevin M. Quinn; 2002-present Andrew D. Martin, Kevin M. Quinn, * and Daniel Pemstein. All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify under the terms of the GNU General Public License as * published by Free Software Foundation; either version 2 of the * License, or (at your option) any later version. See the text files * COPYING and LICENSE, distributed with this source code, for further * information. * -------------------------------------------------------------------- * scythestat/stat.h * */ /*! * \file stat.h * \brief Definitions for functions that perform common * statistical operations on Scythe Matrix objects. * * \note As is the case throughout the library, we provide both * general and default template definitions of the Matrix-returning * functions in this file, explicitly providing documentation for only * the general template versions. */ #ifndef SCYTHE_STAT_H #define SCYTHE_STAT_H #ifdef SCYTHE_COMPILE_DIRECT #include "matrix.h" #include "algorithm.h" #include "error.h" #else #include "scythestat/matrix.h" #include "scythestat/algorithm.h" #include "scythestat/error.h" #endif #include #include namespace scythe { namespace { typedef unsigned int uint; } /* A macro for defining column versions of a function. That is, * when expanded, this macro produces general and default template * functions that compute function NAME on each column in a matrix and * return a row vector with the results. We use this to generate * column versions of every function in this header file. */ #define SCYTHE_STATMETH_COL(NAME) \ template \ Matrix \ NAME ## c (const Matrix& A) \ { \ Matrix res (1, A.cols(), false); \ \ for (uint j = 0; j < A.cols(); ++j) \ res[j] = NAME(A(_, j)); \ \ return res; \ } \ \ template \ Matrix \ NAME ## c (const Matrix& A) \ { \ return NAME ## c(A); \ } /* Calculate the sum of a Matrix */ /*! * \brief Calculate the sum of a Matrix * * This function calculates the sum of a matrix by adding each element * in turn. * * \param A The matrix to be summed. * * \see prod(const Matrix &A) * \see sumc(const Matrix &A) * \see prodc(const Matrix &A) */ template T sum (const Matrix &A) { return (std::accumulate(A.begin_f(), A.end_f(), (T) 0)); } /* Calculate the sum of each column in a Matrix */ /*! * \brief Calculate the sum of each column in a Matrix * * This function calculates the sum of each column in a matrix by * consecutively adding elements in a single column, looping through all * columns, and returning the results. * * \param A The matrix to be summed. * * \see prod(const Matrix &A) * \see sum(const Matrix &A) * \see prodc(const Matrix &A) */ SCYTHE_STATMETH_COL(sum) /* Calculate the product of a Matrix */ /*! * \brief Calculate the product of a Matrix * * This function calculates the product of a matrix by beginning with the * first element of a matrix, and consecutively multiplying each entry. * * \param A The matrix to be multiplied. * * \see sumc(const Matrix &A) * \see sum(const Matrix &A) * \see prodc(const Matrix &A) */ template T prod (const Matrix &A) { return std::accumulate(A.begin_f(), A.end_f(), (T) 1, std::multiplies ()); } /* Calculate the product of each column of a matrix */ /*! * \brief Calculate the product of each column of a Matrix * * This function calculates the product of each column of a matrix by * multiplying all elements of a single column, looping through all columns, * and returning the results. * * \param A The matrix to be multiplied. * * \see sumc(const Matrix &A) * \see sum(const Matrix &A) * \see prod(const Matrix &A) */ SCYTHE_STATMETH_COL(prod) /* Calculate the mean of a Matrix */ /*! * \brief Calculate the mean of a Matrix * * This function calculates the mean of a matrix by summing all elements of * the matrix, and dividing by the total number of elements in the matrix. * * \param A The matrix to be averaged. * * \see sum(const Matrix &A) * \see meanc(const Matrix &A) * \see median(const Matrix &A) * \see mode(const Matrix &A) * \see variance(const Matrix &A) */ template T mean (const Matrix &A) { return (std::accumulate(A.begin_f(), A.end_f(), (T) 0) / A.size()); } /* Calculate the mean of each column of a Matrix */ /*! * \brief Calculate the mean of each column of a Matrix * * This function calculates the mean of each column of a matrix by summing * all elements of a column in the matrix, divding by the total number of * elements in the column, and looping over every column in the matrix. * * \param A The matrix to be averaged. * * \see sumc(const Matrix &A) * \see mean(const Matrix &A) * \see medianc(const Matrix &A) * \see modec(const Matrix &A) * \see variancec(const Matrix &A) */ SCYTHE_STATMETH_COL(mean) /* Calculate the median of a matrix. Uses a sort but I'll implement * the randomized alg when I figure out how to generalize it to * even-length lists */ /*! * \brief Calculate the median of a Matrix * * This function calculates the median of a matrix by first sorting the elements * of the matrix, and then finding the middle element. * * \param A The matrix whose median is of interest. * * \see medianc(const Matrix &A) * \see mean(const Matrix &A) * \see mode(const Matrix &A) */ template T median (const Matrix &A) { Matrix temp(A); uint n = temp.size(); sort(temp.begin(), temp.end()); if (n % 2 == 0) return ((temp[n / 2] + temp[n / 2 - 1]) / 2); else return temp[(uint) ::floor(n / 2)]; } /* Calculate the median of each column of a matrix */ /*! * \brief Calculate the median of each column a Matrix * * This function calculates the median of each column of a matrix by first * sorting the elements and locating the middle in a single column, and then * looping over all columns. * * \param A The matrix whose medians are of interest. * * \see median(const Matrix &A) * \see meanc(const Matrix &A) * \see modec(const Matrix &A) */ SCYTHE_STATMETH_COL(median) /* Calculate the mode of a matrix */ /*! * \brief Calculate the mode of a Matrix * * This function calculates the mode of a matrix by determining which value of * the matrix occurs with the highest frequency. * * \param A The matrix whose mode is of interest. * * \see modec(const Matrix &A) * \see mean(const Matrix &A) * \see median(const Matrix &A) */ template T mode (const Matrix &A) { Matrix temp(A); sort(temp.begin(), temp.end()); T last = temp[0]; uint cnt = 1; T cur_max = temp[0]; uint max_cnt = 1; for (uint i = 1; i < temp.size(); ++i) { if (last == temp[i]) { ++cnt; } else { last = temp[i]; cnt = 1; } if (cnt > max_cnt) { max_cnt = cnt; cur_max = temp[i]; } } return cur_max; } /*! * \brief Calculate the mode of the columns of a Matrix * * This function calculates the mode of the columns of a matrix by * determining which value in a single column of the matrix occurs * most frequently, and then looping over all columns. * * \param A The matrix whose modes are of interest. * * \see mode(const Matrix &A) * \see meanc(const Matrix &A) * \see medianc(const Matrix &A) */ SCYTHE_STATMETH_COL(mode) /* Calculate the variance of a Matrix */ /* A functor that encapsulates a single variance calculation step. * Also used by skew and kurtosis. */ namespace { template struct var_step : std::binary_function { T constant_; T2 divisor_; T exponent_; var_step (T c, T2 d, T e) : constant_ (c), divisor_ (d), exponent_ (e) {} T operator() (T last, T x) const { return (last + std::pow(constant_ - x, exponent_) / divisor_); } }; } /*! * \brief Calculate the variance of a Matrix * * This function calculates the variance of a matrix. * * \param A The matrix whose variance is of interest. * * \see var(cons Matrix &A, T mu) * \see varc(const Matrix &A) * \see sd(const Matrix &A) * \see mean(const Matrix &A) */ template T var (const Matrix &A) { return var(A, mean(A)); } /* Calculate the variances of each column of a Matrix. */ /*! * \brief Calculate the variance of each column of a Matrix * * This function calculates the variance of each column of a matrix. * * \param A The matrix whose variances are of interest. * * \see var(const Matrix &A) * \see var(cons Matrix &A, T mu) * \see sdc(const Matrix &A) * \see meanc(const Matrix &A) */ SCYTHE_STATMETH_COL(var) /*! * \brief Calculate the variance of a Matrix * * This function calculates the variance of a matrix when the mean is * already known. * * \param A The matrix whose variance is of interest. * \param mu The mean of the values in the matrix. * * \see var(cons Matrix &A) * \see varc(const Matrix &A) * \see sd(const Matrix &A) * \see mean(const Matrix &A) */ template T var (const Matrix &A, T mu) { return std::accumulate(A.begin_f(), A.end_f(), (T) 0, var_step (mu, A.size() - 1, 2)); } /* Calculate the standard deviation of a Matrix (not std cause of namespace std:: */ /*! * \brief Calculate the standard deviation of a Matrix * * This function calculates the standard deviation of a matrix by * taking the square root of the matrix's variance. * * \param A The matrix whose standard deviation is of interest. * * \see sd(const Matrix &A) * \see variance(const Matrix &A) */ template T sd (const Matrix &A) { return std::sqrt(var(A)); } /* Calculate the standard deviation of each column of a Matrix */ /*! * \brief Calculate the standard deviation of each column of a Matrix * * This function calculates the standard deviation of each column of a matrix by * taking the square root of each column's variance. * * \param A The matrix whose standard deviations are of interest. * * \see sd(const Matrix &A) * \see variancec(const Matrix &A) */ SCYTHE_STATMETH_COL(sd) /*! * \brief Calculate the standard deviation of a Matrix * * This function calculates the standard deviation of a matrix * when the matrix's mean is already known. * * \param A The matrix whose standard deviation is of interest. * \param mu The matrix mean. * * \see sd(const Matrix &A) * \see variance(const Matrix &A) */ template T sd (const Matrix &A, T mu) { return std::sqrt(var(A, mu)); } /* Calculate the skew of a Matrix */ /*! * \brief Calculate the skew of a Matrix * * This function calculates the skew of a matrix. * * \param A The matrix whose skew is of interest. * * \see skewc(const Matrix &A) * \see kurtosis(const Matrix &A) */ template T skew (const Matrix &A) { T mu = mean(A); T sde = sd(A, mu); return std::accumulate(A.begin_f(), A.end_f(), (T) 0, var_step (mu, A.size() * std::pow(sde, 3), 3)); } /* Calculate the skew of each column of a Matrix. */ /*! * \brief Calculate the skew of each column of a Matrix * * This function calculates the skew of each column of a matrix. * * \param A The matrix whose skews are of interest. * * \see skew(const Matrix &A) * \see kurtosisc(const Matrix &A) */ SCYTHE_STATMETH_COL(skew) /* Calculate the kurtosis of a Matrix */ /*! * \brief Calculate the kurtosis of a Matrix * * This function calculates the kurtosis of a matrix. * * \param A The matrix whose kurtosis is of interest. * * \see skew(const Matrix &A) * \see kurtosisc(const Matrix &A) */ template T kurtosis (const Matrix &A) { T mu = mean(A); T sde = sd(A, mu); return (std::accumulate(A.begin_f(), A.end_f(), (T) 0, var_step (mu, A.size() * std::pow(sde, 4), 4)) - 3); } /* Calculate the kurtosis of each column of a Matrix. */ /*! * \brief Calculate the kurtosis of each column of a Matrix * * This function calculates the kurtosis of each column of a matrix. * * \param A The matrix whose kurtoses are of interest. * * \see skewc(const Matrix &A) * \see kurtosis(const Matrix &A) */ SCYTHE_STATMETH_COL(kurtosis) /* Calculates the maximum element in a Matrix */ /*! * \brief Calculate the maximum element in a Matrix * * This function identifies the maximum element in a matrix. * * \param A The matrix whose maximum element is of interest. * * \see min(const Matrix &A) * \see maxc (const Matrix &A) */ template T max (const Matrix &A) { return *(max_element(A.begin_f(), A.end_f())); } /*! * \brief Calculate the maximum of each column of a Matrix * * This function identifies the maximum of each column in a matrix. * * \param A The matrix whose maximae are of interest. * * \see max(const Matrix &A) * \see minc(const Matrix &A) */ SCYTHE_STATMETH_COL(max) /* Calculates the minimum element in a Matrix */ /*! * \brief Calculate the maximum element in a Matrix * * This function identifies the maximum element in a matrix. * * \param A The matrix whose maximum element is of interest. * * \see max(const Matrix &A) * \see minc(const Matrix &A) */ template T min (const Matrix &A) { return *(min_element(A.begin_f(), A.end_f())); } /*! * \brief Calculate the minimum of each column of a Matrix * * This function identifies the minimum of each column in a matrix. * * \param A The matrix whose minimae are of interest. * * \see min(const Matrix &A) * \see maxc(const Matrix &A) */ SCYTHE_STATMETH_COL(min) /* Find the index of the max element */ /*! * \brief Calculate the index of the maximum element in a Matrix * * This function identifies the index of the maximum element in a matrix. * * \param A The matrix whose maximum element indices are of interest. * * \see minind(const Matrix &A) * \see max(const Matrix &A) * \see maxindc(const Matrix &A) */ template unsigned int maxind (const Matrix &A) { return (max_element(A.begin_f(), A.end_f())).get_index(); } /*! * \brief Calculate the index of the maximum for each column of a Matrix * * This function identifies the index of the maximum for each column of a Matrix. * * \param A The matrix whose maximum indices are of interest. * * \see maxc(const Matrix &A) * \see minindc(const Matrix &A) */ SCYTHE_STATMETH_COL(maxind) /* Find the index of the min element */ /*! * \brief Calculate the index of the minimum element in a Matrix * * This function identifies the index of the minimum element in a matrix. * * \param A The matrix whose minimum element indices are of interest. * * \see maxind(const Matrix &A) * \see min(const Matrix &A) * \see minindc(const Matrix &A) */ template unsigned int minind (const Matrix &A) { return (min_element(A.begin_f(), A.end_f())).get_index(); } /*! * \brief Calculate the index of the minimum for each column of a Matrix * * This function identifies the index of the minimum for each column of a Matrix. * * \param A The matrix whose minimum indices are of interest. * * \see minc(const Matrix &A) * \see maxindc(const Matrix &A) */ SCYTHE_STATMETH_COL(minind) } // end namespace scythe #endif /* SCYTHE_STAT_H */ scythestat-1.0.3/scythestat/lapack.h0000644000175000017500000001202711550656101014430 00000000000000/* * Scythe Statistical Library Copyright (C) 2000-2002 Andrew D. Martin * and Kevin M. Quinn; 2002-present Andrew D. Martin, Kevin M. Quinn, * and Daniel Pemstein. All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify under the terms of the GNU General Public License as * published by Free Software Foundation; either version 2 of the * License, or (at your option) any later version. See the text files * COPYING and LICENSE, distributed with this source code, for further * information. * -------------------------------------------------------------------- * scythe/lapack.h * */ /*! * \file lapack.h * \brief Definitions that provide access to LAPACK/BLAS fortran * routines for internal library functions. * * This file provides function definitions that help provide * LAPACK/BLAS support to Scythe functions. These definitions are not * part of Scythe's public interface and are used exclusively from * within the library. * */ #ifndef SCYTHE_LAPACK_H #define SCYTHE_LAPACK_H #ifdef SCYTHE_COMPILE_DIRECT #endif namespace scythe { namespace lapack { inline void make_symmetric(double* matrix, int rows) { for (int i = 1; i < rows; ++i) for (int j = 0; j < i; ++j) matrix[i * rows + j] = matrix[j * rows + i]; } extern "C" { /* Matrix multiplication and gaxpy */ void dgemm_ (char* transa, char* transb, const int* m, const int* n, const int* k, const double* alpha, const double* a, const int* lda, const double* b, const int* ldb, const double* beta, double* c, const int* ldc); /* Matrix cross product A'A */ void dsyrk_(const char* uplo, const char* trans, const int* n, const int* k, const double* alpha, const double* a, const int* lda, const double* beta, double* c, const int* ldc); /* LU decomposition */ void dgetrf_ (const int* rows, const int* cols, double* a, const int* lda, int* ipiv, int *info); /* General inversion (given LU decomposion)*/ void dgetri_ (const int* n, double* a, const int* lda, const int* ipiv, double* work, const int* lwork, int* info); /* Cholesky decomposition */ void dpotrf_(const char* uplo, const int* n, double* a, const int* lda, int* info); /* chol_solve give cholesky */ void dpotrs_ (const char* uplo, const int* n, const int* nrhs, const double* a, const int* lda, double *b, const int* ldb, int* info); /* chol_solve from A and b */ void dposv_ (const char* uplo, const int* n, const int* nrhs, double* a, const int* lda, double* b, const int* ldb, int* info); /* Positive Definite Inversion (given LU decomposition) */ void dpotri_(const char* uplo, const int* n, double* a, const int* lda, int* info); /* Eigenvalues/vectors for general (nonsymmetric) square matrices */ void dgeev_(const char* jobvl, const char* jobvr, const int* n, double* a, const int* lda, double* wr, double* wi, double* vl, const int* ldvl, double* vr, const int* ldvr, double* work, const int* lwork, int* info); /* Eigenvalues/vectors for symmetric matrices */ void dsyevr_ (const char* jobz, const char* range, const char* uplo, const int* n, double* a, const int* lda, double* vl, double* vu, const int* il, const int* iu, const double* abstol, const int* m, double* w, double* z, const int* ldz, int* isuppz, double* work, int* lwork, int* iwork, const int* liwork, int* info); /* QR decomposition */ void dgeqp3_ (const int* m, const int* n, double* a, const int* lda, int* jpvt, double* tau, double* work, const int* lwork, int* info); /* QR solve routines */ void dormqr_ (const char* side, const char* trans, const int* m, const int* n, const int* k, const double* a, const int* lda, const double* tau, double* c, const int* ldc, double* work, const int* lwork, int* info); void dtrtrs_ (const char* uplo, const char* trans, const char* diag, const int* n, const int* nrhs, const double* a, const int* lda, double* b, const int* ldb, int* info); /* SVD */ void dgesdd_ (const char* jobz, const int* m, const int* n, double* a, const int* lda, double* s, double* u, const int* ldu, double* vt, const int* ldvt, double* work, const int* lwork, int* iwork, int* info); } // end extern } // end namespace lapack } // end namespace scythe #endif /* SCYTHE_LAPACK_H */ scythestat-1.0.3/scythestat/Makefile.in0000644000175000017500000004624011766141014015076 00000000000000# Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = scythestat DIST_COMMON = $(pkginclude_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ install-html-recursive install-info-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkgincludedir)" HEADERS = $(pkginclude_HEADERS) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ distdir ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ DX_CONFIG = @DX_CONFIG@ DX_DOCDIR = @DX_DOCDIR@ DX_DOT = @DX_DOT@ DX_DOXYGEN = @DX_DOXYGEN@ DX_DVIPS = @DX_DVIPS@ DX_EGREP = @DX_EGREP@ DX_ENV = @DX_ENV@ DX_FLAG_chi = @DX_FLAG_chi@ DX_FLAG_chm = @DX_FLAG_chm@ DX_FLAG_doc = @DX_FLAG_doc@ DX_FLAG_dot = @DX_FLAG_dot@ DX_FLAG_html = @DX_FLAG_html@ DX_FLAG_man = @DX_FLAG_man@ DX_FLAG_pdf = @DX_FLAG_pdf@ DX_FLAG_ps = @DX_FLAG_ps@ DX_FLAG_rtf = @DX_FLAG_rtf@ DX_FLAG_xml = @DX_FLAG_xml@ DX_HHC = @DX_HHC@ DX_LATEX = @DX_LATEX@ DX_MAKEINDEX = @DX_MAKEINDEX@ DX_PDFLATEX = @DX_PDFLATEX@ DX_PERL = @DX_PERL@ DX_PROJECT = @DX_PROJECT@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EXEEXT = @EXEEXT@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ VERSION_INFO = @VERSION_INFO@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CXX = @ac_ct_CXX@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = rng INCLUDES = -I@top_srcdir@/ pkginclude_HEADERS = \ algorithm.h \ datablock.h \ defs.h \ distributions.h \ error.h \ ide.h \ la.h \ lapack.h \ matrix.h \ matrix_bidirectional_iterator.h \ matrix_forward_iterator.h \ matrix_random_access_iterator.h \ optimize.h \ rng.h \ smath.h \ stat.h all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu scythestat/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu scythestat/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkgincludeHEADERS: $(pkginclude_HEADERS) @$(NORMAL_INSTALL) test -z "$(pkgincludedir)" || $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)" @list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(pkgincludedir)'"; \ $(INSTALL_HEADER) $$files "$(DESTDIR)$(pkgincludedir)" || exit $$?; \ done uninstall-pkgincludeHEADERS: @$(NORMAL_UNINSTALL) @list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(pkgincludedir)'; $(am__uninstall_files_from_dir) # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile $(HEADERS) installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(pkgincludedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic mostlyclean-am distclean: distclean-recursive -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-pkgincludeHEADERS install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-pkgincludeHEADERS .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ install-am install-strip tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am check check-am clean clean-generic ctags \ ctags-recursive distclean distclean-generic distclean-tags \ distdir dvi dvi-am html html-am info info-am install \ install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-pkgincludeHEADERS \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs installdirs-am maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ uninstall-pkgincludeHEADERS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: scythestat-1.0.3/scythestat/Makefile.am0000644000175000017500000000047611550656101015065 00000000000000SUBDIRS = rng INCLUDES = -I@top_srcdir@/ pkginclude_HEADERS = \ algorithm.h \ datablock.h \ defs.h \ distributions.h \ error.h \ ide.h \ la.h \ lapack.h \ matrix.h \ matrix_bidirectional_iterator.h \ matrix_forward_iterator.h \ matrix_random_access_iterator.h \ optimize.h \ rng.h \ smath.h \ stat.h scythestat-1.0.3/scythestat/matrix_forward_iterator.h0000644000175000017500000003020311550656101020132 00000000000000/* * Scythe Statistical Library Copyright (C) 2000-2002 Andrew D. Martin * and Kevin M. Quinn; 2002-present Andrew D. Martin, Kevin M. Quinn, * and Daniel Pemstein. All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify under the terms of the GNU General Public License as * published by Free Software Foundation; either version 2 of the * License, or (at your option) any later version. See the text files * COPYING and LICENSE, distributed with this source code, for further * information. * -------------------------------------------------------------------- * scythestat/matrix_forward_iterator.h * * Forward iterators for the matrix class. * */ /*! \file matrix_forward_iterator.h * \brief Definitions of STL-compliant forward iterators for the * Matrix class. * * Contains definitions of const_matrix_forward_iterator, * matrix_forward_iterator, and related operators. See a Standard * Template Library reference, such as Josuttis (1999), for a full * description of the capabilities of forward iterators. * * These iterators are templated on the type, order and style of the * Matrix they iterate over and their own order, which need not match * the iterated-over matrix. Same-order iteration over concrete * matrices is extremely fast. Cross-grain concrete and/or view * iteration is slower. */ #ifndef SCYTHE_MATRIX_FORWARD_ITERATOR_H #define SCYTHE_MATRIX_FORWARD_ITERATOR_H #include #ifdef SCYTHE_COMPILE_DIRECT #include "defs.h" #include "error.h" #include "matrix.h" #else #include "scythestat/defs.h" #include "scythestat/error.h" #include "scythestat/matrix.h" #endif namespace scythe { /* convenience typedefs */ namespace { // local to this file typedef unsigned int uint; } /* forward declaration of the matrix class */ template class Matrix; /*! \brief An STL-compliant const forward iterator for Matrix. * * Provides forward iteration over const Matrix objects. See * Josuttis (1999), or some other STL reference, for a full * description of the forward iterator interface. * * \see Matrix * \see matrix_forward_iterator * \see const_matrix_random_access_iterator * \see matrix_random_access_iterator * \see const_matrix_bidirectional_iterator * \see matrix_bidirectional_iterator */ template class const_matrix_forward_iterator : public std::iterator { public: /**** TYPEDEFS ***/ typedef const_matrix_forward_iterator self; /* These are a little formal, but useful */ typedef typename std::iterator_traits::value_type value_type; typedef typename std::iterator_traits::iterator_category iterator_category; typedef typename std::iterator_traits::difference_type difference_type; typedef typename std::iterator_traits::pointer pointer; typedef typename std::iterator_traits::reference reference; /**** CONSTRUCTORS ****/ /* Default constructor */ const_matrix_forward_iterator () {} /* Standard constructor */ const_matrix_forward_iterator (const Matrix &M) : pos_ (M.getArray()), matrix_ (&M) { SCYTHE_CHECK_30 (pos_ == 0, scythe_null_error, "Requesting iterator to NULL matrix"); /* The basic story is: when M_STYLE == Concrete and ORDER == * M_ORDER, we only need pos_ and iteration will be as fast as * possible. All other types of iteration need more variables * to keep track of things and are slower. */ if (M_STYLE != Concrete || M_ORDER != ORDER) { offset_ = 0; if (ORDER == Col) { lead_length_ = M.rows(); lead_inc_ = M.rowstride(); trail_inc_ = M.colstride(); } else { lead_length_ = M.cols(); lead_inc_ = M.colstride(); trail_inc_ = M.rowstride(); } jump_ = trail_inc_ + (1 - lead_length_) * lead_inc_; vend_ = pos_ + (lead_length_ - 1) * lead_inc_; } #if SCYTHE_DEBUG > 2 size_ = M.size(); start_ = pos_; #endif } /* Copy constructor */ const_matrix_forward_iterator (const self &mi) : pos_ (mi.pos_), matrix_ (mi.matrix_) { if (M_STYLE != Concrete || M_ORDER != ORDER) { offset_ = mi.offset_; lead_length_ = mi.lead_length_; lead_inc_ = mi.lead_inc_; trail_inc_ = mi.trail_inc_; vend_ = mi.vend_; jump_ = mi.jump_; } #if SCYTHE_DEBUG > 2 size_ = mi.size_; start_ = mi.start_; #endif } /**** EXTRA MODIFIER ****/ /* This function lets us grab an end iterator quickly, for both * concrete and view matrices. The view code is a bit of a * kludge, but it works. */ inline self& set_end () { if (M_STYLE == Concrete && ORDER == M_ORDER) { pos_ = matrix_->getArray() + matrix_->size(); } else { offset_ = matrix_->size(); } return *this; } /* Returns the current index (in logical matrix terms) of the * iterator. */ unsigned int get_index () const { return offset_; } /**** FORWARD ITERATOR FACILITIES ****/ inline self& operator= (const self& mi) { pos_ = mi.pos_; matrix_ = mi.matrix_; if (M_STYLE != Concrete || M_ORDER != ORDER) { offset_ = mi.offset_; lead_length_ = mi.lead_length_; lead_inc_ = mi.lead_inc_; trail_inc_ = mi.trail_inc_; vend_ = mi.vend_; jump_ = mi.jump_; } #if SCYTHE_DEBUG > 2 size_ = mi.size_; start_ = mi.start_; #endif return *this; } inline const reference operator* () const { SCYTHE_ITER_CHECK_BOUNDS(); return *pos_; } inline const pointer operator-> () const { SCYTHE_ITER_CHECK_BOUNDS(); return pos_; } inline self& operator++ () { if (M_STYLE == Concrete && ORDER == M_ORDER) ++pos_; else { if (pos_ == vend_) { vend_ += trail_inc_; pos_ += jump_; } else { pos_ += lead_inc_; } ++offset_; } return *this; } inline self operator++ (int) { self tmp = *this; ++(*this); return tmp; } /* == is only defined for iterators of the same template type * that point to the same matrix. Behavior for any other * comparison is undefined. * * Note that we have to be careful about iterator comparisons * when working with views and cross-grain iterators. * Specifically, we always have to rely on the offset value. * Obviously, with <> checks pos_ can jump all over the place in * cross-grain iterators, but also end iterators point to the * value after the last in the matrix. In some cases, the * equation in += and -= will actually put pos_ inside the * matrix (often in an early position) in this case. */ inline bool operator== (const self& x) const { if (M_STYLE == Concrete && ORDER == M_ORDER) { return pos_ == x.pos_; } else { return offset_ == x.offset_; } } /* Again, != is only officially defined for iterators over the * same matrix although the test will be trivially true for * matrices that don't view the same data, by implementation. */ inline bool operator!= (const self &x) const { return !(*this == x); } protected: /**** INSTANCE VARIABLES ****/ T_type* pos_; // pointer to current position in array T_type *vend_; // pointer to end of current vector uint offset_; // logical offset into matrix // TODO Some of these can probably be uints int lead_length_; // Logical length of leading dimension int lead_inc_; // Memory distance between vectors in ldim int trail_inc_; // Memory distance between vectors in tdim int jump_; // Memory distance between end of one ldim vector and // begin of next // Pointer to the matrix we're iterating over. This is really // only needed to get variables necessary to set the end. // TODO Handle this more cleanly. const Matrix* matrix_; // Size variable for range checking #if SCYTHE_DEBUG > 2 uint size_; // Logical matrix size T_type* start_; // Not normally needed, but used for bound check #endif }; /*! \brief An STL-compliant forward iterator for Matrix. * * Provides forward iteration over Matrix objects. See * Josuttis (1999), or some other STL reference, for a full * description of the forward iterator interface. * * \see Matrix * \see const_matrix_forward_iterator * \see const_matrix_random_access_iterator * \see matrix_random_access_iterator * \see const_matrix_bidirectional_iterator * \see matrix_bidirectional_iterator */ template class matrix_forward_iterator : public const_matrix_forward_iterator { /**** TYPEDEFS ***/ typedef matrix_forward_iterator self; typedef const_matrix_forward_iterator Base; public: /* These are a little formal, but useful */ typedef typename std::iterator_traits::value_type value_type; typedef typename std::iterator_traits::iterator_category iterator_category; typedef typename std::iterator_traits::difference_type difference_type; typedef typename std::iterator_traits::pointer pointer; typedef typename std::iterator_traits::reference reference; /**** CONSTRUCTORS ****/ /* Default constructor */ matrix_forward_iterator () : Base () {} /* Standard constructor */ matrix_forward_iterator (const Matrix &M) : Base(M) {} /* Copy constructor */ matrix_forward_iterator (const self &mi) : Base (mi) {} /**** EXTRA MODIFIER ****/ inline self& set_end () { Base::set_end(); return *this; } /**** FORWARD ITERATOR FACILITIES ****/ /* We have to override a lot of these to get return values * right.*/ inline self& operator= (const self& mi) { pos_ = mi.pos_; matrix_ = mi.matrix_; if (M_STYLE != Concrete || M_ORDER != ORDER) { offset_ = mi.offset_; lead_length_ = mi.lead_length_; lead_inc_ = mi.lead_inc_; trail_inc_ = mi.trail_inc_; vend_ = mi.vend_; jump_ = mi.jump_; } #if SCYTHE_DEBUG > 2 size_ = mi.size_; start_ = mi.start_; #endif return *this; } inline reference operator* () const { SCYTHE_ITER_CHECK_BOUNDS(); return *pos_; } inline pointer operator-> () const { SCYTHE_ITER_CHECK_BOUNDS(); return pos_; } inline self& operator++ () { Base::operator++(); return *this; } inline self operator++ (int) { self tmp = *this; ++(*this); return tmp; } private: /* Get handles to base members. It boggles the mind */ using Base::pos_; using Base::vend_; using Base::offset_; using Base::lead_length_; using Base::lead_inc_; using Base::trail_inc_; using Base::jump_; using Base::matrix_; #if SCYTHE_DEBUG > 2 using Base::size_; using Base::start_; #endif }; } // namespace scythe #endif /* SCYTHE_MATRIX_ITERATOR_H */ scythestat-1.0.3/INSTALL0000644000175000017500000000136111765734372011700 00000000000000Scythe installs as header-only C++ library. Users who do not wish to install Scythe in this way may also compile the Scythe sources directly into their applications using the SCYTHE_COMPILE_DIRECT preprocessor flag. To install in the default system library folder (typicaly /usr/local/lib). In the current directory, execute the commands (assuming you have root write privelages): $ ./configure $ make install To install in a local library folder (e.g. /home/myhome/lib). In the current directory, execute the commands: $ ./configure --prefix=/home/myhome $ make install Make sure /home/myhome/lib is in your include path or compile with -I/home/myhome/lib when installing in a local folder. Scythe requires gcc 4.4.7 or greater to compile. scythestat-1.0.3/LICENSE0000644000175000017500000000210111765734415011643 00000000000000Scythe Statistical Library Copyright (C) 2000-2002 Andrew D. Martin and Kevin M. Quinn; 2002-2012 Andrew D. Martin, Kevin M. Quinn, and Daniel Pemstein. All Rights Reserved. This program is free software; you can redistribute it and/or modify under the terms of the GNU General Public License as published by Free Software Foundation; either version 3 of the License, or (at your option) any later version. A copy of this license is included with this library (in the COPYING text file in this directory). This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. This library uses code from a number of other open source projects. Specific copyright information is provided alongside the applicable code. scythestat-1.0.3/ChangeLog0000644000175000017500000000477211766134471012425 00000000000000Version 1.0 * Major release. Change log starts here. Version 1.0.1 * Fixed missing la.h include in rng.h. This allows rwish method to compile. Version 1.0.2 * Added LAPACK wrapper for LU decomposition. * Added QR decomposition for concrete col-major matrices using LAPACK. * Added equation solving via QR decomposition for concrete col-major matrices using LAPACK. * Added singular value decomposition for concrete col-major matrices using LAPACK. * Added eigenvalue/vector decomposition for symmetric concrete col-major matrices using LAPACK. * Added wrapped_generator class to allow use of external pseudo-random uniform number generators with rng.h. * Provided support for plain rectangular files in matrix file constructor. * Added scythe_lapack_internal_error exception type. * Changed SetPackageSeed return type in lecuyer.h for mcmcpack compatibility. * Added return type to GetState in lecuyer.h. * Added missing std prefixes in distributions.h. * Fixed bugs in lndmvn in distributions.h. * Fixed rgamma documentation to indicate it takes shape and rate, not shape and scale. * Fixed some typos in error checks in ide.h. * Changed __PRETTY_FUNCTION__ to __func__ for standards compliance. * Made a number of functions inline for mcmcpack compatibility. Version 1.0.3 * Removed extra semi-colons in stat.h macro calls. * Changed else if to else in rgamma (rng.h) to eliminate warning. * Changed error level of symmetry check in vech (la.h) to match docs. * Fixed typo in vech (la.h) doc. * Added missing std prefix to sqrt in xpnd (la.h). * Changed A = A + .. to A += ... in rwish. * Made Matrix::save() const. * Added generalized eigenvalue support (experimental and undocumented). * Added inlines to lapack wrappers for mcmcpack support. * Fixed bugs in median and mode functions that, erroneously, modified matrix views passed to those methods in place. * Added an asScalar() method to the matrix class. * Updated datablock.h for thread safety with pthreads when SCYTHE_PTHREAD compiler flag enabled. * Fixed bug in rdirich. * Fixed subtle string bug in scythe_exception::what() * Various standards compliance fixes. * Updated triangularity checks to ensure square. * Fixed SCYTHE_DEBUG_LEVEL typo on doc intro page. * Added SCYTHE_RPACK flag and some R compatibility code for printing warnings and errors, and aborting from C++ back into R. * Updated the documentation into to fix some typos, add some context, and to reflect new preprocessor flags. * Moved to GNU GPL v3. scythestat-1.0.3/acinclude.m40000644000175000017500000002622511765737316013047 00000000000000# This file is part of Autoconf. -*- Autoconf -*- # Copyright (C) 2003 Oren Ben-Kiki # This file is distributed under the same terms as the Autoconf macro files. # Generate automatic documentation using Doxygen. Works in concert with the # aminclude.m4 file and a compatible doxygen configuration file. Defines the # following public macros: # # DX_???_FEATURE(ON|OFF) - control the default setting fo a Doxygen feature. # Supported features are 'DOXYGEN' itself, 'DOT' for generating graphics, # 'HTML' for plain HTML, 'CHM' for compressed HTML help (for MS users), 'CHI' # for generating a seperate .chi file by the .chm file, and 'MAN', 'RTF', # 'XML', 'PDF' and 'PS' for the appropriate output formats. The environment # variable DOXYGEN_PAPER_SIZE may be specified to override the default 'a4wide' # paper size. # # By default, HTML, PDF and PS documentation is generated as this seems to be # the most popular and portable combination. MAN pages created by Doxygen are # usually problematic, though by picking an appropriate subset and doing some # massaging they might be better than nothing. CHM and RTF are specific for MS # (note that you can't generate both HTML and CHM at the same time). The XML is # rather useless unless you apply specialized post-processing to it. # # The macro mainly controls the default state of the feature. The use can # override the default by specifying --enable or --disable. The macros ensure # that contradictory flags are not given (e.g., --enable-doxygen-html and # --enable-doxygen-chm, --enable-doxygen-anything with --disable-doxygen, etc.) # Finally, each feature will be automatically disabled (with a warning) if the # required programs are missing. # # Once all the feature defaults have been specified, call DX_INIT_DOXYGEN with # the following parameters: a one-word name for the project for use as a # filename base etc., an optional configuration file name (the default is # 'Doxyfile', the same as Doxygen's default), and an optional output directory # name (the default is 'doc'). ## ----------## ## Defaults. ## ## ----------## DX_ENV="" AC_DEFUN(DX_FEATURE_doc, ON) AC_DEFUN(DX_FEATURE_dot, ON) AC_DEFUN(DX_FEATURE_man, OFF) AC_DEFUN(DX_FEATURE_html, ON) AC_DEFUN(DX_FEATURE_chm, OFF) AC_DEFUN(DX_FEATURE_chi, OFF) AC_DEFUN(DX_FEATURE_rtf, OFF) AC_DEFUN(DX_FEATURE_xml, OFF) AC_DEFUN(DX_FEATURE_pdf, ON) AC_DEFUN(DX_FEATURE_ps, ON) ## --------------- ## ## Private macros. ## ## --------------- ## # DX_ENV_APPEND(VARIABLE, VALUE) # ------------------------------ # Append VARIABLE="VALUE" to DX_ENV for invoking doxygen. AC_DEFUN([DX_ENV_APPEND], [AC_SUBST([DX_ENV], ["$DX_ENV $1='$2'"])]) # DX_DIRNAME_EXPR # --------------- # Expand into a shell expression prints the directory part of a path. AC_DEFUN([DX_DIRNAME_EXPR], [[expr ".$1" : '\(\.\)[^/]*$' \| "x$1" : 'x\(.*\)/[^/]*$']]) # DX_IF_FEATURE(FEATURE, IF-ON, IF-OFF) # ------------------------------------- # Expands according to the M4 (static) status of the feature. AC_DEFUN([DX_IF_FEATURE], [ifelse(DX_FEATURE_$1, ON, [$2], [$3])]) # DX_REQUIRE_PROG(VARIABLE, PROGRAM) # ---------------------------------- # Require the specified program to be found for the DX_CURRENT_FEATURE to work. AC_DEFUN([DX_REQUIRE_PROG], [ AC_PATH_TOOL([$1], [$2]) if test "$[DX_FLAG_]DX_CURRENT_FEATURE$$1" = 1; then AC_MSG_WARN([$2 not found - will not DX_CURRENT_DESCRIPTION]) AC_SUBST([DX_FLAG_]DX_CURRENT_FEATURE, 0) fi ]) # DX_TEST_FEATURE(FEATURE) # ------------------------ # Expand to a shell expression testing whether the feature is active. AC_DEFUN([DX_TEST_FEATURE], [test "$DX_FLAG_$1" = 1]) # DX_CHECK_DEPEND(REQUIRED_FEATURE, REQUIRED_STATE) # ------------------------------------------------- # Verify that a required features has the right state before trying to turn on # the DX_CURRENT_FEATURE. AC_DEFUN([DX_CHECK_DEPEND], [ test "$DX_FLAG_$1" = "$2" \ || AC_MSG_ERROR([doxygen-DX_CURRENT_FEATURE ifelse([$2], 1, requires, contradicts) doxygen-DX_CURRENT_FEATURE]) ]) # DX_CLEAR_DEPEND(FEATURE, REQUIRED_FEATURE, REQUIRED_STATE) # ---------------------------------------------------------- # Turn off the DX_CURRENT_FEATURE if the required feature is off. AC_DEFUN([DX_CLEAR_DEPEND], [ test "$DX_FLAG_$1" = "$2" || AC_SUBST([DX_FLAG_]DX_CURRENT_FEATURE, 0) ]) # DX_FEATURE_ARG(FEATURE, DESCRIPTION, # CHECK_DEPEND, CLEAR_DEPEND, # REQUIRE, DO-IF-ON, DO-IF-OFF) # -------------------------------------------- # Parse the command-line option controlling a feature. CHECK_DEPEND is called # if the user explicitly turns the feature on (and invokes DX_CHECK_DEPEND), # otherwise CLEAR_DEPEND is called to turn off the default state if a required # feature is disabled (using DX_CLEAR_DEPEND). REQUIRE performs additional # requirement tests (DX_REQUIRE_PROG). Finally, an automake flag is set and # DO-IF-ON or DO-IF-OFF are called according to the final state of the feature. AC_DEFUN([DX_ARG_ABLE], [ AC_DEFUN([DX_CURRENT_FEATURE], [$1]) AC_DEFUN([DX_CURRENT_DESCRIPTION], [$2]) AC_ARG_ENABLE(doxygen-$1, [AC_HELP_STRING(DX_IF_FEATURE([$1], [--disable-doxygen-$1], [--enable-doxygen-$1]), DX_IF_FEATURE([$1], [don't $2], [$2]))], [ case "$enableval" in #( y|Y|yes|Yes|YES) AC_SUBST([DX_FLAG_$1], 1) $3 ;; #( n|N|no|No|NO) AC_SUBST([DX_FLAG_$1], 0) ;; #( *) AC_MSG_ERROR([invalid value '$enableval' given to doxygen-$1]) ;; esac ], [ AC_SUBST([DX_FLAG_$1], [DX_IF_FEATURE([$1], 1, 0)]) $4 ]) if DX_TEST_FEATURE([$1]); then $5 : fi if DX_TEST_FEATURE([$1]); then AM_CONDITIONAL(DX_COND_$1, :) $6 : else AM_CONDITIONAL(DX_COND_$1, false) $7 : fi ]) ## -------------- ## ## Public macros. ## ## -------------- ## # DX_XXX_FEATURE(DEFAULT_STATE) # ----------------------------- AC_DEFUN([DX_DOXYGEN_FEATURE], [AC_DEFUN([DX_FEATURE_doc], [$1])]) AC_DEFUN([DX_MAN_FEATURE], [AC_DEFUN([DX_FEATURE_man], [$1])]) AC_DEFUN([DX_HTML_FEATURE], [AC_DEFUN([DX_FEATURE_html], [$1])]) AC_DEFUN([DX_CHM_FEATURE], [AC_DEFUN([DX_FEATURE_chm], [$1])]) AC_DEFUN([DX_CHI_FEATURE], [AC_DEFUN([DX_FEATURE_chi], [$1])]) AC_DEFUN([DX_RTF_FEATURE], [AC_DEFUN([DX_FEATURE_rtf], [$1])]) AC_DEFUN([DX_XML_FEATURE], [AC_DEFUN([DX_FEATURE_xml], [$1])]) AC_DEFUN([DX_XML_FEATURE], [AC_DEFUN([DX_FEATURE_xml], [$1])]) AC_DEFUN([DX_PDF_FEATURE], [AC_DEFUN([DX_FEATURE_pdf], [$1])]) AC_DEFUN([DX_PS_FEATURE], [AC_DEFUN([DX_FEATURE_ps], [$1])]) # DX_INIT_DOXYGEN(PROJECT, [CONFIG-FILE], [OUTPUT-DOC-DIR]) # --------------------------------------------------------- # PROJECT also serves as the base name for the documentation files. # The default CONFIG-FILE is "Doxyfile" and OUTPUT-DOC-DIR is "doc". AC_DEFUN([DX_INIT_DOXYGEN], [ # Files: AC_SUBST([DX_PROJECT], [$1]) AC_SUBST([DX_CONFIG], [ifelse([$2], [], Doxyfile, [$2])]) AC_SUBST([DX_DOCDIR], [ifelse([$3], [], doc, [$3])]) # Environment variables used inside doxygen.cfg: DX_ENV_APPEND(SRCDIR, $srcdir) DX_ENV_APPEND(PROJECT, $DX_PROJECT) DX_ENV_APPEND(DOCDIR, $DX_DOCDIR) DX_ENV_APPEND(VERSION, $PACKAGE_VERSION) # Doxygen itself: DX_ARG_ABLE(doc, [generate documentation], [], [], [DX_REQUIRE_PROG([DX_DOXYGEN], doxygen) DX_REQUIRE_PROG([DX_PERL], perl)], [DX_ENV_APPEND(PERL_PATH, $DX_PERL)]) # Dot for graphics: DX_ARG_ABLE(dot, [generate graphics for the documentation], [DX_CHECK_DEPEND(doc, 1)], [DX_CLEAR_DEPEND(doc, 1)], [DX_REQUIRE_PROG([DX_DOT], dot)], [DX_ENV_APPEND(HAVE_DOT, YES) DX_ENV_APPEND(DOT_PATH, [`DX_DIRNAME_EXPR($DX_DOT)`])], [DX_ENV_APPEND(HAVE_DOT, NO)]) # Man pages generation: DX_ARG_ABLE(man, [generate manual pages], [DX_CHECK_DEPEND(doc, 1)], [DX_CLEAR_DEPEND(doc, 1)], [], [DX_ENV_APPEND(GENERATE_MAN, YES)], [DX_ENV_APPEND(GENERATE_MAN, NO)]) # RTF file generation: DX_ARG_ABLE(rtf, [generate RTF documentation], [DX_CHECK_DEPEND(doc, 1)], [DX_CLEAR_DEPEND(doc, 1)], [], [DX_ENV_APPEND(GENERATE_RTF, YES)], [DX_ENV_APPEND(GENERATE_RTF, NO)]) # XML file generation: DX_ARG_ABLE(xml, [generate XML documentation], [DX_CHECK_DEPEND(doc, 1)], [DX_CLEAR_DEPEND(doc, 1)], [], [DX_ENV_APPEND(GENERATE_XML, YES)], [DX_ENV_APPEND(GENERATE_XML, NO)]) # (Compressed) HTML help generation: DX_ARG_ABLE(chm, [generate compressed HTML help documentation], [DX_CHECK_DEPEND(doc, 1)], [DX_CLEAR_DEPEND(doc, 1)], [DX_REQUIRE_PROG([DX_HHC], hhc)], [DX_ENV_APPEND(HHC_PATH, $DX_HHC) DX_ENV_APPEND(GENERATE_HTML, YES) DX_ENV_APPEND(GENERATE_HTMLHELP, YES)], [DX_ENV_APPEND(GENERATE_HTMLHELP, NO)]) # Seperate CHI file generation. DX_ARG_ABLE(chi, [generate seperate compressed HTML help index file], [DX_CHECK_DEPEND(chm, 1)], [DX_CLEAR_DEPEND(chm, 1)], [], [DX_ENV_APPEND(GENERATE_CHI, YES)], [DX_ENV_APPEND(GENERATE_CHI, NO)]) # Plain HTML pages generation: DX_ARG_ABLE(html, [generate plain HTML documentation], [DX_CHECK_DEPEND(doc, 1) DX_CHECK_DEPEND(chm, 0)], [DX_CLEAR_DEPEND(doc, 1) DX_CLEAR_DEPEND(chm, 0)], [], [DX_ENV_APPEND(GENERATE_HTML, YES)], [DX_TEST_FEATURE(chm) || DX_ENV_APPEND(GENERATE_HTML, NO)]) # PostScript file generation: DX_ARG_ABLE(ps, [generate PostScript documentation], [DX_CHECK_DEPEND(doc, 1)], [DX_CLEAR_DEPEND(doc, 1)], [DX_REQUIRE_PROG([DX_LATEX], latex) DX_REQUIRE_PROG([DX_MAKEINDEX], makeindex) DX_REQUIRE_PROG([DX_DVIPS], dvips) DX_REQUIRE_PROG([DX_EGREP], egrep)]) # PDF file generation: DX_ARG_ABLE(pdf, [generate PDF documentation], [DX_CHECK_DEPEND(doc, 1)], [DX_CLEAR_DEPEND(doc, 1)], [DX_REQUIRE_PROG([DX_PDFLATEX], pdflatex) DX_REQUIRE_PROG([DX_MAKEINDEX], makeindex) DX_REQUIRE_PROG([DX_EGREP], egrep)]) # LaTeX generation for PS and/or PDF: if DX_TEST_FEATURE(ps) || DX_TEST_FEATURE(pdf); then AM_CONDITIONAL(DX_COND_latex, :) DX_ENV_APPEND(GENERATE_LATEX, YES) else AM_CONDITIONAL(DX_COND_latex, false) DX_ENV_APPEND(GENERATE_LATEX, NO) fi # Paper size for PS and/or PDF: AC_ARG_VAR(DOXYGEN_PAPER_SIZE, [a4wide (default), a4, letter, legal or executive]) case "$DOXYGEN_PAPER_SIZE" in #( "") AC_SUBST(DOXYGEN_PAPER_SIZE, "") ;; #( a4wide|a4|letter|legal|executive) DX_ENV_APPEND(PAPER_SIZE, $DOXYGEN_PAPER_SIZE) ;; #( *) AC_MSG_ERROR([unknown DOXYGEN_PAPER_SIZE='$DOXYGEN_PAPER_SIZE']) ;; esac #For debugging: #echo DX_FLAG_doc=$DX_FLAG_doc #echo DX_FLAG_dot=$DX_FLAG_dot #echo DX_FLAG_man=$DX_FLAG_man #echo DX_FLAG_html=$DX_FLAG_html #echo DX_FLAG_chm=$DX_FLAG_chm #echo DX_FLAG_chi=$DX_FLAG_chi #echo DX_FLAG_rtf=$DX_FLAG_rtf #echo DX_FLAG_xml=$DX_FLAG_xml #echo DX_FLAG_pdf=$DX_FLAG_pdf #echo DX_FLAG_ps=$DX_FLAG_ps #echo DX_ENV=$DX_ENV ]) scythestat-1.0.3/README0000644000175000017500000000256611550656101011520 00000000000000Description The Scythe Statistical Library is an open source C++ library for statistical computation. It includes a suite of matrix manipulation functions, a suite of pseudo-random number generators, and a suite of numerical optimizers. Programs written using Scythe are generally much faster than those written in commonly used interpreted languages, such as R, Matlab, and GAUSS; and can be compiled on any system with the GNU GCC compiler (and perhaps with other C++ compilers). One of the primary design goals of the Scythe developers has been ease of use for non-expert C++ programmers. Ease of use is provided through three primary mechanisms: (1) operator and function over-loading, (2) numerous pre-fabricated utility functions, and (3) clear documentation and example programs. Additionally, Scythe is quite flexible and entirely extensible because the source code is available to all users. Scythe is distributed under the GNU General Public License, and has been thoroughly tested on Linux and MacOS X. Installation Scythe is typically installed as a header-only C++ library. The text file INSTALL, located in this directory, provides installation instructions. Documentation See http://scythe.wustl.edu License Scythe is free software. The text files COPYING and LICENSE, located in this directory, contain copyright and licensing details. scythestat-1.0.3/config/0000755000175000017500000000000011766141023012155 500000000000000scythestat-1.0.3/config/config.guess0000755000175000017500000012743211735414004014424 00000000000000#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011, 2012 Free Software Foundation, Inc. timestamp='2012-02-10' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Per Bothner. Please send patches (context # diff format) to and include a ChangeLog # entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm:riscos:*:*|arm:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; aarch64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-gnu else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-gnueabi else echo ${UNAME_MACHINE}-unknown-linux-gnueabihf fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-gnu exit ;; crisv32:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-gnu exit ;; frv:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; hexagon:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:Linux:*:*) LIBC=gnu eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __dietlibc__ LIBC=dietlibc #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` echo "${UNAME_MACHINE}-pc-linux-${LIBC}" exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; or32:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; padre:Linux:*:*) echo sparc-unknown-linux-gnu exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; x86_64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown case $UNAME_PROCESSOR in i386) eval $set_cc_for_build if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then UNAME_PROCESSOR="x86_64" fi fi ;; unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-?:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; x86_64:VMkernel:*:*) echo ${UNAME_MACHINE}-unknown-esx exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; c34*) echo c34-convex-bsd exit ;; c38*) echo c38-convex-bsd exit ;; c4*) echo c4-convex-bsd exit ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: scythestat-1.0.3/config/config.sub0000755000175000017500000010517611735414004014070 00000000000000#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011, 2012 Free Software Foundation, Inc. timestamp='2012-02-10' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . Submit a context # diff and a properly formatted GNU ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ | be32 | be64 \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | epiphany \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 \ | ns16k | ns32k \ | open8 \ | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown os=-none ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze) basic_machine=microblaze-xilinx ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i386-pc os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; nacl) basic_machine=le32-unknown os=-nacl ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tile*) basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -kaos*) os=-kaos ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -nacl*) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: scythestat-1.0.3/config/install-sh0000755000175000017500000003325611736361705014122 00000000000000#!/bin/sh # install - install a program, script, or datafile scriptversion=2011-01-19.21; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. nl=' ' IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} if test -z "$doit"; then doit_exec=exec else doit_exec=$doit fi # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_glob='?' initialize_posix_glob=' test "$posix_glob" != "?" || { if (set -f) 2>/dev/null; then posix_glob= else posix_glob=: fi } ' posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false no_target_directory= usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *' '* | *' '* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) dst_arg=$2 # Protect names problematic for `test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for `test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call `install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for `test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else # Prefer dirname, but fall back on a substitute if dirname fails. dstdir=` (dirname "$dst") 2>/dev/null || expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$dst" : 'X\(//\)[^/]' \| \ X"$dst" : 'X\(//\)$' \| \ X"$dst" : 'X\(/\)' \| . 2>/dev/null || echo X"$dst" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q' ` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 if (umask $mkdir_umask && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writeable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; [-=\(\)!]*) prefix='./';; *) prefix='';; esac eval "$initialize_posix_glob" oIFS=$IFS IFS=/ $posix_glob set -f set fnord $dstdir shift $posix_glob set +f IFS=$oIFS prefixes= for d do test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && eval "$initialize_posix_glob" && $posix_glob set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && $posix_glob set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: scythestat-1.0.3/config/missing0000755000175000017500000002415211736361705013510 00000000000000#! /bin/sh # Common stub for a few missing GNU programs while installing. scriptversion=2012-01-06.13; # UTC # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, # 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi run=: sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' sed_minuso='s/.* -o \([^ ]*\).*/\1/p' # In the cases where this matters, `missing' is being run in the # srcdir already. if test -f configure.ac; then configure_ac=configure.ac else configure_ac=configure.in fi msg="missing on your system" case $1 in --run) # Try to run requested program, and just exit if it succeeds. run= shift "$@" && exit 0 # Exit code 63 means version mismatch. This often happens # when the user try to use an ancient version of a tool on # a file that requires a minimum version. In this case we # we should proceed has if the program had been absent, or # if --run hadn't been passed. if test $? = 63; then run=: msg="probably too old" fi ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' autom4te touch the output file, or create a stub one automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file yacc create \`y.tab.[ch]', if possible, from existing .[ch] Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and \`g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; esac # normalize program name to check for. program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` # Now exit if we have it, but it failed. Also exit now if we # don't have it and --version was passed (most likely to detect # the program). This is about non-GNU programs, so use $1 not # $program. case $1 in lex*|yacc*) # Not GNU programs, they don't have --version. ;; *) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then # Could not run --version or --help. This is probably someone # running `$TOOL --version' or `$TOOL --help' to check whether # $TOOL exists and not knowing $TOOL uses missing. exit 1 fi ;; esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. case $program in aclocal*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acconfig.h' or \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` test -z "$files" && files="config.h" touch_files= for f in $files; do case $f in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; autom4te*) echo 1>&2 "\ WARNING: \`$1' is needed, but is $msg. You might have modified some files without having the proper tools for further handling them. You can get \`$1' as part of \`Autoconf' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo "#! /bin/sh" echo "# Created by GNU Automake missing as a replacement of" echo "# $ $@" echo "exit 0" chmod +x $file exit 1 fi ;; bison*|yacc*) echo 1>&2 "\ WARNING: \`$1' $msg. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if test $# -ne 1; then eval LASTARG=\${$#} case $LASTARG in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.h fi ;; esac fi if test ! -f y.tab.h; then echo >y.tab.h fi if test ! -f y.tab.c; then echo 'main() { return 0; }' >y.tab.c fi ;; lex*|flex*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if test $# -ne 1; then eval LASTARG=\${$#} case $LASTARG in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if test ! -f lex.yy.c; then echo 'main() { return 0; }' >lex.yy.c fi ;; help2man*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a dependency of a manual page. You may need the \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit $? fi ;; makeinfo*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." # The file to touch is that specified with -o ... file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -z "$file"; then # ... or it is the one specified with @setfilename ... infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n ' /^@setfilename/{ s/.* \([^ ]*\) *$/\1/ p q }' $infile` # ... or it is derived from the source name (dir/f.texi becomes f.info) test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info fi # If the file does not exist, the user really needs makeinfo; # let's fail without touching anything. test -f $file || exit 1 touch $file ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and is $msg. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequisites for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: scythestat-1.0.3/configure.ac0000644000175000017500000000352611766132036013130 00000000000000dnl init and sanity test AC_INIT(Scythe Statistical Library, 1.0.3, dpemstei@olemiss.edu, scythestat) AC_PREREQ([2.58]) AC_COPYRIGHT(GNU General Public License) AC_CONFIG_SRCDIR(scythestat/matrix.h) dnl Put all the autoconf mess in a a subdir AC_CONFIG_AUX_DIR(config) dnl AC_CONFIG_MACRO_DIR(m4) dnl What platform are we on AC_CANONICAL_TARGET([]) dnl Doxygen support: document this out when doing a make dist DX_HTML_FEATURE(ON) DX_CHM_FEATURE(OFF) DX_CHI_FEATURE(OFF) DX_MAN_FEATURE(OFF) DX_RTF_FEATURE(OFF) DX_XML_FEATURE(OFF) DX_PDF_FEATURE(OFF) DX_PS_FEATURE(OFF) DX_INIT_DOXYGEN(Scythe, doc/doxygen.conf) dnl initialize automake; ask for 1.7 or better AM_INIT_AUTOMAKE([$PACKAGE_TARNAME], [$PACKAGE_VERSION]) dnl scythestat_config.h macros, XXX should probably make a move to the dnl big leagues, but need to think about direct compilation first dnl AM_CONFIG_HEADER(config/config.h) dnl AX_PREFIX_CONFIG_H(scythestat/_config.h) dnl Set the library version number. This is different from dnl the Scythe package version number, and follows a strict dnl format. Violating this format may break programs that use dnl Scythe. dnl dnl CURRENT.REVISION.AGE dnl dnl CURRENT dnl Increment this number when the interface changes. dnl REVISION dnl Increment this number when the implementation changes dnl without changing the interface. Roll over to 0 on dnl CURRENT++ dnl AGE dnl The difference between the oldest and newest interfaces dnl that the library implements. If CURRENT=7 but the dnl library implements the (deprecated) 6, 5, and 4 level dnl interfaces, AGE=7-4=3 VERSION_INFO=1:3:0 AC_SUBST(VERSION_INFO) dnl Check for the C++ compiler and preprocessor AC_PROG_CXX AC_PROG_CXXCPP dnl Set the test language as C++ AC_LANG([C++]) AC_CONFIG_FILES([Makefile \ scythestat/Makefile \ scythestat/rng/Makefile]) dnl Output the files AC_OUTPUT scythestat-1.0.3/aminclude.am0000644000175000017500000001235611766133543013127 00000000000000# This file is part of Automake. -*- Automake -*- # Copyright (C) 2003 Oren Ben-Kiki # This file is distributed under the same terms as the Automake macro files. # Generate automatic documentation using Doxygen. Goals and variables values # are controlled by the various DX_COND_??? conditionals set by autoconf. # # The provided goals are: # # doxygen: generate all the documentation. Called via dist-hook. Calls: # doxygen-hook: do psot-doxygen processing. # doxygen-pdf: generate documentation in PDF format. # doxygen-ps: generate documentation in PostScript format. # # mostlyclean-doxygen: clean all tmp files. Called via mostlyclean. Calls: # mostlyclean-doxygen-chm: delete the uncompressed HTML files. # mostlyclean-doxygen-latex: delete the LaTeX source files for PS/PDF. # # clean-doxygen: remove all the documentation. Called via clean and # maintainer-clean. # # The following variables are set: # # DX_OUT_FILES = the generated document files (CHM, PS, PDF, XML, RTF). # DX_OUT_DIRS = the generated document directories (html, man). # # These may then be added to EXTRA_DIST etc. ## --------------------------------- ## ## Format-independent Doxygen rules. ## ## --------------------------------- ## if DX_COND_doc .PHONY: doxygen clean-doxygen mostlyclean-doxygen doxygen-hook dist-hook: doxygen doxygen: @DX_DOCDIR@/@PACKAGE@.tag doxygen-hook maintainer-clean: clean-doxygen distclean: clean-doxygen clean: clean-doxygen clean-doxygen: rm -rf @DX_DOCDIR@/html @DX_DOCDIR@/Scythe.tag mostlyclean: mostlyclean-doxygen @DX_DOCDIR@/@PACKAGE@.tag: $(DX_CONFIG) $(pkginclude_HEADERS) rm -rf @DX_DOCDIR@/html @DX_DOCDIR@/Scythe.tag $(DX_ENV) $(DX_DOXYGEN) $(srcdir)/$(DX_CONFIG) endif DX_COND_doc DX_OUT_FILES = DX_OUT_DIRS = ## ------------------------------- ## ## Rules specific for HTML output. ## ## ------------------------------- ## if DX_COND_html DX_OUT_FILES += @DX_DOCDIR@/@PACKAGE@.tag DX_OUT_DIRS += @DX_DOCDIR@/html @DX_DOCDIR@/html: @DX_DOCDIR@/@PACKAGE@.tag else !DX_COND_html # HTML is not generated, but tag file is. It is pretty useless by itself, but # is a convenient intermediate file to hand all the other goals on. .INTERMEDIATE: @DX_DOCDIR@/@PACKAGE@.tag MOSTLYCLEAN_FILES = @DX_DOCDIR@/@PACKAGE@.tag endif !DX_COND_html ## ------------------------------ ## ## Rules specific for CHM output. ## ## ------------------------------ ## if DX_COND_chm .PHONY: mostlyclean-doxygen-chm DX_OUT_FILES += @DX_DOCDIR@/@PACKAGE@.chm @DX_DOCDIR@/@PACKAGE@.chm: @DX_DOCDIR@/@PACKAGE@.tag if DX_COND_chi DX_OUT_FILES += @DX_DOCDIR@/@PACKAGE@.chi @DX_DOCDIR@/@PACKAGE@.chi: @DX_DOCDIR@/@PACKAGE@.tag endif DX_COND_chi mostlyclean-doxygen: mostlyclean-doxygen-chm mostlyclean-doxygen-chm: rm -rf @DX_DOCDIR@/html endif DX_COND_chm ## ------------------------------ ## ## Rules specific for MAN output. ## ## ------------------------------ ## if DX_COND_man DX_OUT_DIRS += @DX_DOCDIR@/man @DX_DOCDIR@/man: @DX_DOCDIR@/@PACKAGE@.tag endif DX_COND_man ## ----------------------------- ## ## Rules specific for PS output. ## ## ----------------------------- ## if DX_COND_ps .PHONY: doxygen-ps DX_OUT_FILES += @DX_DOCDIR@/@PACKAGE@.ps doxygen: doxygen-ps doxygen-ps: @DX_DOCDIR@/@PACKAGE@.ps @DX_DOCDIR@/@PACKAGE@.ps: @DX_DOCDIR@/@PACKAGE@.tag cd @DX_DOCDIR@/latex; \ rm -f *.aux *.toc *.idx *.ind *.ilg *.log *.out; \ $(DX_LATEX) refman.tex; \ $(MAKEINDEX_PATH) refman.idx; \ $(DX_LATEX) refman.tex; \ countdown=5; \ while $(DX_EGREP) 'Rerun (LaTeX|to get cross-references right)' \ refman.log > /dev/null 2>&1 \ && test $$countdown -gt 0; do \ $(DX_LATEX) refman.tex; \ countdown=`expr $$countdown - 1`; \ done; \ $(DX_DVIPS) -o ../@PACKAGE@.ps refman.dvi endif DX_COND_ps ## ------------------------------ ## ## Rules specific for PDF output. ## ## ------------------------------ ## if DX_COND_pdf .PHONY: doxygen-pdf DX_OUT_FILES += @DX_DOCDIR@/@PACKAGE@.pdf doxygen: doxygen-pdf doxygen-pdf: @DX_DOCDIR@/@PACKAGE@.pdf @DX_DOCDIR@/@PACKAGE@.pdf: @DX_DOCDIR@/@PACKAGE@.tag cd @DX_DOCDIR@/latex; \ rm -f *.aux *.toc *.idx *.ind *.ilg *.log *.out; \ $(DX_PDFLATEX) refman.tex; \ $(DX_MAKEINDEX) refman.idx; \ $(DX_PDFLATEX) refman.tex; \ countdown=5; \ while $(DX_EGREP) 'Rerun (LaTeX|to get cross-references right)' \ refman.log > /dev/null 2>&1 \ && test $$countdown -gt 0; do \ $(DX_PDFLATEX) refman.tex; \ countdown=`expr $$countdown - 1`; \ done; \ mv refman.pdf ../@PACKAGE@.pdf endif DX_COND_pdf ## ------------------------------------------------- ## ## Rules specific for LaTeX (shared for PS and PDF). ## ## ------------------------------------------------- ## if DX_COND_latex mostlyclean-doxygen: mostlyclean-doxygen-latex mostlyclean-doxygen-latex: rm -rf @DX_DOCDIR@/latex endif DX_COND_latex ## ------------------------------ ## ## Rules specific for RTF output. ## ## ------------------------------ ## if DX_COND_rtf DX_OUT_DIRS += @DX_DOCDIR@/rtf @DX_DOCDIR@/rtf: @DX_DOCDIR@/@PACKAGE@.tag endif DX_COND_rtf ## ------------------------------ ## ## Rules specific for XML output. ## ## ------------------------------ ## if DX_COND_xml DX_OUT_DIRS += @DX_DOCDIR@/xml @DX_DOCDIR@/xml: @DX_DOCDIR@/@PACKAGE@.tag endif DX_COND_xml scythestat-1.0.3/NEWS0000644000175000017500000000000011550656101011314 00000000000000scythestat-1.0.3/configure0000754000175000017500000055722611766141014012557 00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.68 for Scythe Statistical Library 1.0.3. # # Report bugs to . # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software # Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. # # GNU General Public License ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and $0: dpemstei@olemiss.edu about your system, including any $0: error possibly output before this message. Then install $0: a modern shell, or manually run the script under such a $0: shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='Scythe Statistical Library' PACKAGE_TARNAME='scythestat' PACKAGE_VERSION='1.0.3' PACKAGE_STRING='Scythe Statistical Library 1.0.3' PACKAGE_BUGREPORT='dpemstei@olemiss.edu' PACKAGE_URL='' ac_unique_file="scythestat/matrix.h" ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS CXXCPP am__fastdepCXX_FALSE am__fastdepCXX_TRUE CXXDEPMODE am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR OBJEXT EXEEXT ac_ct_CXX CPPFLAGS LDFLAGS CXXFLAGS CXX VERSION_INFO am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM DOXYGEN_PAPER_SIZE DX_COND_latex_FALSE DX_COND_latex_TRUE DX_COND_pdf_FALSE DX_COND_pdf_TRUE DX_PDFLATEX DX_FLAG_pdf DX_COND_ps_FALSE DX_COND_ps_TRUE DX_EGREP DX_DVIPS DX_MAKEINDEX DX_LATEX DX_FLAG_ps DX_COND_html_FALSE DX_COND_html_TRUE DX_FLAG_html DX_COND_chi_FALSE DX_COND_chi_TRUE DX_FLAG_chi DX_COND_chm_FALSE DX_COND_chm_TRUE DX_HHC DX_FLAG_chm DX_COND_xml_FALSE DX_COND_xml_TRUE DX_FLAG_xml DX_COND_rtf_FALSE DX_COND_rtf_TRUE DX_FLAG_rtf DX_COND_man_FALSE DX_COND_man_TRUE DX_FLAG_man DX_COND_dot_FALSE DX_COND_dot_TRUE DX_DOT DX_FLAG_dot DX_COND_doc_FALSE DX_COND_doc_TRUE DX_PERL DX_DOXYGEN DX_FLAG_doc DX_ENV DX_DOCDIR DX_CONFIG DX_PROJECT target_os target_vendor target_cpu target host_os host_vendor host_cpu host build_os build_vendor build_cpu build target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_doxygen_doc enable_doxygen_dot enable_doxygen_man enable_doxygen_rtf enable_doxygen_xml enable_doxygen_chm enable_doxygen_chi enable_doxygen_html enable_doxygen_ps enable_doxygen_pdf enable_dependency_tracking ' ac_precious_vars='build_alias host_alias target_alias DOXYGEN_PAPER_SIZE CXX CXXFLAGS LDFLAGS LIBS CPPFLAGS CCC CXXCPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures Scythe Statistical Library 1.0.3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/scythestat] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] --target=TARGET configure for building compilers for TARGET [HOST] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of Scythe Statistical Library 1.0.3:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --disable-doxygen-doc don't generate documentation --disable-doxygen-dot don't generate graphics for the documentation --enable-doxygen-man generate manual pages --enable-doxygen-rtf generate RTF documentation --enable-doxygen-xml generate XML documentation --enable-doxygen-chm generate compressed HTML help documentation --enable-doxygen-chi generate seperate compressed HTML help index file --disable-doxygen-html don't generate plain HTML documentation --enable-doxygen-ps generate PostScript documentation --enable-doxygen-pdf generate PDF documentation --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors Some influential environment variables: DOXYGEN_PAPER_SIZE a4wide (default), a4, letter, legal or executive CXX C++ compiler command CXXFLAGS C++ compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CXXCPP C++ preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF Scythe Statistical Library configure 1.0.3 generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. GNU General Public License _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_cxx_try_compile LINENO # ---------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile # ac_fn_cxx_try_cpp LINENO # ------------------------ # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_cpp cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by Scythe Statistical Library $as_me 1.0.3, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_aux_dir= for ac_dir in config "$srcdir"/config; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in config \"$srcdir\"/config" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 $as_echo_n "checking target system type... " >&6; } if ${ac_cv_target+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$target_alias" = x; then ac_cv_target=$ac_cv_host else ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5 $as_echo "$ac_cv_target" >&6; } case $ac_cv_target in *-*-*) ;; *) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;; esac target=$ac_cv_target ac_save_IFS=$IFS; IFS='-' set x $ac_cv_target shift target_cpu=$1 target_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: target_os=$* IFS=$ac_save_IFS case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac # The aliases save the names the user supplied, while $host etc. # will get canonicalized. test -n "$target_alias" && test "$program_prefix$program_suffix$program_transform_name" = \ NONENONEs,x,x, && program_prefix=${target_alias}- # Files: DX_PROJECT=Scythe DX_CONFIG=doc/doxygen.conf DX_DOCDIR=doc # Environment variables used inside doxygen.cfg: DX_ENV="$DX_ENV SRCDIR='$srcdir'" DX_ENV="$DX_ENV PROJECT='$DX_PROJECT'" DX_ENV="$DX_ENV DOCDIR='$DX_DOCDIR'" DX_ENV="$DX_ENV VERSION='$PACKAGE_VERSION'" # Doxygen itself: # Check whether --enable-doxygen-doc was given. if test "${enable_doxygen_doc+set}" = set; then : enableval=$enable_doxygen_doc; case "$enableval" in #( y|Y|yes|Yes|YES) DX_FLAG_doc=1 ;; #( n|N|no|No|NO) DX_FLAG_doc=0 ;; #( *) as_fn_error $? "invalid value '$enableval' given to doxygen-doc" "$LINENO" 5 ;; esac else DX_FLAG_doc=1 fi if test "$DX_FLAG_doc" = 1; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}doxygen", so it can be a program name with args. set dummy ${ac_tool_prefix}doxygen; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_DX_DOXYGEN+:} false; then : $as_echo_n "(cached) " >&6 else case $DX_DOXYGEN in [\\/]* | ?:[\\/]*) ac_cv_path_DX_DOXYGEN="$DX_DOXYGEN" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_DX_DOXYGEN="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi DX_DOXYGEN=$ac_cv_path_DX_DOXYGEN if test -n "$DX_DOXYGEN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DX_DOXYGEN" >&5 $as_echo "$DX_DOXYGEN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_DX_DOXYGEN"; then ac_pt_DX_DOXYGEN=$DX_DOXYGEN # Extract the first word of "doxygen", so it can be a program name with args. set dummy doxygen; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_DX_DOXYGEN+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_DX_DOXYGEN in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_DX_DOXYGEN="$ac_pt_DX_DOXYGEN" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_ac_pt_DX_DOXYGEN="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_DX_DOXYGEN=$ac_cv_path_ac_pt_DX_DOXYGEN if test -n "$ac_pt_DX_DOXYGEN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_DX_DOXYGEN" >&5 $as_echo "$ac_pt_DX_DOXYGEN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_DX_DOXYGEN" = x; then DX_DOXYGEN="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DX_DOXYGEN=$ac_pt_DX_DOXYGEN fi else DX_DOXYGEN="$ac_cv_path_DX_DOXYGEN" fi if test "$DX_FLAG_doc$DX_DOXYGEN" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: doxygen not found - will not generate documentation" >&5 $as_echo "$as_me: WARNING: doxygen not found - will not generate documentation" >&2;} DX_FLAG_doc=0 fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}perl", so it can be a program name with args. set dummy ${ac_tool_prefix}perl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_DX_PERL+:} false; then : $as_echo_n "(cached) " >&6 else case $DX_PERL in [\\/]* | ?:[\\/]*) ac_cv_path_DX_PERL="$DX_PERL" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_DX_PERL="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi DX_PERL=$ac_cv_path_DX_PERL if test -n "$DX_PERL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DX_PERL" >&5 $as_echo "$DX_PERL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_DX_PERL"; then ac_pt_DX_PERL=$DX_PERL # Extract the first word of "perl", so it can be a program name with args. set dummy perl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_DX_PERL+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_DX_PERL in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_DX_PERL="$ac_pt_DX_PERL" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_ac_pt_DX_PERL="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_DX_PERL=$ac_cv_path_ac_pt_DX_PERL if test -n "$ac_pt_DX_PERL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_DX_PERL" >&5 $as_echo "$ac_pt_DX_PERL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_DX_PERL" = x; then DX_PERL="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DX_PERL=$ac_pt_DX_PERL fi else DX_PERL="$ac_cv_path_DX_PERL" fi if test "$DX_FLAG_doc$DX_PERL" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: perl not found - will not generate documentation" >&5 $as_echo "$as_me: WARNING: perl not found - will not generate documentation" >&2;} DX_FLAG_doc=0 fi : fi if test "$DX_FLAG_doc" = 1; then if :; then DX_COND_doc_TRUE= DX_COND_doc_FALSE='#' else DX_COND_doc_TRUE='#' DX_COND_doc_FALSE= fi DX_ENV="$DX_ENV PERL_PATH='$DX_PERL'" : else if false; then DX_COND_doc_TRUE= DX_COND_doc_FALSE='#' else DX_COND_doc_TRUE='#' DX_COND_doc_FALSE= fi : fi # Dot for graphics: # Check whether --enable-doxygen-dot was given. if test "${enable_doxygen_dot+set}" = set; then : enableval=$enable_doxygen_dot; case "$enableval" in #( y|Y|yes|Yes|YES) DX_FLAG_dot=1 test "$DX_FLAG_doc" = "1" \ || as_fn_error $? "doxygen-dot requires doxygen-dot" "$LINENO" 5 ;; #( n|N|no|No|NO) DX_FLAG_dot=0 ;; #( *) as_fn_error $? "invalid value '$enableval' given to doxygen-dot" "$LINENO" 5 ;; esac else DX_FLAG_dot=1 test "$DX_FLAG_doc" = "1" || DX_FLAG_dot=0 fi if test "$DX_FLAG_dot" = 1; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dot", so it can be a program name with args. set dummy ${ac_tool_prefix}dot; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_DX_DOT+:} false; then : $as_echo_n "(cached) " >&6 else case $DX_DOT in [\\/]* | ?:[\\/]*) ac_cv_path_DX_DOT="$DX_DOT" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_DX_DOT="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi DX_DOT=$ac_cv_path_DX_DOT if test -n "$DX_DOT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DX_DOT" >&5 $as_echo "$DX_DOT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_DX_DOT"; then ac_pt_DX_DOT=$DX_DOT # Extract the first word of "dot", so it can be a program name with args. set dummy dot; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_DX_DOT+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_DX_DOT in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_DX_DOT="$ac_pt_DX_DOT" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_ac_pt_DX_DOT="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_DX_DOT=$ac_cv_path_ac_pt_DX_DOT if test -n "$ac_pt_DX_DOT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_DX_DOT" >&5 $as_echo "$ac_pt_DX_DOT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_DX_DOT" = x; then DX_DOT="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DX_DOT=$ac_pt_DX_DOT fi else DX_DOT="$ac_cv_path_DX_DOT" fi if test "$DX_FLAG_dot$DX_DOT" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: dot not found - will not generate graphics for the documentation" >&5 $as_echo "$as_me: WARNING: dot not found - will not generate graphics for the documentation" >&2;} DX_FLAG_dot=0 fi : fi if test "$DX_FLAG_dot" = 1; then if :; then DX_COND_dot_TRUE= DX_COND_dot_FALSE='#' else DX_COND_dot_TRUE='#' DX_COND_dot_FALSE= fi DX_ENV="$DX_ENV HAVE_DOT='YES'" DX_ENV="$DX_ENV DOT_PATH='`expr ".$DX_DOT" : '\(\.\)[^/]*$' \| "x$DX_DOT" : 'x\(.*\)/[^/]*$'`'" : else if false; then DX_COND_dot_TRUE= DX_COND_dot_FALSE='#' else DX_COND_dot_TRUE='#' DX_COND_dot_FALSE= fi DX_ENV="$DX_ENV HAVE_DOT='NO'" : fi # Man pages generation: # Check whether --enable-doxygen-man was given. if test "${enable_doxygen_man+set}" = set; then : enableval=$enable_doxygen_man; case "$enableval" in #( y|Y|yes|Yes|YES) DX_FLAG_man=1 test "$DX_FLAG_doc" = "1" \ || as_fn_error $? "doxygen-man requires doxygen-man" "$LINENO" 5 ;; #( n|N|no|No|NO) DX_FLAG_man=0 ;; #( *) as_fn_error $? "invalid value '$enableval' given to doxygen-man" "$LINENO" 5 ;; esac else DX_FLAG_man=0 test "$DX_FLAG_doc" = "1" || DX_FLAG_man=0 fi if test "$DX_FLAG_man" = 1; then : fi if test "$DX_FLAG_man" = 1; then if :; then DX_COND_man_TRUE= DX_COND_man_FALSE='#' else DX_COND_man_TRUE='#' DX_COND_man_FALSE= fi DX_ENV="$DX_ENV GENERATE_MAN='YES'" : else if false; then DX_COND_man_TRUE= DX_COND_man_FALSE='#' else DX_COND_man_TRUE='#' DX_COND_man_FALSE= fi DX_ENV="$DX_ENV GENERATE_MAN='NO'" : fi # RTF file generation: # Check whether --enable-doxygen-rtf was given. if test "${enable_doxygen_rtf+set}" = set; then : enableval=$enable_doxygen_rtf; case "$enableval" in #( y|Y|yes|Yes|YES) DX_FLAG_rtf=1 test "$DX_FLAG_doc" = "1" \ || as_fn_error $? "doxygen-rtf requires doxygen-rtf" "$LINENO" 5 ;; #( n|N|no|No|NO) DX_FLAG_rtf=0 ;; #( *) as_fn_error $? "invalid value '$enableval' given to doxygen-rtf" "$LINENO" 5 ;; esac else DX_FLAG_rtf=0 test "$DX_FLAG_doc" = "1" || DX_FLAG_rtf=0 fi if test "$DX_FLAG_rtf" = 1; then : fi if test "$DX_FLAG_rtf" = 1; then if :; then DX_COND_rtf_TRUE= DX_COND_rtf_FALSE='#' else DX_COND_rtf_TRUE='#' DX_COND_rtf_FALSE= fi DX_ENV="$DX_ENV GENERATE_RTF='YES'" : else if false; then DX_COND_rtf_TRUE= DX_COND_rtf_FALSE='#' else DX_COND_rtf_TRUE='#' DX_COND_rtf_FALSE= fi DX_ENV="$DX_ENV GENERATE_RTF='NO'" : fi # XML file generation: # Check whether --enable-doxygen-xml was given. if test "${enable_doxygen_xml+set}" = set; then : enableval=$enable_doxygen_xml; case "$enableval" in #( y|Y|yes|Yes|YES) DX_FLAG_xml=1 test "$DX_FLAG_doc" = "1" \ || as_fn_error $? "doxygen-xml requires doxygen-xml" "$LINENO" 5 ;; #( n|N|no|No|NO) DX_FLAG_xml=0 ;; #( *) as_fn_error $? "invalid value '$enableval' given to doxygen-xml" "$LINENO" 5 ;; esac else DX_FLAG_xml=0 test "$DX_FLAG_doc" = "1" || DX_FLAG_xml=0 fi if test "$DX_FLAG_xml" = 1; then : fi if test "$DX_FLAG_xml" = 1; then if :; then DX_COND_xml_TRUE= DX_COND_xml_FALSE='#' else DX_COND_xml_TRUE='#' DX_COND_xml_FALSE= fi DX_ENV="$DX_ENV GENERATE_XML='YES'" : else if false; then DX_COND_xml_TRUE= DX_COND_xml_FALSE='#' else DX_COND_xml_TRUE='#' DX_COND_xml_FALSE= fi DX_ENV="$DX_ENV GENERATE_XML='NO'" : fi # (Compressed) HTML help generation: # Check whether --enable-doxygen-chm was given. if test "${enable_doxygen_chm+set}" = set; then : enableval=$enable_doxygen_chm; case "$enableval" in #( y|Y|yes|Yes|YES) DX_FLAG_chm=1 test "$DX_FLAG_doc" = "1" \ || as_fn_error $? "doxygen-chm requires doxygen-chm" "$LINENO" 5 ;; #( n|N|no|No|NO) DX_FLAG_chm=0 ;; #( *) as_fn_error $? "invalid value '$enableval' given to doxygen-chm" "$LINENO" 5 ;; esac else DX_FLAG_chm=0 test "$DX_FLAG_doc" = "1" || DX_FLAG_chm=0 fi if test "$DX_FLAG_chm" = 1; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}hhc", so it can be a program name with args. set dummy ${ac_tool_prefix}hhc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_DX_HHC+:} false; then : $as_echo_n "(cached) " >&6 else case $DX_HHC in [\\/]* | ?:[\\/]*) ac_cv_path_DX_HHC="$DX_HHC" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_DX_HHC="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi DX_HHC=$ac_cv_path_DX_HHC if test -n "$DX_HHC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DX_HHC" >&5 $as_echo "$DX_HHC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_DX_HHC"; then ac_pt_DX_HHC=$DX_HHC # Extract the first word of "hhc", so it can be a program name with args. set dummy hhc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_DX_HHC+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_DX_HHC in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_DX_HHC="$ac_pt_DX_HHC" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_ac_pt_DX_HHC="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_DX_HHC=$ac_cv_path_ac_pt_DX_HHC if test -n "$ac_pt_DX_HHC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_DX_HHC" >&5 $as_echo "$ac_pt_DX_HHC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_DX_HHC" = x; then DX_HHC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DX_HHC=$ac_pt_DX_HHC fi else DX_HHC="$ac_cv_path_DX_HHC" fi if test "$DX_FLAG_chm$DX_HHC" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: hhc not found - will not generate compressed HTML help documentation" >&5 $as_echo "$as_me: WARNING: hhc not found - will not generate compressed HTML help documentation" >&2;} DX_FLAG_chm=0 fi : fi if test "$DX_FLAG_chm" = 1; then if :; then DX_COND_chm_TRUE= DX_COND_chm_FALSE='#' else DX_COND_chm_TRUE='#' DX_COND_chm_FALSE= fi DX_ENV="$DX_ENV HHC_PATH='$DX_HHC'" DX_ENV="$DX_ENV GENERATE_HTML='YES'" DX_ENV="$DX_ENV GENERATE_HTMLHELP='YES'" : else if false; then DX_COND_chm_TRUE= DX_COND_chm_FALSE='#' else DX_COND_chm_TRUE='#' DX_COND_chm_FALSE= fi DX_ENV="$DX_ENV GENERATE_HTMLHELP='NO'" : fi # Seperate CHI file generation. # Check whether --enable-doxygen-chi was given. if test "${enable_doxygen_chi+set}" = set; then : enableval=$enable_doxygen_chi; case "$enableval" in #( y|Y|yes|Yes|YES) DX_FLAG_chi=1 test "$DX_FLAG_chm" = "1" \ || as_fn_error $? "doxygen-chi requires doxygen-chi" "$LINENO" 5 ;; #( n|N|no|No|NO) DX_FLAG_chi=0 ;; #( *) as_fn_error $? "invalid value '$enableval' given to doxygen-chi" "$LINENO" 5 ;; esac else DX_FLAG_chi=0 test "$DX_FLAG_chm" = "1" || DX_FLAG_chi=0 fi if test "$DX_FLAG_chi" = 1; then : fi if test "$DX_FLAG_chi" = 1; then if :; then DX_COND_chi_TRUE= DX_COND_chi_FALSE='#' else DX_COND_chi_TRUE='#' DX_COND_chi_FALSE= fi DX_ENV="$DX_ENV GENERATE_CHI='YES'" : else if false; then DX_COND_chi_TRUE= DX_COND_chi_FALSE='#' else DX_COND_chi_TRUE='#' DX_COND_chi_FALSE= fi DX_ENV="$DX_ENV GENERATE_CHI='NO'" : fi # Plain HTML pages generation: # Check whether --enable-doxygen-html was given. if test "${enable_doxygen_html+set}" = set; then : enableval=$enable_doxygen_html; case "$enableval" in #( y|Y|yes|Yes|YES) DX_FLAG_html=1 test "$DX_FLAG_doc" = "1" \ || as_fn_error $? "doxygen-html requires doxygen-html" "$LINENO" 5 test "$DX_FLAG_chm" = "0" \ || as_fn_error $? "doxygen-html contradicts doxygen-html" "$LINENO" 5 ;; #( n|N|no|No|NO) DX_FLAG_html=0 ;; #( *) as_fn_error $? "invalid value '$enableval' given to doxygen-html" "$LINENO" 5 ;; esac else DX_FLAG_html=1 test "$DX_FLAG_doc" = "1" || DX_FLAG_html=0 test "$DX_FLAG_chm" = "0" || DX_FLAG_html=0 fi if test "$DX_FLAG_html" = 1; then : fi if test "$DX_FLAG_html" = 1; then if :; then DX_COND_html_TRUE= DX_COND_html_FALSE='#' else DX_COND_html_TRUE='#' DX_COND_html_FALSE= fi DX_ENV="$DX_ENV GENERATE_HTML='YES'" : else if false; then DX_COND_html_TRUE= DX_COND_html_FALSE='#' else DX_COND_html_TRUE='#' DX_COND_html_FALSE= fi test "$DX_FLAG_chm" = 1 || DX_ENV="$DX_ENV GENERATE_HTML='NO'" : fi # PostScript file generation: # Check whether --enable-doxygen-ps was given. if test "${enable_doxygen_ps+set}" = set; then : enableval=$enable_doxygen_ps; case "$enableval" in #( y|Y|yes|Yes|YES) DX_FLAG_ps=1 test "$DX_FLAG_doc" = "1" \ || as_fn_error $? "doxygen-ps requires doxygen-ps" "$LINENO" 5 ;; #( n|N|no|No|NO) DX_FLAG_ps=0 ;; #( *) as_fn_error $? "invalid value '$enableval' given to doxygen-ps" "$LINENO" 5 ;; esac else DX_FLAG_ps=0 test "$DX_FLAG_doc" = "1" || DX_FLAG_ps=0 fi if test "$DX_FLAG_ps" = 1; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}latex", so it can be a program name with args. set dummy ${ac_tool_prefix}latex; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_DX_LATEX+:} false; then : $as_echo_n "(cached) " >&6 else case $DX_LATEX in [\\/]* | ?:[\\/]*) ac_cv_path_DX_LATEX="$DX_LATEX" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_DX_LATEX="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi DX_LATEX=$ac_cv_path_DX_LATEX if test -n "$DX_LATEX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DX_LATEX" >&5 $as_echo "$DX_LATEX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_DX_LATEX"; then ac_pt_DX_LATEX=$DX_LATEX # Extract the first word of "latex", so it can be a program name with args. set dummy latex; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_DX_LATEX+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_DX_LATEX in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_DX_LATEX="$ac_pt_DX_LATEX" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_ac_pt_DX_LATEX="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_DX_LATEX=$ac_cv_path_ac_pt_DX_LATEX if test -n "$ac_pt_DX_LATEX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_DX_LATEX" >&5 $as_echo "$ac_pt_DX_LATEX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_DX_LATEX" = x; then DX_LATEX="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DX_LATEX=$ac_pt_DX_LATEX fi else DX_LATEX="$ac_cv_path_DX_LATEX" fi if test "$DX_FLAG_ps$DX_LATEX" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: latex not found - will not generate PostScript documentation" >&5 $as_echo "$as_me: WARNING: latex not found - will not generate PostScript documentation" >&2;} DX_FLAG_ps=0 fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}makeindex", so it can be a program name with args. set dummy ${ac_tool_prefix}makeindex; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_DX_MAKEINDEX+:} false; then : $as_echo_n "(cached) " >&6 else case $DX_MAKEINDEX in [\\/]* | ?:[\\/]*) ac_cv_path_DX_MAKEINDEX="$DX_MAKEINDEX" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_DX_MAKEINDEX="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi DX_MAKEINDEX=$ac_cv_path_DX_MAKEINDEX if test -n "$DX_MAKEINDEX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DX_MAKEINDEX" >&5 $as_echo "$DX_MAKEINDEX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_DX_MAKEINDEX"; then ac_pt_DX_MAKEINDEX=$DX_MAKEINDEX # Extract the first word of "makeindex", so it can be a program name with args. set dummy makeindex; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_DX_MAKEINDEX+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_DX_MAKEINDEX in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_DX_MAKEINDEX="$ac_pt_DX_MAKEINDEX" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_ac_pt_DX_MAKEINDEX="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_DX_MAKEINDEX=$ac_cv_path_ac_pt_DX_MAKEINDEX if test -n "$ac_pt_DX_MAKEINDEX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_DX_MAKEINDEX" >&5 $as_echo "$ac_pt_DX_MAKEINDEX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_DX_MAKEINDEX" = x; then DX_MAKEINDEX="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DX_MAKEINDEX=$ac_pt_DX_MAKEINDEX fi else DX_MAKEINDEX="$ac_cv_path_DX_MAKEINDEX" fi if test "$DX_FLAG_ps$DX_MAKEINDEX" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: makeindex not found - will not generate PostScript documentation" >&5 $as_echo "$as_me: WARNING: makeindex not found - will not generate PostScript documentation" >&2;} DX_FLAG_ps=0 fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dvips", so it can be a program name with args. set dummy ${ac_tool_prefix}dvips; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_DX_DVIPS+:} false; then : $as_echo_n "(cached) " >&6 else case $DX_DVIPS in [\\/]* | ?:[\\/]*) ac_cv_path_DX_DVIPS="$DX_DVIPS" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_DX_DVIPS="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi DX_DVIPS=$ac_cv_path_DX_DVIPS if test -n "$DX_DVIPS"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DX_DVIPS" >&5 $as_echo "$DX_DVIPS" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_DX_DVIPS"; then ac_pt_DX_DVIPS=$DX_DVIPS # Extract the first word of "dvips", so it can be a program name with args. set dummy dvips; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_DX_DVIPS+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_DX_DVIPS in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_DX_DVIPS="$ac_pt_DX_DVIPS" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_ac_pt_DX_DVIPS="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_DX_DVIPS=$ac_cv_path_ac_pt_DX_DVIPS if test -n "$ac_pt_DX_DVIPS"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_DX_DVIPS" >&5 $as_echo "$ac_pt_DX_DVIPS" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_DX_DVIPS" = x; then DX_DVIPS="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DX_DVIPS=$ac_pt_DX_DVIPS fi else DX_DVIPS="$ac_cv_path_DX_DVIPS" fi if test "$DX_FLAG_ps$DX_DVIPS" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: dvips not found - will not generate PostScript documentation" >&5 $as_echo "$as_me: WARNING: dvips not found - will not generate PostScript documentation" >&2;} DX_FLAG_ps=0 fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}egrep", so it can be a program name with args. set dummy ${ac_tool_prefix}egrep; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_DX_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else case $DX_EGREP in [\\/]* | ?:[\\/]*) ac_cv_path_DX_EGREP="$DX_EGREP" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_DX_EGREP="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi DX_EGREP=$ac_cv_path_DX_EGREP if test -n "$DX_EGREP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DX_EGREP" >&5 $as_echo "$DX_EGREP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_DX_EGREP"; then ac_pt_DX_EGREP=$DX_EGREP # Extract the first word of "egrep", so it can be a program name with args. set dummy egrep; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_DX_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_DX_EGREP in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_DX_EGREP="$ac_pt_DX_EGREP" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_ac_pt_DX_EGREP="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_DX_EGREP=$ac_cv_path_ac_pt_DX_EGREP if test -n "$ac_pt_DX_EGREP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_DX_EGREP" >&5 $as_echo "$ac_pt_DX_EGREP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_DX_EGREP" = x; then DX_EGREP="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DX_EGREP=$ac_pt_DX_EGREP fi else DX_EGREP="$ac_cv_path_DX_EGREP" fi if test "$DX_FLAG_ps$DX_EGREP" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: egrep not found - will not generate PostScript documentation" >&5 $as_echo "$as_me: WARNING: egrep not found - will not generate PostScript documentation" >&2;} DX_FLAG_ps=0 fi : fi if test "$DX_FLAG_ps" = 1; then if :; then DX_COND_ps_TRUE= DX_COND_ps_FALSE='#' else DX_COND_ps_TRUE='#' DX_COND_ps_FALSE= fi : else if false; then DX_COND_ps_TRUE= DX_COND_ps_FALSE='#' else DX_COND_ps_TRUE='#' DX_COND_ps_FALSE= fi : fi # PDF file generation: # Check whether --enable-doxygen-pdf was given. if test "${enable_doxygen_pdf+set}" = set; then : enableval=$enable_doxygen_pdf; case "$enableval" in #( y|Y|yes|Yes|YES) DX_FLAG_pdf=1 test "$DX_FLAG_doc" = "1" \ || as_fn_error $? "doxygen-pdf requires doxygen-pdf" "$LINENO" 5 ;; #( n|N|no|No|NO) DX_FLAG_pdf=0 ;; #( *) as_fn_error $? "invalid value '$enableval' given to doxygen-pdf" "$LINENO" 5 ;; esac else DX_FLAG_pdf=0 test "$DX_FLAG_doc" = "1" || DX_FLAG_pdf=0 fi if test "$DX_FLAG_pdf" = 1; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pdflatex", so it can be a program name with args. set dummy ${ac_tool_prefix}pdflatex; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_DX_PDFLATEX+:} false; then : $as_echo_n "(cached) " >&6 else case $DX_PDFLATEX in [\\/]* | ?:[\\/]*) ac_cv_path_DX_PDFLATEX="$DX_PDFLATEX" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_DX_PDFLATEX="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi DX_PDFLATEX=$ac_cv_path_DX_PDFLATEX if test -n "$DX_PDFLATEX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DX_PDFLATEX" >&5 $as_echo "$DX_PDFLATEX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_DX_PDFLATEX"; then ac_pt_DX_PDFLATEX=$DX_PDFLATEX # Extract the first word of "pdflatex", so it can be a program name with args. set dummy pdflatex; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_DX_PDFLATEX+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_DX_PDFLATEX in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_DX_PDFLATEX="$ac_pt_DX_PDFLATEX" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_ac_pt_DX_PDFLATEX="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_DX_PDFLATEX=$ac_cv_path_ac_pt_DX_PDFLATEX if test -n "$ac_pt_DX_PDFLATEX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_DX_PDFLATEX" >&5 $as_echo "$ac_pt_DX_PDFLATEX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_DX_PDFLATEX" = x; then DX_PDFLATEX="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DX_PDFLATEX=$ac_pt_DX_PDFLATEX fi else DX_PDFLATEX="$ac_cv_path_DX_PDFLATEX" fi if test "$DX_FLAG_pdf$DX_PDFLATEX" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pdflatex not found - will not generate PDF documentation" >&5 $as_echo "$as_me: WARNING: pdflatex not found - will not generate PDF documentation" >&2;} DX_FLAG_pdf=0 fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}makeindex", so it can be a program name with args. set dummy ${ac_tool_prefix}makeindex; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_DX_MAKEINDEX+:} false; then : $as_echo_n "(cached) " >&6 else case $DX_MAKEINDEX in [\\/]* | ?:[\\/]*) ac_cv_path_DX_MAKEINDEX="$DX_MAKEINDEX" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_DX_MAKEINDEX="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi DX_MAKEINDEX=$ac_cv_path_DX_MAKEINDEX if test -n "$DX_MAKEINDEX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DX_MAKEINDEX" >&5 $as_echo "$DX_MAKEINDEX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_DX_MAKEINDEX"; then ac_pt_DX_MAKEINDEX=$DX_MAKEINDEX # Extract the first word of "makeindex", so it can be a program name with args. set dummy makeindex; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_DX_MAKEINDEX+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_DX_MAKEINDEX in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_DX_MAKEINDEX="$ac_pt_DX_MAKEINDEX" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_ac_pt_DX_MAKEINDEX="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_DX_MAKEINDEX=$ac_cv_path_ac_pt_DX_MAKEINDEX if test -n "$ac_pt_DX_MAKEINDEX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_DX_MAKEINDEX" >&5 $as_echo "$ac_pt_DX_MAKEINDEX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_DX_MAKEINDEX" = x; then DX_MAKEINDEX="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DX_MAKEINDEX=$ac_pt_DX_MAKEINDEX fi else DX_MAKEINDEX="$ac_cv_path_DX_MAKEINDEX" fi if test "$DX_FLAG_pdf$DX_MAKEINDEX" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: makeindex not found - will not generate PDF documentation" >&5 $as_echo "$as_me: WARNING: makeindex not found - will not generate PDF documentation" >&2;} DX_FLAG_pdf=0 fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}egrep", so it can be a program name with args. set dummy ${ac_tool_prefix}egrep; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_DX_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else case $DX_EGREP in [\\/]* | ?:[\\/]*) ac_cv_path_DX_EGREP="$DX_EGREP" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_DX_EGREP="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi DX_EGREP=$ac_cv_path_DX_EGREP if test -n "$DX_EGREP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DX_EGREP" >&5 $as_echo "$DX_EGREP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_DX_EGREP"; then ac_pt_DX_EGREP=$DX_EGREP # Extract the first word of "egrep", so it can be a program name with args. set dummy egrep; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_DX_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_DX_EGREP in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_DX_EGREP="$ac_pt_DX_EGREP" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_ac_pt_DX_EGREP="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_DX_EGREP=$ac_cv_path_ac_pt_DX_EGREP if test -n "$ac_pt_DX_EGREP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_DX_EGREP" >&5 $as_echo "$ac_pt_DX_EGREP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_DX_EGREP" = x; then DX_EGREP="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DX_EGREP=$ac_pt_DX_EGREP fi else DX_EGREP="$ac_cv_path_DX_EGREP" fi if test "$DX_FLAG_pdf$DX_EGREP" = 1; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: egrep not found - will not generate PDF documentation" >&5 $as_echo "$as_me: WARNING: egrep not found - will not generate PDF documentation" >&2;} DX_FLAG_pdf=0 fi : fi if test "$DX_FLAG_pdf" = 1; then if :; then DX_COND_pdf_TRUE= DX_COND_pdf_FALSE='#' else DX_COND_pdf_TRUE='#' DX_COND_pdf_FALSE= fi : else if false; then DX_COND_pdf_TRUE= DX_COND_pdf_FALSE='#' else DX_COND_pdf_TRUE='#' DX_COND_pdf_FALSE= fi : fi # LaTeX generation for PS and/or PDF: if test "$DX_FLAG_ps" = 1 || test "$DX_FLAG_pdf" = 1; then if :; then DX_COND_latex_TRUE= DX_COND_latex_FALSE='#' else DX_COND_latex_TRUE='#' DX_COND_latex_FALSE= fi DX_ENV="$DX_ENV GENERATE_LATEX='YES'" else if false; then DX_COND_latex_TRUE= DX_COND_latex_FALSE='#' else DX_COND_latex_TRUE='#' DX_COND_latex_FALSE= fi DX_ENV="$DX_ENV GENERATE_LATEX='NO'" fi # Paper size for PS and/or PDF: case "$DOXYGEN_PAPER_SIZE" in #( "") DOXYGEN_PAPER_SIZE="" ;; #( a4wide|a4|letter|legal|executive) DX_ENV="$DX_ENV PAPER_SIZE='$DOXYGEN_PAPER_SIZE'" ;; #( *) as_fn_error $? "unknown DOXYGEN_PAPER_SIZE='$DOXYGEN_PAPER_SIZE'" "$LINENO" 5 ;; esac #For debugging: #echo DX_FLAG_doc=$DX_FLAG_doc #echo DX_FLAG_dot=$DX_FLAG_dot #echo DX_FLAG_man=$DX_FLAG_man #echo DX_FLAG_html=$DX_FLAG_html #echo DX_FLAG_chm=$DX_FLAG_chm #echo DX_FLAG_chi=$DX_FLAG_chi #echo DX_FLAG_rtf=$DX_FLAG_rtf #echo DX_FLAG_xml=$DX_FLAG_xml #echo DX_FLAG_pdf=$DX_FLAG_pdf #echo DX_FLAG_ps=$DX_FLAG_ps #echo DX_ENV=$DX_ENV am__api_version='1.11' # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } mkdir_p="$MKDIR_P" case $mkdir_p in [\\/$]* | ?:[\\/]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE=$PACKAGE_TARNAME VERSION=$PACKAGE_VERSION cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' VERSION_INFO=1:3:0 ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 $as_echo "$CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CXX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler works" >&5 $as_echo_n "checking whether the C++ compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C++ compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler default output file name" >&5 $as_echo_n "checking for C++ compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C++ compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } if ${ac_cv_cxx_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } if ${ac_cv_prog_cxx_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi depcc="$CXX" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CXX_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CXX_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CXX_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CXX_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 $as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then am__fastdepCXX_TRUE= am__fastdepCXX_FALSE='#' else am__fastdepCXX_TRUE='#' am__fastdepCXX_FALSE= fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 $as_echo_n "checking how to run the C++ preprocessor... " >&6; } if test -z "$CXXCPP"; then if ${ac_cv_prog_CXXCPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CXXCPP needs to be expanded for CXXCPP in "$CXX -E" "/lib/cpp" do ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CXXCPP=$CXXCPP fi CXXCPP=$ac_cv_prog_CXXCPP else ac_cv_prog_CXXCPP=$CXXCPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 $as_echo "$CXXCPP" >&6; } ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu ac_config_files="$ac_config_files Makefile scythestat/Makefile scythestat/rng/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # Transform confdefs.h into DEFS. # Protect against shell expansion while executing Makefile rules. # Protect against Makefile macro expansion. # # If the first sed substitution is executed (which looks for macros that # take arguments), then branch to the quote section. Otherwise, # look for a macro that doesn't take arguments. ac_script=' :mline /\\$/{ N s,\\\n,, b mline } t clear :clear s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g t quote s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g t quote b any :quote s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g s/\[/\\&/g s/\]/\\&/g s/\$/$$/g H :any ${ g s/^\n// s/\n/ /g p } ' DEFS=`sed -n "$ac_script" confdefs.h` ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs if test -z "${DX_COND_doc_TRUE}" && test -z "${DX_COND_doc_FALSE}"; then as_fn_error $? "conditional \"DX_COND_doc\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${DX_COND_doc_TRUE}" && test -z "${DX_COND_doc_FALSE}"; then as_fn_error $? "conditional \"DX_COND_doc\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${DX_COND_dot_TRUE}" && test -z "${DX_COND_dot_FALSE}"; then as_fn_error $? "conditional \"DX_COND_dot\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${DX_COND_dot_TRUE}" && test -z "${DX_COND_dot_FALSE}"; then as_fn_error $? "conditional \"DX_COND_dot\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${DX_COND_man_TRUE}" && test -z "${DX_COND_man_FALSE}"; then as_fn_error $? "conditional \"DX_COND_man\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${DX_COND_man_TRUE}" && test -z "${DX_COND_man_FALSE}"; then as_fn_error $? "conditional \"DX_COND_man\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${DX_COND_rtf_TRUE}" && test -z "${DX_COND_rtf_FALSE}"; then as_fn_error $? "conditional \"DX_COND_rtf\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${DX_COND_rtf_TRUE}" && test -z "${DX_COND_rtf_FALSE}"; then as_fn_error $? "conditional \"DX_COND_rtf\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${DX_COND_xml_TRUE}" && test -z "${DX_COND_xml_FALSE}"; then as_fn_error $? "conditional \"DX_COND_xml\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${DX_COND_xml_TRUE}" && test -z "${DX_COND_xml_FALSE}"; then as_fn_error $? "conditional \"DX_COND_xml\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${DX_COND_chm_TRUE}" && test -z "${DX_COND_chm_FALSE}"; then as_fn_error $? "conditional \"DX_COND_chm\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${DX_COND_chm_TRUE}" && test -z "${DX_COND_chm_FALSE}"; then as_fn_error $? "conditional \"DX_COND_chm\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${DX_COND_chi_TRUE}" && test -z "${DX_COND_chi_FALSE}"; then as_fn_error $? "conditional \"DX_COND_chi\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${DX_COND_chi_TRUE}" && test -z "${DX_COND_chi_FALSE}"; then as_fn_error $? "conditional \"DX_COND_chi\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${DX_COND_html_TRUE}" && test -z "${DX_COND_html_FALSE}"; then as_fn_error $? "conditional \"DX_COND_html\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${DX_COND_html_TRUE}" && test -z "${DX_COND_html_FALSE}"; then as_fn_error $? "conditional \"DX_COND_html\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${DX_COND_ps_TRUE}" && test -z "${DX_COND_ps_FALSE}"; then as_fn_error $? "conditional \"DX_COND_ps\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${DX_COND_ps_TRUE}" && test -z "${DX_COND_ps_FALSE}"; then as_fn_error $? "conditional \"DX_COND_ps\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${DX_COND_pdf_TRUE}" && test -z "${DX_COND_pdf_FALSE}"; then as_fn_error $? "conditional \"DX_COND_pdf\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${DX_COND_pdf_TRUE}" && test -z "${DX_COND_pdf_FALSE}"; then as_fn_error $? "conditional \"DX_COND_pdf\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${DX_COND_latex_TRUE}" && test -z "${DX_COND_latex_FALSE}"; then as_fn_error $? "conditional \"DX_COND_latex\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${DX_COND_latex_TRUE}" && test -z "${DX_COND_latex_FALSE}"; then as_fn_error $? "conditional \"DX_COND_latex\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by Scythe Statistical Library $as_me 1.0.3, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE Configuration files: $config_files Configuration commands: $config_commands Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ Scythe Statistical Library config.status 1.0.3 configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --he | --h | --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "scythestat/Makefile") CONFIG_FILES="$CONFIG_FILES scythestat/Makefile" ;; "scythestat/rng/Makefile") CONFIG_FILES="$CONFIG_FILES scythestat/rng/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" eval set X " :F $CONFIG_FILES :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir=$dirpart/$fdir; as_fn_mkdir_p # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi scythestat-1.0.3/AUTHORS0000644000175000017500000000066211765733772011725 00000000000000Daniel Pemstein Department of Political Science Croft Institute for International Studies University of Mississippi P.O. Box 1848 University, MS 38677 dbp@uiuc.edu Kevin M. Quinn UC Berkeley School of Law 490 Simon #7200 University of California, Berkeley Berkeley, CA 94720-7200 kquinn@law.berkeley.edu Andrew D. Martin Washington University School of Law Campus Box 1120 One Brookings Drive St. Louis, MO 63130 admartin@wustl.edu scythestat-1.0.3/aclocal.m40000644000175000017500000010422611766141013012474 00000000000000# generated automatically by aclocal 1.11.3 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, # Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],, [m4_warning([this file was generated for autoconf 2.68. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) # Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008, 2011 Free Software # Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.11' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.11.3], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.11.3])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to # `$srcdir', `$srcdir/..', or `$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is `.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 9 # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ(2.52)dnl ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, # 2010, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 12 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "GCJ", or "OBJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl ifelse([$1], CC, [depcc="$CC" am_compiler_list=], [$1], CXX, [depcc="$CXX" am_compiler_list=], [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], UPC, [depcc="$UPC" am_compiler_list=], [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE(dependency-tracking, [ --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. #serial 5 # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` AS_MKDIR_P([$dirpart/$fdir]) # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each `.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2008, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 16 # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.62])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) AM_MISSING_PROG(AUTOCONF, autoconf) AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) AM_MISSING_PROG(AUTOHEADER, autoheader) AM_MISSING_PROG(MAKEINFO, makeinfo) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AM_PROG_MKDIR_P])dnl # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES(CC)], [define([AC_PROG_CC], defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES(CXX)], [define([AC_PROG_CXX], defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES(OBJC)], [define([AC_PROG_OBJC], defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl ]) _AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl dnl The `parallel-tests' driver may need to know about EXEEXT, so add the dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl ]) dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001, 2003, 2005, 2008, 2011 Free Software Foundation, # Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST(install_sh)]) # Copyright (C) 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 4 # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi AC_SUBST([am__include]) AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 6 # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it supports --run. # If it does, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= AC_MSG_WARN([`missing' script is too old or missing]) fi ]) # Copyright (C) 2003, 2004, 2005, 2006, 2011 Free Software Foundation, # Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_PROG_MKDIR_P # --------------- # Check for `mkdir -p'. AC_DEFUN([AM_PROG_MKDIR_P], [AC_PREREQ([2.60])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, dnl while keeping a definition of mkdir_p for backward compatibility. dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of dnl Makefile.ins that do not define MKDIR_P, so we do our own dnl adjustment using top_builddir (which is defined more often than dnl MKDIR_P). AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl case $mkdir_p in [[\\/$]]* | ?:[[\\/]]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2008, 2010 Free Software # Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 5 # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), 1)]) # _AM_SET_OPTIONS(OPTIONS) # ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 5 # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT(yes)]) # Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 1 # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor `install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in `make install-strip', and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be `maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006, 2008, 2010 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 3 # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004, 2005, 2012 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of `v7', `ustar', or `pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar],, [pax],, [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' _am_tools=${am_cv_prog_tar_$1-$_am_tools} # Do not fold the above two line into one, because Tru64 sh and # Solaris sh will not grok spaces in the rhs of `-'. for _am_tool in $_am_tools do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR m4_include([acinclude.m4]) scythestat-1.0.3/COPYING0000644000175000017500000010451311765734115011700 00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . scythestat-1.0.3/Makefile.in0000644000175000017500000007050011766141014012677 00000000000000# Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # This file is part of Automake. -*- Automake -*- # Copyright (C) 2003 Oren Ben-Kiki # This file is distributed under the same terms as the Automake macro files. # Generate automatic documentation using Doxygen. Goals and variables values # are controlled by the various DX_COND_??? conditionals set by autoconf. # # The provided goals are: # # doxygen: generate all the documentation. Called via dist-hook. Calls: # doxygen-hook: do psot-doxygen processing. # doxygen-pdf: generate documentation in PDF format. # doxygen-ps: generate documentation in PostScript format. # # mostlyclean-doxygen: clean all tmp files. Called via mostlyclean. Calls: # mostlyclean-doxygen-chm: delete the uncompressed HTML files. # mostlyclean-doxygen-latex: delete the LaTeX source files for PS/PDF. # # clean-doxygen: remove all the documentation. Called via clean and # maintainer-clean. # # The following variables are set: # # DX_OUT_FILES = the generated document files (CHM, PS, PDF, XML, RTF). # DX_OUT_DIRS = the generated document directories (html, man). # # These may then be added to EXTRA_DIST etc. VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(top_srcdir)/aminclude.am \ $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \ config/config.guess config/config.sub config/install-sh \ config/missing @DX_COND_html_TRUE@am__append_1 = @DX_DOCDIR@/@PACKAGE@.tag @DX_COND_html_TRUE@am__append_2 = @DX_DOCDIR@/html @DX_COND_chm_TRUE@am__append_3 = @DX_DOCDIR@/@PACKAGE@.chm @DX_COND_chi_TRUE@@DX_COND_chm_TRUE@am__append_4 = @DX_DOCDIR@/@PACKAGE@.chi @DX_COND_man_TRUE@am__append_5 = @DX_DOCDIR@/man @DX_COND_ps_TRUE@am__append_6 = @DX_DOCDIR@/@PACKAGE@.ps @DX_COND_pdf_TRUE@am__append_7 = @DX_DOCDIR@/@PACKAGE@.pdf @DX_COND_rtf_TRUE@am__append_8 = @DX_DOCDIR@/rtf @DX_COND_xml_TRUE@am__append_9 = @DX_DOCDIR@/xml subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ install-html-recursive install-info-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ distdir dist dist-all distcheck ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -rf "$(distdir)" \ || { sleep 5 && rm -rf "$(distdir)"; }; \ else :; fi am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DOXYGEN_PAPER_SIZE = @DOXYGEN_PAPER_SIZE@ DX_CONFIG = @DX_CONFIG@ DX_DOCDIR = @DX_DOCDIR@ DX_DOT = @DX_DOT@ DX_DOXYGEN = @DX_DOXYGEN@ DX_DVIPS = @DX_DVIPS@ DX_EGREP = @DX_EGREP@ DX_ENV = @DX_ENV@ DX_FLAG_chi = @DX_FLAG_chi@ DX_FLAG_chm = @DX_FLAG_chm@ DX_FLAG_doc = @DX_FLAG_doc@ DX_FLAG_dot = @DX_FLAG_dot@ DX_FLAG_html = @DX_FLAG_html@ DX_FLAG_man = @DX_FLAG_man@ DX_FLAG_pdf = @DX_FLAG_pdf@ DX_FLAG_ps = @DX_FLAG_ps@ DX_FLAG_rtf = @DX_FLAG_rtf@ DX_FLAG_xml = @DX_FLAG_xml@ DX_HHC = @DX_HHC@ DX_LATEX = @DX_LATEX@ DX_MAKEINDEX = @DX_MAKEINDEX@ DX_PDFLATEX = @DX_PDFLATEX@ DX_PERL = @DX_PERL@ DX_PROJECT = @DX_PROJECT@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EXEEXT = @EXEEXT@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ VERSION_INFO = @VERSION_INFO@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CXX = @ac_ct_CXX@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ DX_OUT_FILES = $(am__append_1) $(am__append_3) $(am__append_4) \ $(am__append_6) $(am__append_7) DX_OUT_DIRS = $(am__append_2) $(am__append_5) $(am__append_8) \ $(am__append_9) @DX_COND_html_FALSE@MOSTLYCLEAN_FILES = @DX_DOCDIR@/@PACKAGE@.tag EXTRA_DIST = LICENSE SUBDIRS = scythestat ACLOCAL_AMFLAGS = -I m4 all: all-recursive .SUFFIXES: am--refresh: Makefile @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/aminclude.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_srcdir)/aminclude.am: $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags @DX_COND_doc_FALSE@dist-hook: distdir: $(DISTFILES) $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$(top_distdir)" distdir="$(distdir)" \ dist-hook -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__remove_distdir) dist-lzip: distdir tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz $(am__remove_distdir) dist-lzma: distdir tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma $(am__remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__remove_distdir) dist-tarZ: distdir tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__remove_distdir) dist-shar: distdir shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__remove_distdir) dist dist-all: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lzma*) \ lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ *.tar.lz*) \ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir); chmod a+w $(distdir) mkdir $(distdir)/_build mkdir $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build \ && ../configure --srcdir=.. --prefix="$$dc_install_base" \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @test -n '$(distuninstallcheck_dir)' || { \ echo 'ERROR: trying to run $@ with an empty' \ '$$(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ $(am__cd) '$(distuninstallcheck_dir)' || { \ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: check-recursive all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." @DX_COND_doc_FALSE@clean: clean-recursive clean-am: clean-generic mostlyclean-am @DX_COND_doc_FALSE@distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: @DX_COND_doc_FALSE@maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic @DX_COND_doc_FALSE@mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ install-am install-strip tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am am--refresh check check-am clean clean-generic \ ctags ctags-recursive dist dist-all dist-bzip2 dist-gzip \ dist-hook dist-lzip dist-lzma dist-shar dist-tarZ dist-xz \ dist-zip distcheck distclean distclean-generic distclean-tags \ distcleancheck distdir distuninstallcheck dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs installdirs-am maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ pdf-am ps ps-am tags tags-recursive uninstall uninstall-am @DX_COND_doc_TRUE@.PHONY: doxygen clean-doxygen mostlyclean-doxygen doxygen-hook @DX_COND_doc_TRUE@dist-hook: doxygen @DX_COND_doc_TRUE@doxygen: @DX_DOCDIR@/@PACKAGE@.tag doxygen-hook @DX_COND_doc_TRUE@maintainer-clean: clean-doxygen @DX_COND_doc_TRUE@distclean: clean-doxygen @DX_COND_doc_TRUE@clean: clean-doxygen @DX_COND_doc_TRUE@clean-doxygen: @DX_COND_doc_TRUE@ rm -rf @DX_DOCDIR@/html @DX_DOCDIR@/Scythe.tag @DX_COND_doc_TRUE@mostlyclean: mostlyclean-doxygen @DX_COND_doc_TRUE@@DX_DOCDIR@/@PACKAGE@.tag: $(DX_CONFIG) $(pkginclude_HEADERS) @DX_COND_doc_TRUE@ rm -rf @DX_DOCDIR@/html @DX_DOCDIR@/Scythe.tag @DX_COND_doc_TRUE@ $(DX_ENV) $(DX_DOXYGEN) $(srcdir)/$(DX_CONFIG) @DX_COND_html_TRUE@@DX_DOCDIR@/html: @DX_DOCDIR@/@PACKAGE@.tag # HTML is not generated, but tag file is. It is pretty useless by itself, but # is a convenient intermediate file to hand all the other goals on. @DX_COND_html_FALSE@.INTERMEDIATE: @DX_DOCDIR@/@PACKAGE@.tag @DX_COND_chm_TRUE@.PHONY: mostlyclean-doxygen-chm @DX_COND_chm_TRUE@@DX_DOCDIR@/@PACKAGE@.chm: @DX_DOCDIR@/@PACKAGE@.tag @DX_COND_chi_TRUE@@DX_COND_chm_TRUE@@DX_DOCDIR@/@PACKAGE@.chi: @DX_DOCDIR@/@PACKAGE@.tag @DX_COND_chm_TRUE@mostlyclean-doxygen: mostlyclean-doxygen-chm @DX_COND_chm_TRUE@mostlyclean-doxygen-chm: @DX_COND_chm_TRUE@ rm -rf @DX_DOCDIR@/html @DX_COND_man_TRUE@@DX_DOCDIR@/man: @DX_DOCDIR@/@PACKAGE@.tag @DX_COND_ps_TRUE@.PHONY: doxygen-ps @DX_COND_ps_TRUE@doxygen: doxygen-ps @DX_COND_ps_TRUE@doxygen-ps: @DX_DOCDIR@/@PACKAGE@.ps @DX_COND_ps_TRUE@@DX_DOCDIR@/@PACKAGE@.ps: @DX_DOCDIR@/@PACKAGE@.tag @DX_COND_ps_TRUE@ cd @DX_DOCDIR@/latex; \ @DX_COND_ps_TRUE@ rm -f *.aux *.toc *.idx *.ind *.ilg *.log *.out; \ @DX_COND_ps_TRUE@ $(DX_LATEX) refman.tex; \ @DX_COND_ps_TRUE@ $(MAKEINDEX_PATH) refman.idx; \ @DX_COND_ps_TRUE@ $(DX_LATEX) refman.tex; \ @DX_COND_ps_TRUE@ countdown=5; \ @DX_COND_ps_TRUE@ while $(DX_EGREP) 'Rerun (LaTeX|to get cross-references right)' \ @DX_COND_ps_TRUE@ refman.log > /dev/null 2>&1 \ @DX_COND_ps_TRUE@ && test $$countdown -gt 0; do \ @DX_COND_ps_TRUE@ $(DX_LATEX) refman.tex; \ @DX_COND_ps_TRUE@ countdown=`expr $$countdown - 1`; \ @DX_COND_ps_TRUE@ done; \ @DX_COND_ps_TRUE@ $(DX_DVIPS) -o ../@PACKAGE@.ps refman.dvi @DX_COND_pdf_TRUE@.PHONY: doxygen-pdf @DX_COND_pdf_TRUE@doxygen: doxygen-pdf @DX_COND_pdf_TRUE@doxygen-pdf: @DX_DOCDIR@/@PACKAGE@.pdf @DX_COND_pdf_TRUE@@DX_DOCDIR@/@PACKAGE@.pdf: @DX_DOCDIR@/@PACKAGE@.tag @DX_COND_pdf_TRUE@ cd @DX_DOCDIR@/latex; \ @DX_COND_pdf_TRUE@ rm -f *.aux *.toc *.idx *.ind *.ilg *.log *.out; \ @DX_COND_pdf_TRUE@ $(DX_PDFLATEX) refman.tex; \ @DX_COND_pdf_TRUE@ $(DX_MAKEINDEX) refman.idx; \ @DX_COND_pdf_TRUE@ $(DX_PDFLATEX) refman.tex; \ @DX_COND_pdf_TRUE@ countdown=5; \ @DX_COND_pdf_TRUE@ while $(DX_EGREP) 'Rerun (LaTeX|to get cross-references right)' \ @DX_COND_pdf_TRUE@ refman.log > /dev/null 2>&1 \ @DX_COND_pdf_TRUE@ && test $$countdown -gt 0; do \ @DX_COND_pdf_TRUE@ $(DX_PDFLATEX) refman.tex; \ @DX_COND_pdf_TRUE@ countdown=`expr $$countdown - 1`; \ @DX_COND_pdf_TRUE@ done; \ @DX_COND_pdf_TRUE@ mv refman.pdf ../@PACKAGE@.pdf @DX_COND_latex_TRUE@mostlyclean-doxygen: mostlyclean-doxygen-latex @DX_COND_latex_TRUE@mostlyclean-doxygen-latex: @DX_COND_latex_TRUE@ rm -rf @DX_DOCDIR@/latex @DX_COND_rtf_TRUE@@DX_DOCDIR@/rtf: @DX_DOCDIR@/@PACKAGE@.tag @DX_COND_xml_TRUE@@DX_DOCDIR@/xml: @DX_DOCDIR@/@PACKAGE@.tag $(srcdir)/package.m4: $(top_srcdir)/configure.ac { \ echo '# Signature of the current package.'; \ echo 'm4_define([AT_PACKAGE_NAME], [@PACKAGE_NAME@])'; \ echo 'm4_define([AT_PACKAGE_TARNAME], [@PACKAGE_TARNAME@])'; \ echo 'm4_define([AT_PACKAGE_VERSION], [@PACKAGE_VERSION@])'; \ echo 'm4_define([AT_PACKAGE_STRING], [@PACKAGE_STRING@])'; \ echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \ } >$(srcdir)/package.m4 # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: scythestat-1.0.3/Makefile.am0000644000175000017500000000130311766140375012672 00000000000000include $(top_srcdir)/aminclude.am EXTRA_DIST = LICENSE SUBDIRS = scythestat ## Include the m4 subdirectory when looking for macros ACLOCAL_AMFLAGS = -I m4 ## Create the package.m4 file required by autotest $(srcdir)/package.m4: $(top_srcdir)/configure.ac { \ echo '# Signature of the current package.'; \ echo 'm4_define([AT_PACKAGE_NAME], [@PACKAGE_NAME@])'; \ echo 'm4_define([AT_PACKAGE_TARNAME], [@PACKAGE_TARNAME@])'; \ echo 'm4_define([AT_PACKAGE_VERSION], [@PACKAGE_VERSION@])'; \ echo 'm4_define([AT_PACKAGE_STRING], [@PACKAGE_STRING@])'; \ echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \ } >$(srcdir)/package.m4