45 explicit VectorImage(
size_t n_rows,
size_t n_cols,
46 const T* value_init = Image<T, VectorImage<T>>::_value_default_ptr(),
47 std::shared_ptr<const CoordinateSystem> coordsys =
nullptr)
48 : Image<T, VectorImage<T>>(coordsys), _n_rows(n_rows), _n_cols(n_cols) {
53 = value_init !=
nullptr ? *value_init : (Image<T, VectorImage<T>>::_value_default);
54 for (
size_t row = 0; row < _n_rows; row++) {
55 _data[row].resize(n_cols, value_init_override);
58 ~VectorImage() =
default;
60 T& _get_value_impl(
size_t row,
size_t col) {
64 if constexpr (std::is_same_v<bool, T>) {
65 throw std::logic_error(
"VectorImage<bool> cannot use _get_value");
68 return this->_data.at(row).at(col);
71 inline T& _get_value_unchecked_impl(
size_t row,
size_t col) {
73 if constexpr (std::is_same_v<bool, T>) {
74 throw std::logic_error(
"VectorImage<bool> cannot use _get_value_unchecked");
76 return this->_data[row][col];
79 void add_value_unchecked_impl(
size_t row,
size_t col, T value) { this->_data[row][col] += value; }
80 inline T get_value_unchecked_impl(
size_t row,
size_t col)
const {
return this->_data[row][col]; }
81 inline void set_value_impl(
size_t row,
size_t col, T value) { this->_data.at(row).at(col) = value; }
82 inline void set_value_unchecked_impl(
size_t row,
size_t col, T value) { this->_data[row][col] = value; }
84 size_t get_n_cols_impl()
const {
return _n_cols; };
85 size_t get_n_rows_impl()
const {
return _n_rows; };
92 std::vector<std::deque<T>> _data;