OSHUN  beta
Arbitrary Order Spherical-Harmonic 1D-3P Vlasov-Fokker-Planck-Maxwell code
CGSlice_iter< T > Class Template Reference

#include <lib-array.h>

Inheritance diagram for CGSlice_iter< T >:
Collaboration diagram for CGSlice_iter< T >:

Public Member Functions

 CGSlice_iter (valarray< T > *vv, gslice gss)
 
CGSlice_iter end () const
 
CGSlice_iteroperator++ ()
 
CGSlice_iter operator++ (int)
 
const T & operator[] (size_t i) const
 
const T & operator() (size_t i) const
 
const T & operator* () const
 

Private Member Functions

const T & ref (size_t i) const
 

Private Attributes

valarray< T > * v
 
gslice gs
 
size_t curr
 
valarray< size_t > gsizes
 

Friends

bool operator== (const CGSlice_iter &p, const CGSlice_iter &q)
 
bool operator!= (const CGSlice_iter &p, const CGSlice_iter &q)
 
bool operator< (const CGSlice_iter &p, const CGSlice_iter &q)
 

Detailed Description

template<class T>
class CGSlice_iter< T >

Definition at line 167 of file lib-array.h.

Constructor & Destructor Documentation

◆ CGSlice_iter()

template<class T >
CGSlice_iter< T >::CGSlice_iter ( valarray< T > *  vv,
gslice  gss 
)

Definition at line 227 of file lib-array.h.

References CGSlice_iter< T >::gsizes.

227  :
228  v(vv), gs(gss), curr(0), gsizes(gs.size()){
229  for (int ic=1; ic < gsizes.size(); ++ic) {
230  gsizes[gss.size().size()-ic-1] *= gsizes[gss.size().size()-ic];
231  }
232 }
size_t curr
Definition: lib-array.h:182
valarray< size_t > gsizes
Definition: lib-array.h:183
valarray< T > * v
Definition: lib-array.h:180
gslice gs
Definition: lib-array.h:181

Member Function Documentation

◆ end()

template<class T>
CGSlice_iter CGSlice_iter< T >::end ( ) const
inline

Definition at line 191 of file lib-array.h.

References CGSlice_iter< T >::curr.

191  {
192  CGSlice_iter t = *this;
193  t.curr = gsizes[0];
194  return t;
195  }
size_t curr
Definition: lib-array.h:182
valarray< size_t > gsizes
Definition: lib-array.h:183

◆ operator()()

template<class T>
const T& CGSlice_iter< T >::operator() ( size_t  i) const
inline

Definition at line 201 of file lib-array.h.

References GSlice_iter< T >::ref().

Referenced by Array2D< complex< double > >::array().

201 {return ref(i);} // Fortran style subscript
const T & ref(size_t i) const
Definition: lib-array.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator*()

template<class T>
const T& CGSlice_iter< T >::operator* ( ) const
inline

Definition at line 202 of file lib-array.h.

References GSlice_iter< T >::ref().

202 {return ref(curr);} // Current element
size_t curr
Definition: lib-array.h:182
const T & ref(size_t i) const
Definition: lib-array.h:213
Here is the call graph for this function:

◆ operator++() [1/2]

template<class T>
CGSlice_iter& CGSlice_iter< T >::operator++ ( )
inline

Definition at line 197 of file lib-array.h.

References GSlice_iter< T >::curr.

197 {++curr; return *this;} //prefix
size_t curr
Definition: lib-array.h:182

◆ operator++() [2/2]

template<class T>
CGSlice_iter CGSlice_iter< T >::operator++ ( int  )
inline

Definition at line 198 of file lib-array.h.

References GSlice_iter< T >::curr.

198 {CGSlice_iter t = *this; ++curr; return t;} //postfix
size_t curr
Definition: lib-array.h:182

◆ operator[]()

template<class T>
const T& CGSlice_iter< T >::operator[] ( size_t  i) const
inline

Definition at line 200 of file lib-array.h.

References GSlice_iter< T >::ref().

200 {return ref(i);} // C style subscript
const T & ref(size_t i) const
Definition: lib-array.h:213
Here is the call graph for this function:

◆ ref()

template<class T >
const T & CGSlice_iter< T >::ref ( size_t  i) const
private

Definition at line 213 of file lib-array.h.

References GSlice_iter< T >::gs, GSlice_iter< T >::gsizes, and GSlice_iter< T >::v.

213  {
214  size_t loc(0);
215  for (size_t ic = 0; ic < gsizes.size()-1; ++ic){
216  loc += (i/gsizes[ic+1]) * gs.stride()[ic];
217  i %= gsizes[ic+1];
218  }
219  loc += i * gs.stride()[gsizes.size()-1];
220  return (*v)[gs.start()+loc];
221 }
valarray< size_t > gsizes
Definition: lib-array.h:183
valarray< T > * v
Definition: lib-array.h:180
gslice gs
Definition: lib-array.h:181

Friends And Related Function Documentation

◆ operator!=

template<class T>
bool operator!= ( const CGSlice_iter< T > &  p,
const CGSlice_iter< T > &  q 
)
friend

Definition at line 248 of file lib-array.h.

248  {
249  return !(p==q);
250 }

◆ operator<

template<class T>
bool operator< ( const CGSlice_iter< T > &  p,
const CGSlice_iter< T > &  q 
)
friend

Definition at line 253 of file lib-array.h.

253  {
254  size_t count(0);
255  if (p.curr<q.curr && p.gs.start() == q.gs.start())
256  while ( (p.gs.stride()[count] == p.gs.stride()[count])
257  && (p.gs.size()[count] == p.gs.size()[count] ))
258  if (count++ == q.gs.size().size()-1) return true;
259  return false;
260 }
size_t curr
Definition: lib-array.h:182
gslice gs
Definition: lib-array.h:181

◆ operator==

template<class T>
bool operator== ( const CGSlice_iter< T > &  p,
const CGSlice_iter< T > &  q 
)
friend

Definition at line 238 of file lib-array.h.

238  {
239  size_t count(0);
240  if (p.curr==q.curr && p.gs.start() == q.gs.start())
241  while ( (p.gs.stride()[count] == p.gs.stride()[count])
242  && (p.gs.size()[count] == p.gs.size()[count] ))
243  if (count++ == q.gs.size().size()-1) return true;
244  return false;
245 }
size_t curr
Definition: lib-array.h:182
gslice gs
Definition: lib-array.h:181

Field Documentation

◆ curr

template<class T>
size_t CGSlice_iter< T >::curr
private

Definition at line 182 of file lib-array.h.

Referenced by CGSlice_iter< T >::end(), and operator==().

◆ gs

template<class T>
gslice CGSlice_iter< T >::gs
private

Definition at line 181 of file lib-array.h.

Referenced by operator==().

◆ gsizes

template<class T>
valarray<size_t> CGSlice_iter< T >::gsizes
private

Definition at line 183 of file lib-array.h.

Referenced by CGSlice_iter< T >::CGSlice_iter().

◆ v

template<class T>
valarray<T>* CGSlice_iter< T >::v
private

Definition at line 180 of file lib-array.h.

Referenced by Array2D< complex< double > >::array().


The documentation for this class was generated from the following file: