Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 09:41:22

0001 // Copyright Nick Thompson, 2021
0002 // Use, modification and distribution are subject to the
0003 // Boost Software License, Version 1.0.
0004 // (See accompanying file LICENSE_1_0.txt
0005 // or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 // This implements bilinear interpolation on a uniform grid.
0008 // If dx and dy are both positive, then the (x,y) = (x0, y0) is associated with data index 0 (herein referred to as f[0])
0009 // The point (x0 + dx, y0) is associated with f[1], and (x0 + i*dx, y0) is associated with f[i],
0010 // i.e., we are assuming traditional C row major order.
0011 // The y coordinate increases *downward*, as is traditional in 2D computer graphics.
0012 // This is *not* how people generally think in numerical analysis (although it *is* how they lay out matrices).
0013 // Providing the capability of a grid rotation is too expensive and not ergonomic; you'll need to perform any rotations at the call level.
0014 
0015 // For clarity, the value f(x0 + i*dx, y0 + j*dy) must be stored in the f[j*cols + i] position.
0016 
0017 #ifndef BOOST_MATH_INTERPOLATORS_BILINEAR_UNIFORM_HPP
0018 #define BOOST_MATH_INTERPOLATORS_BILINEAR_UNIFORM_HPP
0019 
0020 #include <utility>
0021 #include <memory>
0022 #include <boost/math/interpolators/detail/bilinear_uniform_detail.hpp>
0023 
0024 namespace boost::math::interpolators {
0025 
0026 template <class RandomAccessContainer>
0027 class bilinear_uniform
0028 {
0029 public:
0030     using Real = typename RandomAccessContainer::value_type;
0031     using Z = typename RandomAccessContainer::size_type;
0032 
0033     bilinear_uniform(RandomAccessContainer && fieldData, Z rows, Z cols, Real dx = 1, Real dy = 1, Real x0 = 0, Real y0 = 0)
0034     : m_imp(std::make_shared<detail::bilinear_uniform_imp<RandomAccessContainer>>(std::move(fieldData), rows, cols, dx, dy, x0, y0))
0035     {
0036     }
0037 
0038     Real operator()(Real x, Real y) const
0039     {
0040         return m_imp->operator()(x,y);
0041     }
0042 
0043 
0044     friend std::ostream& operator<<(std::ostream& out, bilinear_uniform<RandomAccessContainer> const & bu) {
0045         out << *bu.m_imp;
0046         return out;
0047     }
0048 
0049 private:
0050     std::shared_ptr<detail::bilinear_uniform_imp<RandomAccessContainer>> m_imp;
0051 };
0052 
0053 }
0054 #endif