ESyS-Particle  2.3.4
dslice.h
Go to the documentation of this file.
1 // //
3 // Copyright (c) 2003-2017 by The University of Queensland //
4 // Centre for Geoscience Computing //
5 // http://earth.uq.edu.au/centre-geoscience-computing //
6 // //
7 // Primary Business: Brisbane, Queensland, Australia //
8 // Licensed under the Open Software License version 3.0 //
9 // http://www.apache.org/licenses/LICENSE-2.0 //
10 // //
12 
13 #ifndef __DSLICE_H
14 #define __DSLICE_H
15 
16 //--- IO includes ---
17 #include <iostream>
18 using std::ostream;
19 using std::endl;
20 
21 class DSlice
22 {
23  private:
24  int m_start;
27 
28  public:
29  DSlice(int st,int l1,int s1,int l2,int s2):
30  m_start(st),m_length1(l1),m_length2(l2),m_stride1(s1),m_stride2(s2)
31  {}
32 
33  inline unsigned int size() const {return m_length1*m_length2;}
34  inline int operator[](int idx) const
35  {return m_start+(idx%m_length1)*m_stride1+(idx/m_length1)*m_stride2;}
36 
37  friend bool operator==(const DSlice&,const DSlice&);
38  friend bool operator!=(const DSlice&,const DSlice&);
39 
40  friend ostream& operator<< (ostream&,const DSlice&);
41 };
42 
43 #endif //__DSLICE_H
DSlice::operator!=
friend bool operator!=(const DSlice &, const DSlice &)
Definition: dslice.cpp:24
DSlice::operator<<
friend ostream & operator<<(ostream &, const DSlice &)
Definition: dslice.cpp:33
DSlice::m_length1
int m_length1
Definition: dslice.h:25
DSlice::m_length2
int m_length2
Definition: dslice.h:25
DSlice::m_stride2
int m_stride2
Definition: dslice.h:26
DSlice::m_start
int m_start
Definition: dslice.h:24
dslice.h
DSlice::m_stride1
int m_stride1
Definition: dslice.h:26
operator<<
ostream & operator<<(ostream &ost, const DSlice &s)
Definition: dslice.cpp:33
operator!=
bool operator!=(const DSlice &s1, const DSlice &s2)
Definition: dslice.cpp:24
DSlice::DSlice
DSlice(int st, int l1, int s1, int l2, int s2)
Definition: dslice.h:29
DSlice
Definition: dslice.h:22
DSlice::operator[]
int operator[](int idx) const
Definition: dslice.h:34
DSlice::size
unsigned int size() const
Definition: dslice.h:33
operator==
bool operator==(const DSlice &s1, const DSlice &s2)
Definition: dslice.cpp:15
DSlice::operator==
friend bool operator==(const DSlice &, const DSlice &)
Definition: dslice.cpp:15