--- MCMCpack/src/distributions.h.orig Mon Aug 18 18:37:44 2008 +++ MCMCpack/src/distributions.h Sun Jan 10 20:33:03 2010 @@ -88,6 +88,7 @@ #include #include #include +#include #ifdef HAVE_IEEEFP_H #include --- MCMCpack/src/error.h.orig Mon Aug 18 18:37:44 2008 +++ MCMCpack/src/error.h Sun Jan 10 20:31:28 2010 @@ -56,6 +56,7 @@ #include #include #include +#include /*! @cond */ #ifdef SCYTHE_DEBUG_LIB --- MCMCpack/src/MCMCdynamicIRT1d-b.cc.orig Mon Aug 18 18:37:44 2008 +++ MCMCpack/src/MCMCdynamicIRT1d-b.cc Mon Jan 11 03:15:17 2010 @@ -92,7 +92,8 @@ const int tot_iter = *burnin + *mcmc; const int nsamp = *mcmc / *thin; //sparse matrix of latent outcome variables - double Z[*nsubj][*nitems]; + double **Z = new double*[*nsubj]; + Z[0] = new double[(*nsubj) * (*nitems)]; for (int s=0; s<*nsubj; ++s){ for (int i=0; i<*nitems; ++i){ Z[s][i] = -999; --- MCMCpack/src/MCMCdynamicIRT1d.cc.orig Mon Aug 18 18:37:44 2008 +++ MCMCpack/src/MCMCdynamicIRT1d.cc Mon Jan 11 03:24:04 2010 @@ -92,7 +92,8 @@ const int tot_iter = *burnin + *mcmc; const int nsamp = *mcmc / *thin; //sparse matrix of latent outcome variables - double Z[*nsubj][*nitems]; + double **Z = new double*[*nsubj]; + Z[0] = new double[(*nsubj) * (*nitems)]; for (int s=0; s<*nsubj; ++s){ for (int i=0; i<*nitems; ++i){ Z[s][i] = -999; --- MCMCpack/src/MCMCfactanal.cc.orig Mon Aug 18 18:37:44 2008 +++ MCMCpack/src/MCMCfactanal.cc Mon Jan 11 04:46:16 2010 @@ -68,7 +68,7 @@ const unsigned int tot_iter = burnin + mcmc; const unsigned int nsamp = mcmc / thin; const Matrix<> I = eye(D); - const Matrix<> Lambda_free_indic = Matrix<>(K, D); + const Matrix Lambda_free_indic = Matrix<>(K, D); for (unsigned int i=0; i<(K*D); ++i){ if (Lambda_eq[i] == -999) Lambda_free_indic[i] = 1.0; } --- MCMCpack/src/MCMCirtHier1d.cc.orig Mon Dec 1 18:09:53 2008 +++ MCMCpack/src/MCMCirtHier1d.cc Mon Jan 11 05:19:43 2010 @@ -42,11 +42,10 @@ //pow(b, a) / gammafn(a) * pow(theta, -(a+1)) * exp(-b/theta); } - // Parameter-Expanded Latent Data Update for // 1d IRT. mjm, 2008-11-18 template -double irt_W_update(Matrix<>& Z, const Matrix<>& X, const Matrix<>& theta, +double irt_W_update(Matrix<>& Z, const Matrix& X, const Matrix<>& theta, const Matrix<>& eta, const double& alpha, const double& px_a0, const double& px_b0, const Matrix<>& etahat, const Matrix<>& thetahat, --- MCMCpack/src/MCMClogituserprior.cc.orig Mon Aug 18 18:37:44 2008 +++ MCMCpack/src/MCMClogituserprior.cc Mon Jan 11 15:03:09 2010 @@ -85,7 +85,7 @@ unsigned int burnin, unsigned int mcmc, unsigned int thin, unsigned int verbose, bool logfun, - const Matrix<>& propvar, const Matrix<>& Y_M, + const Matrix<>& propvar, const Matrix& Y_M, const Matrix<>& X_M, SEXP& sample_SEXP){ // define constants --- MCMCpack/src/MCMCmixfactanal.cc.orig Mon Aug 18 18:37:44 2008 +++ MCMCpack/src/MCMCmixfactanal.cc Mon Jan 11 16:00:30 2010 @@ -61,7 +61,7 @@ const Matrix<>& a0, const Matrix<>& b0, Matrix<>& Lambda, - Matrix<>& gamma, const Matrix<>& ncateg, + Matrix<>& gamma, const Matrix& ncateg, const Matrix<>& Lambda_eq, const Matrix<>& Lambda_ineq, const Matrix<>& Lambda_prior_mean, @@ -87,7 +87,7 @@ const unsigned int tot_iter = burnin + mcmc; const unsigned int nsamp = mcmc / thin; const Matrix<> I = eye(D-1); - const Matrix<> Lambda_free_indic(K, D); + const Matrix Lambda_free_indic(K, D); for (unsigned int i=0; i<(K*D); ++i){ if (Lambda_eq(i) == -999) Lambda_free_indic(i) = 1.0; } --- MCMCpack/src/MCMCpoissonChange.cc.orig Sun Aug 2 07:38:09 2009 +++ MCMCpack/src/MCMCpoissonChange.cc Mon Jan 11 21:49:14 2010 @@ -207,12 +207,12 @@ } -template +template Matrix<> poisson_reg_state_sampler(rng& stream, const int m, const Matrix<>& Y, const Matrix<>& X, - const Matrix<>& beta, + const Matrix& beta, const Matrix<>& P){ const int ns = m + 1; --- MCMCpack/src/smath.h.orig Mon Aug 18 18:37:44 2008 +++ MCMCpack/src/smath.h Tue Jan 12 01:30:53 2010 @@ -66,7 +66,11 @@ NAME (const Matrix& A) \ { \ Matrix res(A.rows(), A.cols(), false); \ - std::transform(A.begin_f(), A.end_f(), res.begin_f(), OP); \ + typename Matrix::forward_iterator rit = res.begin_f(); \ + const_matrix_forward_iterator pit = A.template begin_f(); \ + const_matrix_forward_iterator last = A.template end_f(); \ + for (; pit != last; pit++) \ + *rit++ = OP (*pit); \ return res; \ } \ \ @@ -94,17 +98,32 @@ Matrix res; \ \ if (A.size() == 1) { \ + typename Matrix::forward_iterator rit; \ + const_matrix_forward_iterator bit = B.template begin_f(); \ + const_matrix_forward_iterator last = B.template end_f(); \ + double val = A(0); \ res.resize2Match(B); \ - std::transform(B.template begin_f(), B.template end_f(),\ - res.begin_f(), std::bind1st(OP, A(0))); \ + rit = res.begin_f(); \ + for (; bit != last; bit++) \ + *rit++ = OP(val, *bit); \ } else if (B.size() == 1) { \ + typename Matrix::forward_iterator rit; \ + const_matrix_forward_iterator ait = A.template begin_f(); \ + const_matrix_forward_iterator last = A.template end_f(); \ + double val = B(0); \ res.resize2Match(A); \ - std::transform(A.template begin_f(), A.template end_f(),\ - res.begin_f(), std::bind2nd(OP, B(0))); \ + rit = res.begin_f(); \ + for (; ait != last; ait++) \ + *rit++ = OP(*ait, val); \ } else { \ + typename Matrix::forward_iterator rit; \ + const_matrix_forward_iterator ait = A.template begin_f(); \ + const_matrix_forward_iterator last = A.template end_f(); \ + const_matrix_forward_iterator bit = B.template begin_f(); \ res.resize2Match(A); \ - std::transform(A.template begin_f(), A.template end_f(),\ - B.template begin_f(), res.begin_f(), OP); \ + rit = res.begin_f(); \ + for (; ait != last; ait++, bit++) \ + *rit++ = OP(*ait, *bit); \ } \ \ return res; \ @@ -329,7 +348,7 @@ * \see atanh() */ - SCYTHE_MATH_OP_2ARG(atan2, std::ptr_fun(::atan2)) + SCYTHE_MATH_OP_2ARG(atan2, ::atan2) /* calc the cube root of each element of a Matrix */ /*! @@ -373,7 +392,7 @@ * \param B The matrix whose signs will comprise the resultant matrix */ - SCYTHE_MATH_OP_2ARG(copysign, std::ptr_fun(::copysign)) + SCYTHE_MATH_OP_2ARG(copysign, ::copysign) /* calc the cosine of each element of a Matrix */ @@ -515,7 +534,7 @@ * \param B the matrix to serve as divisor */ - SCYTHE_MATH_OP_2ARG(fmod, std::ptr_fun(::fmod)) + SCYTHE_MATH_OP_2ARG(fmod, ::fmod) /* calc the fractional val of input and return exponents in int * matrix reference @@ -565,7 +584,7 @@ * \param B Input matrix */ - SCYTHE_MATH_OP_2ARG(hypot, std::ptr_fun(::hypot)) + SCYTHE_MATH_OP_2ARG(hypot, ::hypot) /* return (int) logb */ SCYTHE_MATH_OP(ilogb, ::ilogb) @@ -626,7 +645,7 @@ * \see yn() */ - SCYTHE_MATH_OP_2ARG(jn, std::ptr_fun(::jn)) + SCYTHE_MATH_OP_2ARG(jn, ::jn) /* calc x * 2 ^ex */ /*! @@ -638,7 +657,7 @@ * \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)) + SCYTHE_MATH_OP_2ARG(ldexp, ::ldexp) /* compute the natural log of the absval of gamma function */ @@ -759,10 +778,10 @@ * \param A Matrix to be exponentiated * \param ex Desired exponent */ - SCYTHE_MATH_OP_2ARG(pow, std::ptr_fun(::pow)) + SCYTHE_MATH_OP_2ARG(pow, ::pow) /* calc rem == x - n * y */ - SCYTHE_MATH_OP_2ARG(remainder, std::ptr_fun(::remainder)) + SCYTHE_MATH_OP_2ARG(remainder, ::remainder) /* return x rounded to nearest int */ @@ -778,7 +797,7 @@ SCYTHE_MATH_OP(rint, ::rint) /* returns x * FLT_RADIX^ex */ - SCYTHE_MATH_OP_2ARG(scalbn, std::ptr_fun(::scalbn)) + SCYTHE_MATH_OP_2ARG(scalbn, ::scalbn) /* calc the sine of x */ @@ -948,7 +967,7 @@ * \see y1() */ - SCYTHE_MATH_OP_2ARG(yn, std::ptr_fun(::yn)) + SCYTHE_MATH_OP_2ARG(yn, ::yn) } // end namespace scythe