1#ifndef TEUCHOS_TABLE_HPP
2#define TEUCHOS_TABLE_HPP
4#include "Teuchos_TableDecl.hpp"
5#include "Teuchos_Assert.hpp"
6#include "Teuchos_vector.hpp"
16Table<T>::Table(
int ncols_init,
int nrows_reserve):ncols(ncols_init) {
18 reserve(data, ncols * nrows_reserve);
22void swap(Table<T>& a, Table<T>& b) {
25 swap(a.ncols, b.ncols);
29int get_nrows(Table<T>
const& t) {
30 TEUCHOS_DEBUG_ASSERT(t.ncols > 0);
31 TEUCHOS_DEBUG_ASSERT(Teuchos::size(t.data) % t.ncols == 0);
32 return Teuchos::size(t.data) / t.ncols;
36int get_ncols(Table<T>
const& t) {
return t.ncols; }
39void resize(Table<T>& t,
int new_nrows,
int new_ncols) {
41 Teuchos::resize(t.data, new_nrows * t.ncols);
45typename Table<T>::Ref at(Table<T>& t,
int row,
int col) {
46 TEUCHOS_DEBUG_ASSERT(0 <= col);
47 TEUCHOS_DEBUG_ASSERT(col < t.ncols);
48 TEUCHOS_DEBUG_ASSERT(0 <= row);
49 TEUCHOS_DEBUG_ASSERT(row < get_nrows(t));
50 return Teuchos::at(t.data, row * t.ncols + col);
54typename Table<T>::ConstRef at(Table<T>
const& t,
int row,
int col) {
55 TEUCHOS_DEBUG_ASSERT(0 <= col);
56 TEUCHOS_DEBUG_ASSERT(col < t.ncols);
57 TEUCHOS_DEBUG_ASSERT(0 <= row);
58 TEUCHOS_DEBUG_ASSERT(row < get_nrows(t));
59 return Teuchos::at(t.data, row * t.ncols + col);
#define TEUCHOS_ASSERT(assertion_test)
This macro is throws when an assert fails.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...