105 void Resize(
const int& nx,
const int& ny) {
113 void Resize(
const int& nx,
const int& ny,
const T& t) {
122 for(
int i=0; i <
data_.size(); i++){
159 for(
int iy=0;iy<
ysize_;iy++){
160 for(
int i=0; i < ix; i++)
163 for(
int i=ix+1; i <
xsize_; i++)
178 int insx=insarr.
XSize();
183 for(
int iy=0;iy<
ysize_;iy++){
184 for(
int i=0; i < ix; i++)
186 for(
int i=ix; i < ix+insx; i++)
188 for(
int i=ix+insx; i <
xsize_; i++)
204 for(
int iy=0;iy<
ysize_;iy++){
205 for(
int i=0; i < ix; i++)
207 for(
int i=ix; i <
xsize_; i++)
238 int insy=insarr.
YSize();
287 for (
int iy = 0; iy <
ysize_; iy++){
296 s[0] =
this ->
XSize();
297 s[1] =
this ->
YSize();
304 for (
int i = 0; i <
ysize_; i++){
314 f_out = fopen(filename,
"wb");
326 f_in = fopen(filename,
"rb");
337 f_out.open(filename, ios::out | ios::binary);
348 f_in.open(filename, ios::in | ios::binary);
365 data_.assign(inarray,inarray+n1*n2);
378 data_.assign(inarray,inarray+n1*n2);
387 T&
at(
int ix,
int iy){
398 const char* s =
typeid(
data_[0]).name();
399 if (
string(s) ==
string(
"Ss") ){
402 else if (strcmp(s,
"i") == 0){
411 void assign(
const int x,
const int y,
const T val){
1D Array class for any type T
Stores data of any type T in a 1D array.
Definition Array1D.h:61
T * GetArrayPointer()
Return a pointer to the first element of the data in the vector so we can use it access the data in a...
Definition Array1D.h:138
Stores data of any type T in a 2D array.
Definition Array2D.h:60
void Resize(const int &nx, const int &ny)
Resizes the array.
Definition Array2D.h:105
Array2D(const int &nx, const int &ny)
Constructor that allocates the memory.
Definition Array2D.h:76
void ReadBinary4py(char *filename, int n1, int n2)
Definition Array2D.h:344
void getRow(int row)
Definition Array2D.h:301
void insertRow(Array2D< T > &insarr, int ix)
Insert a 2d-array insarr into a row position ix.
Definition Array2D.h:169
void eraseRow(int ix)
Erase the row ix.
Definition Array2D.h:194
void setArray(vector< T > inarray)
Definition Array2D.h:355
void setnpintArray(long *inarray, int n1, int n2)
Definition Array2D.h:375
~Array2D()
Destructor that frees up the memory.
Definition Array2D.h:89
vector< int > shape()
Definition Array2D.h:294
T & operator()(int ix, int iy)
C-like () operator to access values in the 2D data array.
Definition Array2D.h:143
void insertRow(Array1D< T > &insarr, int ix)
Insert array insarr as a row into position ix.
Definition Array2D.h:147
Array2D(const Array2D &obj)
Copy constructor.
Definition Array2D.h:86
int ysize_
Definition Array2D.h:67
const T & operator()(int ix, int iy) const
Definition Array2D.h:144
void setnpdblArray(double *inarray, int n1, int n2)
Definition Array2D.h:362
void DumpBinary(char *filename)
Definition Array2D.h:312
Array2D(const int &nx, const int &ny, const T &t)
Constructor that allocates and initializes the data to a constant t.
Definition Array2D.h:81
void getnpdblArray(double *outarray)
Definition Array2D.h:369
Array2D()
Default constructor, which does not allocate any memory.
Definition Array2D.h:73
void ReadBinary(FILE *f_in)
Read contents of the array from a file in binary format.
Definition Array2D.h:269
int xsize_
Definition Array2D.h:66
vector< T > data_
Definition Array2D.h:68
void insertCol(Array1D< T > &insarr, int iy)
Definition Array2D.h:217
T & at(int ix, int iy)
Definition Array2D.h:387
Array1D< T > & operator[](int ix)
Definition Array2D.h:283
const T * GetConstArrayPointer() const
Return a cont point to the first element of the data in the vector so we can use it access the data i...
Definition Array2D.h:137
int YSize() const
Returns size in the y-direction.
Definition Array2D.h:101
Array1D< T > arraycopy
Definition Array2D.h:69
void ReadBinary(char *filename)
Definition Array2D.h:324
void insertCol(Array2D< T > &insarr, int iy)
Insert a 2d-array insarr into a column position iy.
Definition Array2D.h:232
string type()
Definition Array2D.h:397
void assign(const int x, const int y, const T val)
Definition Array2D.h:411
Array1D< T > rowvec
Definition Array2D.h:70
void getnpintArray(long *outarray)
Definition Array2D.h:382
void DumpBinary(FILE *f_out) const
Dump contents of the array to a file in binary format.
Definition Array2D.h:261
void eraseCol(int iy)
Erase the column iy.
Definition Array2D.h:247
void SetValue(const T &t)
Set all values in the array to the given value.
Definition Array2D.h:121
void Clear()
Function to clear the memory.
Definition Array2D.h:92
void DumpBinary4py(char *filename)
Definition Array2D.h:335
T * GetArrayPointer()
Return a pointer to the first element of the data in the vector so we can use it access the data in a...
Definition Array2D.h:130
int XSize() const
Returns size in the x-direction.
Definition Array2D.h:99
vector< T > flatten()
Definition Array2D.h:393
void Resize(const int &nx, const int &ny, const T &t)
Resizes the array and sets ALL entries to the specified value.
Definition Array2D.h:113