25 data =
new char[asize * elementsize];
40 delete [] (
char*)
data;
48 if (nsize < minsize) { nsize = minsize; }
50 p =
new char[nsize * elementsize];
57 delete [] (
char*)
data;
66 for (
int i = 0; i < size; i++)
69 if ( !((i+1) % width) || i+1 == size )
87 for (
int i = 0; i < size; i++)
89 out << operator[](i) <<
'\n';
102 for (
int i = 0; i < size; i++)
111 MFEM_ASSERT(size > 0,
"Array is empty with size " << size);
113 T max = operator[](0);
114 for (
int i = 1; i < size; i++)
115 if (max <
operator[](i))
126 MFEM_ASSERT(size > 0,
"Array is empty with size " << size);
128 T min = operator[](0);
129 for (
int i = 1; i < size; i++)
130 if (
operator[](i) < min)
142 T sum =
static_cast<T
>(0);
143 for (
int i = 0; i < size; i++)
154 T sum =
static_cast<T
>(0);
155 for (
int i = 0; i < size; i++)
166 T val_prev = operator[](0), val;
167 for (
int i = 1; i < size; i++)
185 in.open(filename, std::ifstream::in);
186 MFEM_VERIFY(in.is_open(),
"File " << filename <<
" does not exist.");
194 int height = this->NumRows();
195 int width = this->NumCols();
197 for (
int i = 0; i < height; i++)
199 out <<
"[row " << i <<
"]\n";
200 for (
int j = 0; j < width; j++)
203 if ( (j+1) == width_ || (j+1) % width_ == 0 )
void Load(std::istream &in, int fmt=0)
Read an Array from the stream in using format fmt. The format fmt can be:
~BaseArray()
Free the allocated memory.
void * data
Pointer to data.
void Load(std::istream &in, int fmt=0)
Read an Array2D from the stream in using format fmt. The format fmt can be:
void Save(std::ostream &out, int fmt=0) const
Save the Array to the stream out using the format fmt. The format fmt can be:
T Min() const
Find the minimal element in the array, using the comparison operator < for class T.
void GrowSize(int minsize, int elementsize)
int size
Size of the array.
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
int allocsize
Size of the allocated memory.
void Print(std::ostream &out=mfem::out, int width=4)
Prints array to stream with width elements per row.
int IsSorted()
return true if the array is sorted.
void PartialSum()
Partial Sum.
void Print(std::ostream &out=mfem::out, int width=4) const
Prints array to stream with width elements per row.
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...