1#ifndef UTIL_D_RAGGED_MATRIX_H
2#define UTIL_D_RAGGED_MATRIX_H
11#include <util/containers/RaggedMatrix.h>
12#include <util/containers/DArray.h>
23 template <
typename Data>
64 template <
typename Data>
72 template <
typename Data>
89 template <
typename Data>
93 UTIL_THROW(
"Attempt to re-allocate a RaggedMatrix");
96 UTIL_THROW(
"rowSizes.capacity() must be positive");
100 for (
int i = 0; i < rowSizes.
capacity(); ++i) {
102 UTIL_THROW(
"rowSizes must all be nonnegative");
107 UTIL_THROW(
"Sum of row sizes must be positive");
128 template <
class Data>
130 {
return !(
data_ == 0); }
int capacity() const
Return allocated size.
Dynamically allocatable contiguous array template.
bool isAllocated() const
Return true iff this DRaggedMatrix has been allocated.
void allocate(DArray< int > const &rowSizes)
Allocate memory for a ragged matrix.
~DRaggedMatrix()
Destructor.
DRaggedMatrix()
Constructor.
static void deallocate(Data *&ptr, size_t size)
Deallocate a C++ array.
static void allocate(Data *&ptr, size_t size)
Allocate a C++ array.
int capacity1_
Number of rows (range of first index).
int * capacity2_
Array containing number of elements in each row.
Data ** rows_
Array of pointers to rows.
int capacity_
Total number of elements.
RaggedMatrix()
Default constructor.
Data * data_
One-dimensional C array of all elements.
File containing preprocessor macros for error handling.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Utility classes for scientific computation.