diff options
author | 2019-03-26 11:13:37 +1100 | |
---|---|---|
committer | 2019-03-26 11:13:37 +1100 | |
commit | 97b67170277437131adf6ed4d60139c172529e4f (patch) | |
tree | 7a5cbf608f191075f1612b1af15832c206a3fe2d /src/lib/netlist/plib/pmatrix2d.h | |
parent | b380514764cf857469bae61c11143a19f79a74c5 (diff) |
(nw) Clean up the mess on master
This effectively reverts b380514764cf857469bae61c11143a19f79a74c5 and
c24473ddff715ecec2e258a6eb38960cf8c8e98e, restoring the state at
598cd5227223c3b04ca31f0dbc1981256d9ea3ff.
Before pushing, please check that what you're about to push is sane.
Check your local commit log and ensure there isn't anything out-of-place
before pushing to mainline. When things like this happen, it wastes
everyone's time. I really don't need this in a week when real work⢠is
busting my balls and I'm behind where I want to be with preparing for
MAME release.
Diffstat (limited to 'src/lib/netlist/plib/pmatrix2d.h')
-rw-r--r-- | src/lib/netlist/plib/pmatrix2d.h | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/src/lib/netlist/plib/pmatrix2d.h b/src/lib/netlist/plib/pmatrix2d.h new file mode 100644 index 00000000000..eab533688d7 --- /dev/null +++ b/src/lib/netlist/plib/pmatrix2d.h @@ -0,0 +1,85 @@ +// license:GPL-2.0+ +// copyright-holders:Couriersud +/* + * pmatrix2d.h + * + * NxM regular matrix + * + */ + +#ifndef PMATRIX2D_H_ +#define PMATRIX2D_H_ + +#include "palloc.h" + +#include <algorithm> +#include <cmath> +#include <cstdlib> +#include <type_traits> +#include <vector> + +namespace plib +{ + + + template<typename T, typename A = aligned_allocator<T>> + class pmatrix2d + { + public: + using value_type = T; + using allocator_type = A; + + static constexpr const std::size_t align_size = align_traits<A>::align_size; + static constexpr const std::size_t stride_size = align_traits<A>::stride_size; + pmatrix2d() + : m_N(0), m_M(0), m_stride(8), m_v() + { + } + + pmatrix2d(std::size_t N, std::size_t M) + : m_N(N), m_M(M), m_v() + { + m_stride = ((M + stride_size-1) / stride_size) * stride_size; + m_v.resize(N * m_stride); + } + + void resize(std::size_t N, std::size_t M) + { + m_N = N; + m_M = M; + m_stride = ((M + stride_size-1) / stride_size) * stride_size; + m_v.resize(N * m_stride); + } + + C14CONSTEXPR T * operator[] (std::size_t row) noexcept + { + return assume_aligned_ptr<T, align_size>(&m_v[m_stride * row]); + } + + constexpr const T * operator[] (std::size_t row) const noexcept + { + return assume_aligned_ptr<T, align_size>(&m_v[m_stride * row]); + } + + T & operator()(std::size_t r, std::size_t c) noexcept + { + return (*this)[r][c]; + } + + const T & operator()(std::size_t r, std::size_t c) const noexcept + { + return (*this)[r][c]; + } + + private: + + std::size_t m_N; + std::size_t m_M; + std::size_t m_stride; + + std::vector<T, A> m_v; + }; + +} // namespace plib + +#endif /* MAT_CR_H_ */ |