|
Open Graph Drawing Framework |
v. 2023.09 (Elderberry)
|
|
|
Go to the documentation of this file.
41 #include <type_traits>
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);
200 void construct(
int a,
int b,
int c,
int d);
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();
Array2D()
Creates a two-dimensional array with empty index set.
The namespace for all OGDF objects.
int size() const
Returns the size (number of elements) of the array.
float det() const
Returns the determinant of the matrix.
int high2() const
Returns the maximal array index in dimension 2.
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...
Definition of exception classes.
void deconstruct()
Call destructor of all elements.
void construct(int a, int b, int c, int d)
Constructs the array with index set [a, ..., b]*[c, ..., d].
int size2() const
Returns the length of the index interval (number of entries) in dimension 2.
Exception thrown when not enough memory is available to execute an algorithm.
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
int m_c
The lowest index in dimension 2.
Array2D(const Array2D< E > &A)
Creates a two-dimensional array that is a copy of A.
The parameterized class Array2D implements dynamic two-dimensional arrays.
void initialize()
Initializes the array with default constructor of E.
Array2D(int a, int b, int c, int d)
Creates a two-dimensional array with index set [a, ..., b]*[c, ..., d].
void fill(const E &x)
Sets all elements to x.
E & operator()(int i, int j)
Returns a reference to the element with index (i,j).
Array2D(Array2D< E > &&A)
Creates a two-dimensional array containing the elements of A (move semantics).
void init()
Reinitializes the array to an array with empty index set.
int high1() const
Returns the maximal array index in dimension 1.
int m_a
The lowest index in dimension 1.
int m_b
The highest index in dimension 1.
#define OGDF_THROW(CLASS)
Replacement for throw.
int low1() const
Returns the minimal array index in dimension 1.
Array2D< E > & operator=(const Array2D< E > &array2)
Assignment operator.
int m_d
The highest index in dimension 2.
E * m_pStart
The real start of the array (address of A[low1,low2]).
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...
int size1() const
Returns the length of the index interval (number of entries) in dimension 1.
void copy(const Array2D< E > &array2)
Copy array2.
int low2() const
Returns the minimal array index in dimension 2.
Basic declarations, included by all source files.
E * m_vpStart
The virtual start of the array (address of A[0,0]).
void init(int a, int b, int c, int d)
Reinitializes the array to an array with index set [a, ..., b]*[c, ..., d].
const E & operator()(int i, int j) const
Returns a reference to the element with index (i,j).
E * m_pStop
Successor of last element (address of A[high1,high2+1]).
int m_lenDim2
The number of elements in dimension 2.
Array2D< E > & operator=(Array2D< E > &&A)
Assignment operator (move semantics).