1 #ifndef CLASSIC_FArray2D_HH
2 #define CLASSIC_FArray2D_HH
39 template<
class T,
int M,
int N>
209 template <
class T,
int M,
int N>
215 template <
class T,
int M,
int N>
221 template<
class T,
int M,
int N>
227 template<
class T,
int M,
int N>
234 template <
class T,
int M,
int N>
236 if(r >= M || c >= N) {
237 throw CLRangeError(
"FArray2D::operator()",
"Index out of range.");
243 template <
class T,
int M,
int N>
245 if(r >= M || c >= N) {
246 throw CLRangeError(
"FArray2D::operator()",
"Index out of range.");
252 template <
class T,
int M,
int N>
258 template <
class T,
int M,
int N>
264 template <
class T,
int M,
int N>
270 template <
class T,
int M,
int N>
276 template <
class T,
int M,
int N>
282 template <
class T,
int M,
int N>
288 template <
class T,
int M,
int N>
294 template <
class T,
int M,
int N>
297 throw CLRangeError(
"FArray2D::row_begin()",
"Row index out of range.");
303 template <
class T,
int M,
int N>
306 throw CLRangeError(
"FArray2D::row_end()",
"Row index out of range.");
308 return data + N * (r + 1);
312 template <
class T,
int M,
int N>
315 throw CLRangeError(
"FArray2D::row_begin()",
"Row index out of range.");
321 template <
class T,
int M,
int N>
324 throw CLRangeError(
"FArray2D::row_end()",
"Row index out of range.");
326 return data + N * (r + 1);
330 template <
class T,
int M,
int N>
336 template <
class T,
int M,
int N>
342 template <
class T,
int M,
int N>
345 throw CLRangeError(
"FArray2D::col_begin()",
"Column index out of range.");
351 template <
class T,
int M,
int N>
354 throw CLRangeError(
"FArray2D::col_end()",
"Column index out of range.");
360 template <
class T,
int M,
int N>
363 throw CLRangeError(
"FArray2D::col_begin()",
"Column index out of range.");
369 template <
class T,
int M,
int N>
372 throw CLRangeError(
"FArray2D::col_end()",
"Column index out of range.");
378 template <
class T,
int M,
int N>
384 template <
class T,
int M,
int N>
390 template <
class T,
int M,
int N>
396 template <
class T,
int M,
int N>
402 template <
class T,
int M,
int N>
404 std::swap_ranges(col_begin(col1), col_end(col1), col_begin(col2));
408 template <
class T,
int M,
int N>
410 std::swap_ranges(row_begin(row1), row_end(row1), row_begin(row2));
414 template <
class T,
int M,
int N>
415 std::ostream &operator<<(std::ostream &os, const FArray2D<T, M, N> &v) {
417 std::streamsize old_prec = os.precision(12);
418 os.setf(std::ios::scientific, std::ios::floatfield);
420 for(
int i = 0; i < M; ++i) {
421 for(
int j = 0; j < N; ++j) {
422 os << std::setw(20) << v[i][j] <<
" ";
428 os.
setf(std::ios::fixed, std::ios::floatfield);
429 os.precision(old_prec);
434 #endif // CLASSIC_FArray2D_HH
void putRow(const FArray1D< T, N > &fromArray, int r)
Store row.
constexpr double c
The velocity of light in m/s.
and give any other recipients of the Program a copy of this License along with the Program You may charge a fee for the physical act of transferring a copy
T * row_iterator
Iterator for access by rows.
T & operator()(int r, int c)
Get element.
void getColumn(FArray1D< T, M > &toArray, int c) const
Fetch column.
Constant version of FSlice.
const FArray2D< T, M, N > & operator=(const FArray2D< T, M, N > &)
Assignment.
const T * const_row_iterator
Iterator for access by rows.
void getRow(FArray1D< T, N > &toArray, int r) const
Fetch row.
col_iterator col_begin(int c)
Get column iterator.
FmtFlags_t setf(FmtFlags_t setbits, FmtFlags_t field)
clearpage the user may choose between constant or variable radius This model includes fringe fields begin
Inform & endl(Inform &inf)
row_iterator row_end(int r)
Get row iterator.
T value_type
The value type of the array.
int ncols() const
Get number of columns.
row_iterator operator[](int r)
Get row iterator.
FArray2D()
Default constructor.
FSlice< T, N > col_iterator
Iterator for access by columns.
An iterator permitting to iterate with a stride different from 1.
col_iterator col_end(int c)
Get column iterator.
iterator end()
Get iterator pointing past end of array.
A templated representation for 2-dimensional arrays.
void swapRows(int r1, int r2)
Exchange rows.
iterator begin()
Get beginning of data.
void putColumn(const FArray1D< T, M > &fromArray, int c)
Store column.
row_iterator row_begin(int r)
Get row iterator.
FConstSlice< T, N > const_col_iterator
Iterator for access by columns.
T * iterator
Iterator for the array.
int nrows() const
Get number of rows.
A templated representation for one-dimensional arrays.
void swapColumns(int c1, int c2)
Exchange columns.
iterator end()
Get pointer past end of data.
int size() const
Get total size.
const T * const_iterator
Iterator for constant array.
iterator begin()
Get iterator pointing to beginning of array.