From a98a1928ffa724fda21b0675e9cd51881ce2e6ad Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Fri, 15 Apr 2011 02:53:06 +0200 Subject: [PATCH 1/2] OSX build fixes --- include/mitsuba/core/chisquare.h | 2 +- src/phase/microflake_fiber.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/mitsuba/core/chisquare.h b/include/mitsuba/core/chisquare.h index a1147f91..cd73413e 100644 --- a/include/mitsuba/core/chisquare.h +++ b/include/mitsuba/core/chisquare.h @@ -267,7 +267,7 @@ protected: const boost::function &pdfFn, size_t nPts, const Float *in, Float *out) { #pragma omp parallel for - for (size_t i=0; i Date: Fri, 15 Apr 2011 02:55:24 +0200 Subject: [PATCH 2/2] uflake fitting utility --- src/utils/uflakefit.cpp | 199 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100644 src/utils/uflakefit.cpp diff --git a/src/utils/uflakefit.cpp b/src/utils/uflakefit.cpp new file mode 100644 index 00000000..c650d349 --- /dev/null +++ b/src/utils/uflakefit.cpp @@ -0,0 +1,199 @@ +/* + This file is part of Mitsuba, a physically based rendering system. + + Copyright (c) 2007-2010 by Wenzel Jakob and others. + + Mitsuba is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License Version 3 + as published by the Free Software Foundation. + + Mitsuba 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 . +*/ + +#include +#include +#include +#include +#include +#include +#include "/Users/wenzel/mitsuba/lookup.h" + +MTS_NAMESPACE_BEGIN + +class UFlakeFit : public Utility { +public: + struct Reference { + Reference(size_t res, size_t nSines) : m_res(res), m_sines(nSines) { + m_directions = new Vector[m_res]; + m_result = new Float[m_res]; + m_error = new Float[m_res]; + for (size_t i=0; i timer = new Timer(); + Float base = refAvgAbsErr; + do { + min[0] = M_PI/2 * (1.0 - std::pow((Float) 2, - (Float) attempt)), + max[0] = M_PI/2 * (1.0 + std::pow((Float) 2, - (Float) attempt)); + NDIntegrator quad(m_res, 2, 200000, 0, 1e-8f); + quad.integrateVectorized(boost::bind( + &Reference::f, this, _1, _2, _3), min, max, m_result, m_error, evals); + Float maxError = 0; + for (size_t i=0; igetMilliseconds()); + ++attempt; + } while (evals < 20000); + + Eigen::MatrixXd A(m_res, m_sines); + Eigen::VectorXd b(m_res); + for (size_t i=0; i