Go to the documentation of this file.
22#ifndef NRLIB_GRID4D_HPP
23#define NRLIB_GRID4D_HPP
34 typedef typename std::vector<A>::iterator iterator;
36 typedef typename std::vector<A>::reference reference;
41 Grid4D( size_t ni, size_t nj, size_t nk, size_t nl, const A& val = A());
47 void Resize( size_t ni, size_t nj, size_t nk, size_t nl, const A& val = A());
61 size_t GetNI() const { return(ni_); }
62 size_t GetNJ() const { return(nj_); }
63 size_t GetNK() const { return(nk_); }
64 size_t GetNL() const { return(nl_); }
65 size_t GetN() const { return data_.size(); }
67 inline size_t GetIndex( size_t i, size_t j, size_t k, size_t l) const;
68 void GetIJKL( size_t index, size_t &i, size_t &j, size_t &k, size_t &l) const;
97 data_(ni*nj*nk*nl, val)
113 data_.resize(ni_ * nj_ * nk_ * nl, val);
120 return data_[GetIndex(i, j, k, l)];
127 assert( index < GetN());
136 return data_[GetIndex(i, j, k, l)];
143 assert( index < GetN());
152 assert(i < GetNI() && j < GetNJ() && k < GetNK() && l < GetNL());
154 return i + j*ni_ + k*ni_*nj_ + l*ni_*nj_*nk_;
160 assert( index < GetN());
163 j = ( index-i)/ni_ % nj_;
164 k = ( index - j*ni_ - i)/ni_/nj_;
165 l = ( index - k*ni_*nj_)/ni_/nj_/nk_;
171 std::swap(ni_, other.ni_);
172 std::swap(nj_, other.nj_);
173 std::swap(nk_, other.nk_);
174 std::swap(nl_, other.nl_);
175 data_.swap(other.data_);
int index Definition: cJSON.h:168
Definition: grid4d.hpp:32
void GetIJKL(size_t index, size_t &i, size_t &j, size_t &k, size_t &l) const Definition: grid4d.hpp:158
std::vector< A >::reference reference Definition: grid4d.hpp:36
std::vector< A >::iterator iterator Definition: grid4d.hpp:34
size_t GetNJ() const Definition: grid4d.hpp:62
size_t GetN() const Definition: grid4d.hpp:65
size_t GetNK() const Definition: grid4d.hpp:63
void Resize(size_t ni, size_t nj, size_t nk, size_t nl, const A &val=A()) Definition: grid4d.hpp:105
size_t GetIndex(size_t i, size_t j, size_t k, size_t l) const Definition: grid4d.hpp:150
iterator end() Definition: grid4d.hpp:56
size_t GetNI() const Definition: grid4d.hpp:61
virtual ~Grid4D() Definition: grid4d.hpp:101
const_iterator end() const Definition: grid4d.hpp:59
size_t GetNL() const Definition: grid4d.hpp:64
reference operator()(size_t i, size_t j, size_t k, size_t l) Definition: grid4d.hpp:118
const_iterator begin() const Definition: grid4d.hpp:58
std::vector< A >::const_iterator const_iterator Definition: grid4d.hpp:35
void Swap(Grid4D< A > &other) Definition: grid4d.hpp:169
Grid4D() Definition: grid4d.hpp:83
iterator begin() Definition: grid4d.hpp:55
std::vector< A >::const_reference const_reference Definition: grid4d.hpp:37
Definition: exception.hpp:31
|