1 #ifndef OMEGA_H_TABLE_HPP
2 #define OMEGA_H_TABLE_HPP
4 #include <Omega_h_std_vector.hpp>
13 using Ref =
typename std::vector<T>::reference;
14 using ConstRef =
typename std::vector<T>::const_reference;
16 Table(
int ncols_init,
int nrows_reserve) : ncols(ncols_init) {
17 OMEGA_H_CHECK(0 <= ncols_init);
18 reserve(data, ncols * nrows_reserve);
24 OMEGA_H_CHECK(t.ncols > 0);
25 OMEGA_H_CHECK(size(t.data) % t.ncols == 0);
26 return size(t.data) / t.ncols;
30 int get_ncols(Table<T>
const& t) {
35 void resize(Table<T>& t,
int new_nrows,
int new_ncols) {
36 OMEGA_H_CHECK(new_ncols == t.ncols);
37 Omega_h::resize(t.data, new_nrows * t.ncols);
41 typename Table<T>::Ref at(Table<T>& t,
int row,
int col) {
42 OMEGA_H_CHECK(0 <= col);
43 OMEGA_H_CHECK(col < t.ncols);
44 OMEGA_H_CHECK(0 <= row);
45 OMEGA_H_CHECK(row < get_nrows(t));
46 return Omega_h::at(t.data, row * t.ncols + col);
50 typename Table<T>::ConstRef at(Table<T>
const& t,
int row,
int col) {
51 OMEGA_H_CHECK(0 <= col);
52 OMEGA_H_CHECK(col < t.ncols);
53 OMEGA_H_CHECK(0 <= row);
54 OMEGA_H_CHECK(row < get_nrows(t));
55 return Omega_h::at(t.data, row * t.ncols + col);
Definition: amr_mpi_test.cpp:6
Definition: Omega_h_table.hpp:10