summaryrefslogtreecommitdiff
path: root/numpy/doc/swig/test/Array2.h
blob: a6e5bfc308de31c49e703dc60c29d64191706e54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef ARRAY2_H
#define ARRAY2_H

#include "Array1.h"
#include <stdexcept>
#include <string>

class Array2
{
public:

  // Default constructor
  Array2();

  // Size/array constructor
  Array2(int nrows, int ncols, long* data=0);

  // Copy constructor
  Array2(const Array2 & source);

  // Destructor
  ~Array2();

  // Assignment operator
  Array2 & operator=(const Array2 & source);

  // Equals operator
  bool operator==(const Array2 & other) const;

  // Length accessors
  int nrows() const;
  int ncols() const;

  // Resize array
  void resize(int ncols, int nrows, long* data=0);

  // Set item accessor
  Array1 & operator[](int i);

  // Get item accessor
  const Array1 & operator[](int i) const;

  // String output
  std::string asString() const;

  // Get view
  void view(int* nrows, int* ncols, long** data) const;

private:
  // Members
  bool _ownData;
  int _nrows;
  int _ncols;
  long * _buffer;
  Array1 * _rows;

  // Methods
  void allocateMemory();
  void allocateRows();
  void deallocateMemory();
};

#endif