37#define G_OP_ADD "GNdarray::operator+=(GNdarray&)"
38#define G_OP_SUB "GNdarray::operator-=(GNdarray&)"
39#define G_OP_MUL "GNdarray::operator*=(GNdarray&)"
40#define G_OP_DIV "GNdarray::operator/=(GNdarray&)"
41#define G_SHAPE "GNdarray::shape(std::vector<int>&)"
42#define G_AT1 "GNdarray::at(int&)"
43#define G_AT2 "GNdarray::at(int&, int&)"
44#define G_AT3 "GNdarray::at(int&, int&, int&)"
45#define G_ATN "GNdarray::at(std::vector<int>&)"
140 int size = nx * ny * nz;
179 for (
int i = 1; i < n.size(); ++i) {
188 for (
int i = 0; i < n.size(); ++i) {
249 if (
this != &array) {
283 for (
int i = 0; i <
m_data.size(); ++i) {
328 for (
int i = 0; i <
m_data.size(); ++i) {
351 for (
int i = 0; i <
m_data.size(); ++i) {
374 for (
int i = 0; i <
m_data.size(); ++i) {
377 if (array.
m_data[i] != 0.0){
407 for (
int i = 0; i <
m_data.size(); ++i) {
427 for (
int i = 0; i <
m_data.size(); ++i) {
447 for (
int i = 0; i <
m_data.size(); ++i) {
467 for (
int i = 0; i <
m_data.size(); ++i) {
487 for (
int i = 0; i <
m_data.size(); ++i) {
509 for (
int i = 0; i <
m_data.size(); ++i) {
567 if (
shape.size() > 0) {
569 for (
int i = 0; i <
shape.size(); ++i) {
570 nelements *=
shape[i];
576 if (nelements !=
size()) {
577 std::string msg =
"Number of elements "+
gammalib::str(nelements)+
578 " in specified shape is not identical to the "
608 std::string msg =
"Invalid access of "+
610 "with 1-dimensional access operator.";
615 if (ix < 0 || ix >=
m_shape[0]) {
641 std::string msg =
"Invalid access of "+
643 "with 2-dimensional access operator.";
648 if (ix < 0 || ix >=
m_shape[0]) {
652 if (iy < 0 || iy >=
m_shape[1]) {
658 return (*
this)(ix,iy);
676const double&
GNdarray::at(
const int& ix,
const int& iy,
const int& iz)
const
680 std::string msg =
"Invalid access of "+
682 "with 3-dimensional access operator.";
687 if (ix < 0 || ix >=
m_shape[0]) {
691 if (iy < 0 || iy >=
m_shape[1]) {
695 if (iz < 0 || iz >=
m_shape[2]) {
701 return (*
this)(ix,iy,iz);
720 if (
m_shape.size() != i.size()) {
721 std::string msg =
"Invalid access of "+
730 for (
int k = 0; k <
m_shape.size(); ++k) {
731 if (i[k] < 0 || i[k] >=
m_shape[k]) {
760 for (
int k = 0; k <
m_shape.size(); ++k) {
778 std::string result =
"(";
784 for (
int i = 0; i <
m_data.size(); ++i) {
866 for (
int i = 0; i <
m_shape.size(); ++i) {
892 std::string msg =
"Incompatible array dimensions (";
893 for (
int i = 0; i <
m_shape.size(); ++i) {
900 for (
int i = 0; i < array.
m_shape.size(); ++i) {
936 if (array.
m_data.size() > 0) {
940 for (
int i = 1; i < array.
m_data.size(); ++i) {
941 if (array.
m_data[i] < result) {
965 if (array.
m_data.size() > 0) {
969 for (
int i = 1; i < array.
m_data.size(); ++i) {
970 if (array.
m_data[i] > result) {
992 for (
int i = 0; i < array.
m_data.size(); ++i) {
993 result += array.
m_data[i];
1013 for (
int i = 0; i < array.
m_data.size(); ++i) {
1034 for (
int i = 0; i < array.
m_data.size(); ++i) {
1055 for (
int i = 0; i < array.
m_data.size(); ++i) {
1076 for (
int i = 0; i < array.
m_data.size(); ++i) {
1097 for (
int i = 0; i < array.
m_data.size(); ++i) {
1118 for (
int i = 0; i < array.
m_data.size(); ++i) {
1139 for (
int i = 0; i < array.
m_data.size(); ++i) {
1160 for (
int i = 0; i < array.
m_data.size(); ++i) {
1181 for (
int i = 0; i < array.
m_data.size(); ++i) {
1202 for (
int i = 0; i < array.
m_data.size(); ++i) {
1223 for (
int i = 0; i < array.
m_data.size(); ++i) {
1244 for (
int i = 0; i < array.
m_data.size(); ++i) {
1247 double content = array.
m_data[i];
1253 if (content < 0.0) {
1256 else if (content > 0.0) {
1285 for (
int i = 0; i < array.
m_data.size(); ++i) {
1306 for (
int i = 0; i < array.
m_data.size(); ++i) {
1327 for (
int i = 0; i < array.
m_data.size(); ++i) {
1348 for (
int i = 0; i < array.
m_data.size(); ++i) {
1369 for (
int i = 0; i < array.
m_data.size(); ++i) {
1390 for (
int i = 0; i < array.
m_data.size(); ++i) {
1412 for (
int i = 0; i < array.
m_data.size(); ++i) {
Exception handler interface definition.
GNdarray cosh(const GNdarray &array)
Computes cosh of array elements.
double max(const GNdarray &array)
Computes maximum array element.
GNdarray asin(const GNdarray &array)
Computes arcsin of array elements.
GNdarray tanh(const GNdarray &array)
Computes tanh of array elements.
GNdarray sqrt(const GNdarray &array)
Computes square root of array elements.
GNdarray atan(const GNdarray &array)
Computes arctan of array elements.
GNdarray asinh(const GNdarray &array)
Computes asinh of array elements.
GNdarray sinh(const GNdarray &array)
Computes sinh of array elements.
GNdarray acosh(const GNdarray &array)
Computes acosh of array elements.
GNdarray atanh(const GNdarray &array)
Computes atanh of array elements.
double min(const GNdarray &array)
Computes minimum array element.
GNdarray pow(const GNdarray &array, const double &power)
Computes tanh of array elements.
double sum(const GNdarray &array)
Computes array sum.
GNdarray acos(const GNdarray &array)
Computes arccos of array elements.
GNdarray log10(const GNdarray &array)
Computes base10 logarithm of array elements.
GNdarray log(const GNdarray &array)
Computes natural logarithm of array elements.
GNdarray sin(const GNdarray &array)
Computes sine of array elements.
GNdarray abs(const GNdarray &array)
Computes absolute of array elements.
GNdarray tan(const GNdarray &array)
Computes tangens of array elements.
GNdarray cos(const GNdarray &array)
Computes cosine of array elements.
GNdarray sign(const GNdarray &array)
Computes sign of array elements.
GNdarray exp(const GNdarray &array)
Computes exponential of array elements.
N-dimensional array class interface definition.
N-dimensional array class.
GNdarray & operator*=(const GNdarray &array)
Unary multiplication operator.
void copy_members(const GNdarray &array)
Copy class members.
GNdarray operator-(void) const
Unary minus operator.
void require_same_shape(const std::string &method, const GNdarray &array) const
Throw exception if array shapes differ.
int size(void) const
Return number of elements in array.
bool operator!=(const GNdarray &array) const
Non-equality operator.
std::vector< int > m_shape
Array dimensions.
bool operator==(const GNdarray &array) const
Equality operator.
void clear(void)
Clear array.
std::string print(const GChatter &chatter=NORMAL) const
Print array information.
GNdarray & operator/=(const GNdarray &array)
Unary division operator.
GNdarray & operator-=(const GNdarray &array)
Unary subtraction operator.
void init_members(void)
Initialise class members.
void free_members(void)
Delete class members.
virtual ~GNdarray(void)
Destructor.
GNdarray(void)
Void constructor.
GNdarray & operator+=(const GNdarray &array)
Unary addition operator.
std::vector< int > m_strides
Steps in each dimension when traversing array.
GNdarray & operator=(const GNdarray &array)
Assignment operator.
const std::vector< int > & shape(void) const
Return shape of array.
int index(const std::vector< int > &i) const
Compute array element index.
bool has_same_shape(const GNdarray &array) const
Check if array has the same shape.
double & at(const int &ix)
1-dimensional array element access with range checking
std::vector< double > m_data
Array data.
GNdarray * clone(void) const
Clone array.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.