AFF --- A container for numbers (array) by Friederich and Forbriger.
fortranshape.h
Go to the documentation of this file.
1 
43 // include guard
44 #ifndef AFF_FORTRANSHAPE_H_VERSION
45 
46 #define AFF_FORTRANSHAPE_H_VERSION \
47  "AFF_FORTRANSHAPE_H V1.2"
48 
49 #include<aff/array.h>
50 #include<aff/lib/checkedcast.h>
51 
52 namespace aff {
53 
54 namespace util {
55 
64  class FortranShape {
65  public:
73  explicit FortranShape(const Tshape& shape, const bool& BaseOne=true);
75  const Tsubscript& first(const Tdim& i) const { return(Mfirst[i]); }
77  const Tsubscript& last(const Tdim& i) const { return(Mlast[i]); }
79  const Tsubscript& dimlast(const Tdim& i) const { return(Mdimlast[i]); }
81  const Tsubscript& offset() const { return(Moffset); }
83  const TIndexVec& first() const { return(Mfirst); }
85  const TIndexVec& last() const { return(Mlast); }
87  const TIndexVec& dimlast() const { return(Mdimlast); }
88  private:
97  }; // class FortranShape
98 } // namespace util
99 
100 /*----------------------------------------------------------------------*/
101 
106 template<class C>
108  public:
110  typedef C Tarray;
112  typedef typename Tarray::Tshape Tshape;
114  typedef typename Tarray::Trepresentation Trepresentation;
116  typedef typename Trepresentation::Tpointer Treppointer;
120  typedef typename Tarray::Tpointer Tpointer;
122  typedef typename Tarray::Tvalue Tvalue;
124  typedef typename Trepresentation::Tvalue Trepvalue;
126  FortranArray(Tarray array, const bool& BaseOne=true):
127  Tbase(array.shape(), BaseOne)
128  {
129  Trepresentation repr=array.representation();
130  Mpointer=&repr[this->Tbase::offset()];
131  }
133 
134  Tbase::first;
135  Tbase::last;
138  Treppointer pointer() const { return(Mpointer); }
147  template<class TT>
148  TT* castedpointer() const
150  private:
153 }; // class FortranArray
154 
155 } // namespace aff
156 
157 #endif // AFF_FORTRANSHAPE_H_VERSION (includeguard)
158 
159 /* ----- END OF fortranshape.h ----- */
Tsubscript Moffset
offset of first element in representation
Definition: fortranshape.h:96
Treppointer Mpointer
pointer to memory
Definition: fortranshape.h:152
Root namespace of library.
Definition: array.h:148
utility for compile-time checked cast
Definition: checkedcast.h:84
Shape for a rectangular array layout.
Definition: strided.h:117
Tshape::TSizeVec TSizeVec
Vector of size values.
Definition: fortranshape.h:71
aff::util::FortranShape Tbase
base class
Definition: fortranshape.h:118
Tarray::Tpointer Tpointer
pointer to array base in memory
Definition: fortranshape.h:120
TIndexVec Mfirst
first index
Definition: fortranshape.h:90
TIndexVec Mdimlast
last index as dimensioned in memory
Definition: fortranshape.h:94
C Tarray
type of corresponding array
Definition: fortranshape.h:110
const Tsubscript & dimlast(const Tdim &i) const
last index as dimensioned in dimension i
Definition: fortranshape.h:79
size checked pointer cast (prototypes)
const TIndexVec & dimlast() const
full dimlast vector
Definition: fortranshape.h:87
Tarray::Trepresentation Trepresentation
representation class
Definition: fortranshape.h:114
Tshape::TIndexVec TIndexVec
Vector of index values.
Definition: fortranshape.h:69
full template array class headers (prototypes)
Treppointer pointer() const
return pointer to first element in Fortran layout
Definition: fortranshape.h:139
Tarray::Tvalue Tvalue
value type in array class
Definition: fortranshape.h:122
const TIndexVec & first() const
full first vector
Definition: fortranshape.h:83
TIndexVec Mlast
last index
Definition: fortranshape.h:92
const Tsubscript & first(const Tdim &i) const
first index in dimension i
Definition: fortranshape.h:75
const Tsubscript & last(const Tdim &i) const
last index in dimension i
Definition: fortranshape.h:77
Class to provide Fortran interface values.
Definition: fortranshape.h:107
find appropriate leading dimensions
Definition: fortranshape.h:64
unsigned short int Tdim
Type to hold an array dimensionality.
Definition: types.h:49
const TIndexVec & last() const
full last vector
Definition: fortranshape.h:85
FortranShape(const Tshape &shape, const bool &BaseOne=true)
construct from shape
Definition: fortranshape.cc:44
ptrdiff_t Tsubscript
Type to hold an array&#39;s subscript value.
Definition: types.h:53
Tarray::Tshape Tshape
shape class
Definition: fortranshape.h:112
aff::Strided Tshape
This is coded for Strided shapes.
Definition: fortranshape.h:67
Trepresentation::Tvalue Trepvalue
value type in representation class
Definition: fortranshape.h:124
FortranArray(Tarray array, const bool &BaseOne=true)
create
Definition: fortranshape.h:126
TT * castedpointer() const
return type-casted pointer to first element in Fortran layout
Definition: fortranshape.h:148
const Tsubscript & offset() const
offset to access representation
Definition: fortranshape.h:81
Trepresentation::Tpointer Treppointer
pointer to value used in representation class
Definition: fortranshape.h:116