| 1 |
#ifndef FARRAY_H |
| 2 |
#define FARRAY_H |
| 3 |
|
| 4 |
#include <stdexcept> |
| 5 |
#include <string> |
| 6 |
|
| 7 |
class Farray |
| 8 |
{ |
| 9 |
public: |
| 10 |
|
| 11 |
// Size constructor |
| 12 |
Farray(int nrows, int ncols); |
| 13 |
|
| 14 |
// Copy constructor |
| 15 |
Farray(const Farray & source); |
| 16 |
|
| 17 |
// Destructor |
| 18 |
~Farray(); |
| 19 |
|
| 20 |
// Assignment operator |
| 21 |
Farray & operator=(const Farray & source); |
| 22 |
|
| 23 |
// Equals operator |
| 24 |
bool operator==(const Farray & other) const; |
| 25 |
|
| 26 |
// Length accessors |
| 27 |
int nrows() const; |
| 28 |
int ncols() const; |
| 29 |
|
| 30 |
// Set item accessor |
| 31 |
long & operator()(int i, int j); |
| 32 |
|
| 33 |
// Get item accessor |
| 34 |
const long & operator()(int i, int j) const; |
| 35 |
|
| 36 |
// String output |
| 37 |
std::string asString() const; |
| 38 |
|
| 39 |
// Get view |
| 40 |
void view(int* nrows, int* ncols, long** data) const; |
| 41 |
|
| 42 |
private: |
| 43 |
// Members |
| 44 |
int _nrows; |
| 45 |
int _ncols; |
| 46 |
long * _buffer; |
| 47 |
|
| 48 |
// Default constructor: not implemented |
| 49 |
Farray(); |
| 50 |
|
| 51 |
// Methods |
| 52 |
void allocateMemory(); |
| 53 |
int offset(int i, int j) const; |
| 54 |
}; |
| 55 |
|
| 56 |
#endif |