~ubuntu-branches/ubuntu/wily/dolfin/wily

« back to all changes in this revision

Viewing changes to dolfin/swig/la/Indices.i

  • Committer: Package Import Robot
  • Author(s): Johannes Ring
  • Date: 2014-09-22 14:35:34 UTC
  • mfrom: (1.1.17) (19.1.23 sid)
  • Revision ID: package-import@ubuntu.com-20140922143534-0yi89jyuqbgdxwm9
Tags: 1.4.0+dfsg-4
* debian/control: Disable libcgal-dev on i386, mipsel and sparc.
* debian/rules: Remove bad directives in pkg-config file dolfin.pc
  (closes: #760658).
* Remove debian/libdolfin-dev.lintian-overrides.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
  { clear(); }
35
35
 
36
36
  // Clear any created array
37
 
  void clear(){
 
37
  void clear()
 
38
  {
38
39
    if (_indices)
39
40
      delete[] _indices;
40
41
    if (_range)
56
57
 
57
58
  dolfin::la_index* range()
58
59
  {
59
 
    // Construct the array if not excisting
 
60
    // Construct the array if not existing
60
61
    if (!_range)
61
62
    {
62
63
      _range = new dolfin::la_index[size()];
77
78
  static std::size_t check_index(int index, unsigned int vector_size)
78
79
  {
79
80
    // Check bounds
80
 
    if (index >= static_cast<int>(vector_size) ||
81
 
         index < -static_cast<int>(vector_size) )
 
81
    if (index >= static_cast<int>(vector_size)
 
82
        || index < -static_cast<int>(vector_size))
82
83
      throw std::runtime_error("index out of range");
83
84
 
84
85
    // If a negative index is provided swap it
109
110
      throw std::runtime_error("expected slice");
110
111
    Py_ssize_t stop, start, step, index_size;
111
112
 
112
 
    if ( PySlice_GetIndicesEx((PySliceObject*)op, vector_size, &start, &stop, &step, &index_size) < 0 )
 
113
    if (PySlice_GetIndicesEx((PySliceObject*)op, vector_size, &start, &stop, &step, &index_size) < 0)
113
114
      throw std::runtime_error("invalid slice");
114
115
    _step  = step;
115
116
    _start = start;
206
207
  {
207
208
    if ( op == Py_None || !PyArray_Check(op))
208
209
      throw std::runtime_error("expected numpy array of integers");
209
 
    
 
210
 
210
211
    PyArrayObject* array_op = reinterpret_cast<PyArrayObject*>(op);
211
212
    if (!PyTypeNum_ISINTEGER(PyArray_TYPE(array_op)))
212
213
      throw std::runtime_error("expected numpy array of integers");
273
274
 
274
275
    if (!PyArray_ISBOOL(npy_op))
275
276
      throw std::runtime_error("expected numpy array of boolean");
276
 
      
 
277
 
277
278
    // An initial check of the length of the array
278
279
    if (PyArray_NDIM(npy_op)!=1)
279
280
      throw std::runtime_error("provide an 1D array");