25 for (
int i = 0; i < size; i++)
28 if ( !((i+1) % width) || i+1 == size )
46 for (
int i = 0; i < size; i++)
48 os << operator[](i) <<
'\n';
61 for (
int i = 0; i < size; i++)
70 MFEM_ASSERT(size > 0,
"Array is empty with size " << size);
72 T max = operator[](0);
73 for (
int i = 1; i < size; i++)
75 if (max <
operator[](i))
87 MFEM_ASSERT(size > 0,
"Array is empty with size " << size);
89 T min = operator[](0);
90 for (
int i = 1; i < size; i++)
92 if (
operator[](i) < min)
105 T sum =
static_cast<T
>(0);
106 for (
int i = 0; i < size; i++)
117 T sum =
static_cast<T
>(0);
118 for (
int i = 0; i < size; i++)
129 T val_prev = operator[](0), val;
130 for (
int i = 1; i < size; i++)
148 in.open(filename, std::ifstream::in);
149 MFEM_VERIFY(in.is_open(),
"File " << filename <<
" does not exist.");
157 int height = this->NumRows();
158 int width = this->NumCols();
160 for (
int i = 0; i < height; i++)
162 os <<
"[row " << i <<
"]\n";
163 for (
int j = 0; j < width; j++)
166 if ( (j+1) == width_ || (j+1) % width_ == 0 )
Dynamic 2D array using row-major layout.
void Load(std::istream &in, int fmt=0)
Read an Array2D from the stream in using format fmt. The format fmt can be:
void Print(std::ostream &out=mfem::out, int width=4)
Prints array to stream with width elements per row.
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
void Load(std::istream &in, int fmt=0)
Read an Array from the stream in using format fmt. The format fmt can be:
T Sum()
Return the sum of all the array entries using the '+'' operator for class 'T'.
T Min() const
Find the minimal element in the array, using the comparison operator < for class T.
void PartialSum()
Fill the entries of the array with the cumulative sum of the entries.
int IsSorted() const
Return 1 if the array is sorted from lowest to highest. Otherwise return 0.
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:
void Print(std::ostream &out=mfem::out, int width=4) const
Prints array to stream with width elements per row.