67 Array2D(
int a,
int b,
int c,
int d,
const E& x) {
88 A.construct(0, -1, 0, -1);
141 void init(
int a,
int b,
int c,
int d) {
148 void init(
int a,
int b,
int c,
int d,
const E& x) {
177 A.construct(0, -1, 0, -1);
218 size_t lenDim1 = b - a + 1;
219 m_lenDim2 = d - c + 1;
221 if (lenDim1 < 1 || m_lenDim2 < 1) {
222 m_pStart = m_vpStart = m_pStop =
nullptr;
225 size_t len = lenDim1 * m_lenDim2;
226 m_pStart =
static_cast<E*
>(malloc(len *
sizeof(E)));
227 if (m_pStart ==
nullptr) {
231 m_vpStart = m_pStart - c;
232 m_pStop = m_pStart + len;
241 for (; pDest < m_pStop; pDest++) {
245 while (--pDest >= m_pStart) {
258 for (; pDest < m_pStop; pDest++) {
262 while (--pDest >= m_pStart) {
273 if (!std::is_trivially_destructible<E>::value) {
274 for (E* pDest = m_pStart; pDest < m_pStop; pDest++) {
284 construct(array2.
m_a, array2.
m_b, array2.
m_c, array2.
m_d);
289 while (pDest > m_pStart) {
290 new (--pDest) E(*--pSrc);
310 float determinant = 0.0;
316 determinant = (float)((*
this)(a, c));
319 determinant = (float)((*
this)(a, c) * (*
this)(b, d) - (*
this)(a, d) * (*
this)(b, c));
325 for (column = c; column <= d; column++) {
328 for (i = a; i <= b; i++) {
329 for (j = c; j <= d; j++) {
330 if (i != a && j != column) {
331 remMatrix(rem_i, rem_j) = (*this)(i, j);
341 determinant += pow(-1.0, (a + column)) * (*this)(a, column) * remMatrix.
det();
Basic declarations, included by all source files.
The parameterized class Array2D implements dynamic two-dimensional arrays.
void init(int a, int b, int c, int d, const E &x)
Reinitializes the array to an array with index set [a, ..., b]*[c, ..., d] and initializes all entrie...
Array2D(int a, int b, int c, int d)
Creates a two-dimensional array with index set [a, ..., b]*[c, ..., d].
E * m_vpStart
The virtual start of the array (address of A[0,0]).
int size2() const
Returns the length of the index interval (number of entries) in dimension 2.
int high2() const
Returns the maximal array index in dimension 2.
Array2D(Array2D< E > &&A)
Creates a two-dimensional array containing the elements of A (move semantics).
int m_d
The highest index in dimension 2.
void init(int a, int b, int c, int d)
Reinitializes the array to an array with index set [a, ..., b]*[c, ..., d].
E * m_pStop
Successor of last element (address of A[high1,high2+1]).
void initialize()
Initializes the array with default constructor of E.
int m_lenDim2
The number of elements in dimension 2.
void deconstruct()
Call destructor of all elements.
int m_c
The lowest index in dimension 2.
E * m_pStart
The real start of the array (address of A[low1,low2]).
int high1() const
Returns the maximal array index in dimension 1.
const E & operator()(int i, int j) const
Returns a reference to the element with index (i,j).
void copy(const Array2D< E > &array2)
Copy array2.
float det() const
Returns the determinant of the matrix.
Array2D< E > & operator=(const Array2D< E > &array2)
Assignment operator.
int size1() const
Returns the length of the index interval (number of entries) in dimension 1.
void initialize(const E &x)
Initializes the array with x.
int low1() const
Returns the minimal array index in dimension 1.
E & operator()(int i, int j)
Returns a reference to the element with index (i,j).
Array2D< E > & operator=(Array2D< E > &&A)
Assignment operator (move semantics).
Array2D(const Array2D< E > &A)
Creates a two-dimensional array that is a copy of A.
void init()
Reinitializes the array to an array with empty index set.
Array2D(int a, int b, int c, int d, const E &x)
Creates a two-dimensional array with index set [a, ..., b]*[c, ..., d] and initailizes all elements w...
int size() const
Returns the size (number of elements) of the array.
Array2D()
Creates a two-dimensional array with empty index set.
void construct(int a, int b, int c, int d)
Constructs the array with index set [a, ..., b]*[c, ..., d].
int m_b
The highest index in dimension 1.
int low2() const
Returns the minimal array index in dimension 2.
int m_a
The lowest index in dimension 1.
void fill(const E &x)
Sets all elements to x.
Exception thrown when not enough memory is available to execute an algorithm.
Definition of exception classes.
#define OGDF_THROW(CLASS)
Replacement for throw.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
The namespace for all OGDF objects.