phdMesh  Version of the Day
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups
Array.hpp
1 /*------------------------------------------------------------------------*/
2 /* phdMesh : Parallel Heterogneous Dynamic unstructured Mesh */
3 /* Copyright (2008) Sandia Corporation */
4 /* */
5 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */
6 /* license for use of this work by or on behalf of the U.S. Government. */
7 /* */
8 /* This library is free software; you can redistribute it and/or modify */
9 /* it under the terms of the GNU Lesser General Public License as */
10 /* published by the Free Software Foundation; either version 2.1 of the */
11 /* License, or (at your option) any later version. */
12 /* */
13 /* This library is distributed in the hope that it will be useful, */
14 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
15 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
16 /* Lesser General Public License for more details. */
17 /* */
18 /* You should have received a copy of the GNU Lesser General Public */
19 /* License along with this library; if not, write to the Free Software */
20 /* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 */
21 /* USA */
22 /*------------------------------------------------------------------------*/
23 
24 #ifndef util_Array_hpp
25 #define util_Array_hpp
26 
27 #ifdef ARRAY_BOUNDS_CHECKING
28 #define ARRAY_CHECK( X ) X
29 #else
30 #define ARRAY_CHECK( X )
31 #endif
32 
33 #include <vector>
34 #include <string>
35 #include <util/SimpleArrayOps.hpp>
36 
37 namespace phdmesh {
38 
101 //----------------------------------------------------------------------
112 
117 
122 };
123 
124 template< typename Scalar , ArrayOrder Order ,
125  class Tag1 = void , class Tag2 = void ,
126  class Tag3 = void , class Tag4 = void ,
127  class Tag5 = void , class Tag6 = void ,
128  class Tag7 = void , class Tag8 = void >
129 class Array ;
130 
131 //----------------------------------------------------------------------
132 
133 template< class ArrayType , class Tag > struct ArrayAppend ;
134 
135 //----------------------------------------------------------------------
160 struct ArrayDimTag {
161 
163  virtual const char * name() const = 0 ;
164 
168  virtual std::string to_string( unsigned dimension ,
169  unsigned index ) const ;
170 
174  virtual unsigned to_index( unsigned dimension ,
175  const std::string & label ) const ;
176 
177 protected:
178  virtual ~ArrayDimTag();
179  ArrayDimTag() {}
180 private:
181  ArrayDimTag( const ArrayDimTag & );
182  ArrayDimTag & operator = ( const ArrayDimTag & );
183 };
184 
190 struct ArrayDimension : public ArrayDimTag {
191 
192  const char * name() const ;
193 
194  static const ArrayDimension & tag();
195 
196 private:
197  ~ArrayDimension();
198  ArrayDimension() {}
199  ArrayDimension( const ArrayDimension & );
200  ArrayDimension & operator = ( const ArrayDimension & );
201 };
202 
203 } // namespace phdmesh
204 
205 //----------------------------------------------------------------------
206 //----------------------------------------------------------------------
207 
208 #include <util/ArrayPrivate.hpp>
209 
210 namespace phdmesh {
211 
212 //----------------------------------------------------------------------
232 template< typename Scalar , ArrayOrder array_order ,
233  class Tag1 , class Tag2 , class Tag3 , class Tag4 ,
234  class Tag5 , class Tag6 , class Tag7 , class Tag8 >
235 class Array
236 {
237 private:
238  typedef
239  Array<void,array_order,Tag1,Tag2,Tag3,Tag4,Tag5,Tag6,Tag7,Tag8>
240  md_type ;
241 public:
247  typedef Scalar value_type ;
248 
250  typedef unsigned size_type ;
251 
253  typedef const ArrayDimTag * tag_type ;
254 
255  //----------------------------------
256 
258  enum { Rank = md_type::Rank };
259 
261  enum { Natural = NaturalOrder == array_order };
262 
264  enum { Reverse = FortranOrder == array_order };
265 
267  enum { Contiguous = true };
268 
270  unsigned rank() const { return Rank ; }
271 
273  bool natural() const { return Natural ; }
274 
276  bool reverse() const { return Reverse ; }
277 
279  bool contiguous() const { return Contiguous ; }
280 
281  //----------------------------------
282 
283 #ifndef DOXYGEN_COMPILE
284 
285  template < unsigned ordinate >
286  struct Tag { typedef typename ArrayTagAt<Array,ordinate>::type type ; };
287 #endif
288 
290  tag_type tag( const unsigned ordinate ) const
291  {
292  array_check_ordinal( Rank , ordinate );
293  return
294  array_dim_tags<Tag1,Tag2,Tag3,Tag4,Tag5,Tag6,Tag7,Tag8>()[ordinate];
295  }
296 
297  //----------------------------------
299  template < unsigned ordinate > unsigned dimension() const
300  {
301  array_check_ordinal_is_less<ordinate,Rank>();
302  return ArrayStrideDim<array_order,Rank,ordinate>::dimension(m_stride);
303  }
304 
306  unsigned dimension( const unsigned ordinate ) const
307  {
308  array_check_ordinal( Rank , ordinate );
309  return ArrayStrideDim<array_order,Rank>::dimension(m_stride,ordinate);
310  }
311 
313  void dimensions( std::vector<unsigned> & n )
314  {
315  n.resize( Rank );
316  for ( unsigned i = 0 ; i < Rank ; ++i ) { n[i] = dimension(i); }
317  }
318 
320  size_type size() const { return m_stride[ Rank - 1 ]; }
321 
323  //----------------------------------
331  typedef typename ArrayTruncate<Array>::type TruncateType ;
332 
337  TruncateType truncate( const unsigned i ) const
338  {
339  TruncateType tmp ;
340  tmp.m_ptr = m_ptr + i * ( 1 < Rank ? m_stride[ Rank - 2 ] : 1 );
341  Copy<Rank-1>( tmp.m_stride , m_stride );
342  return tmp ;
343  }
344 
345  //----------------------------------
347  value_type * contiguous_data() const { return m_ptr ; }
348 
351  {
352  ARRAY_CHECK( array_check_offset(size(),i) );
353  return m_ptr[ i ];
354  }
355 
357  value_type & operator()( const unsigned i1 , const unsigned i2 ,
358  const unsigned i3 , const unsigned i4 ,
359  const unsigned i5 , const unsigned i6 ,
360  const unsigned i7 , const unsigned i8 ) const
361  { return m_ptr[
362  array_offset<array_order,Rank>(m_stride,i1,i2,i3,i4,i5,i6,i7,i8) ];
363  }
364 
366  value_type & operator()( const unsigned i1 , const unsigned i2 ,
367  const unsigned i3 , const unsigned i4 ,
368  const unsigned i5 , const unsigned i6 ,
369  const unsigned i7 ) const
370  { return m_ptr[
371  array_offset<array_order,Rank>(m_stride,i1,i2,i3,i4,i5,i6,i7) ];
372  }
373 
375  value_type & operator()( const unsigned i1 , const unsigned i2 ,
376  const unsigned i3 , const unsigned i4 ,
377  const unsigned i5 , const unsigned i6 ) const
378  { return m_ptr[
379  array_offset<array_order,Rank>(m_stride,i1,i2,i3,i4,i5,i6) ];
380  }
381 
383  value_type & operator()( const unsigned i1 , const unsigned i2 ,
384  const unsigned i3 , const unsigned i4 ,
385  const unsigned i5 ) const
386  { return m_ptr[ array_offset<array_order,Rank>(m_stride,i1,i2,i3,i4,i5) ]; }
387 
389  value_type & operator()( const unsigned i1 , const unsigned i2 ,
390  const unsigned i3 , const unsigned i4 ) const
391  { return m_ptr[ array_offset<array_order,Rank>(m_stride,i1,i2,i3,i4) ]; }
392 
394  value_type & operator()( const unsigned i1 , const unsigned i2 ,
395  const unsigned i3 ) const
396  { return m_ptr[ array_offset<array_order,Rank>(m_stride,i1,i2,i3) ]; }
397 
399  value_type & operator()( const unsigned i1 , const unsigned i2 ) const
400  { return m_ptr[ array_offset<array_order,Rank>(m_stride,i1,i2) ]; }
401 
403  value_type & operator()( const unsigned i1 ) const
404  { return m_ptr[ array_offset<array_order,Rank>(m_stride,i1) ]; }
405 
407  //----------------------------------
415  typedef typename ArrayReverse< Array >::type ReverseType ;
416 
418  Array() : m_ptr(NULL) { Copy<Rank>( m_stride , (size_type) 0 ); }
419 
421  Array( const Array & rhs )
422  : m_ptr( rhs.m_ptr ) { Copy<Rank>( m_stride , rhs.m_stride ); }
423 
425  Array & operator = ( const Array & rhs )
426  {
427  m_ptr = rhs.m_ptr ;
428  Copy<Rank>( m_stride , rhs.m_stride );
429  return *this ;
430  }
431 
433  Array( const ReverseType & rhs )
434  : m_ptr( rhs.m_ptr ) { Copy<Rank>( m_stride , rhs.m_stride ); }
435 
437  Array & operator = ( const ReverseType & rhs )
438  {
439  m_ptr = rhs.m_ptr ;
440  Copy<Rank>( m_stride , rhs.m_stride );
441  return *this ;
442  }
443 
445  Array( value_type * arg_ptr , const unsigned * const dims )
446  : m_ptr( arg_ptr ) { md_type::assign( m_stride , dims ); }
447 
449  Array( value_type * arg_ptr ,
450  const unsigned n1 , const unsigned n2 ,
451  const unsigned n3 , const unsigned n4 ,
452  const unsigned n5 , const unsigned n6 ,
453  const unsigned n7 , const unsigned n8 )
454  : m_ptr( arg_ptr )
455  { md_type::assign( m_stride , n1 , n2 , n3 , n4 , n5 , n6 , n7 , n8 ); }
456 
460  Array( value_type * arg_ptr ,
461  const unsigned n1 , const unsigned n2 ,
462  const unsigned n3 , const unsigned n4 ,
463  const unsigned n5 , const unsigned n6 ,
464  const unsigned n7 )
465  : m_ptr( arg_ptr )
466  { md_type::assign( m_stride , n1 , n2 , n3 , n4 , n5 , n6 , n7 ); }
467 
471  Array( value_type * arg_ptr ,
472  const unsigned n1 , const unsigned n2 ,
473  const unsigned n3 , const unsigned n4 ,
474  const unsigned n5 , const unsigned n6 )
475  : m_ptr( arg_ptr )
476  { md_type::assign( m_stride , n1 , n2 , n3 , n4 , n5 , n6 ); }
477 
481  Array( value_type * arg_ptr ,
482  const unsigned n1 , const unsigned n2 ,
483  const unsigned n3 , const unsigned n4 ,
484  const unsigned n5 )
485  : m_ptr( arg_ptr )
486  { md_type::assign( m_stride , n1 , n2 , n3 , n4 , n5 ); }
487 
491  Array( value_type * arg_ptr ,
492  const unsigned n1 , const unsigned n2 ,
493  const unsigned n3 , const unsigned n4 )
494  : m_ptr( arg_ptr )
495  { md_type::assign( m_stride , n1 , n2 , n3 , n4 ); }
496 
500  Array( value_type * arg_ptr ,
501  const unsigned n1 , const unsigned n2 ,
502  const unsigned n3 )
503  : m_ptr( arg_ptr )
504  { md_type::assign( m_stride , n1 , n2 , n3 ); }
505 
509  Array( value_type * arg_ptr , const unsigned n1 , const unsigned n2 )
510  : m_ptr( arg_ptr ) { md_type::assign( m_stride , n1 , n2 ); }
511 
515  Array( value_type * arg_ptr , const unsigned n1 )
516  : m_ptr( arg_ptr ) { md_type::assign( m_stride , n1 ); }
517 
519  Array( value_type * arg_ptr )
520  : m_ptr( arg_ptr ) { md_type::assign( m_stride ); }
521 
523 protected:
524 
527 
530 
531  template< typename , ArrayOrder ,
532  class , class , class , class ,
533  class , class , class , class >
534  friend class phdmesh::Array ;
535 };
536 
537 //----------------------------------------------------------------------
538 
539 #ifndef DOXYGEN_COMPILE
540 
544 template< typename Scalar >
545 class Array<Scalar,RankZero,void,void,void,void,void,void,void,void>
546 {
547 public:
548 
549  typedef Scalar value_type ;
550  typedef unsigned size_type ;
551  typedef const ArrayDimTag * tag_type ;
552 
553  //----------------------------------
554 
555  enum { Rank = 0 };
556  enum { Natural = false };
557  enum { Reverse = false };
558  enum { Contiguous = true };
559 
560  unsigned rank() const { return Rank ; }
561  bool natural() const { return Natural ; }
562  bool reverse() const { return Reverse ; }
563  bool contiguous() const { return Contiguous ; }
564 
565  //----------------------------------
566 
568  size_type size() const { return m_ptr ? 1 : 0 ; }
569 
570  //----------------------------------
572  value_type * contiguous_data() const { return m_ptr ; }
573 
575  value_type & operator()() const { return *m_ptr ; }
576 
577  //----------------------------------
578  // Required constructors and assignment operators:
579 
580  Array() : m_ptr(NULL) {}
581 
582  Array( const Array & rhs ) : m_ptr( rhs.m_ptr ) {}
583 
584  Array & operator = ( const Array & rhs )
585  { m_ptr = rhs.m_ptr ; return *this ; }
586 
587  //----------------------------------
588  // Class specific constructors:
589 
590  Array( value_type * arg_ptr ) : m_ptr( arg_ptr ) {}
591 
592 protected:
593 
594  value_type * m_ptr ;
595 
596  template< typename , ArrayOrder ,
597  class , class , class , class ,
598  class , class , class , class >
599  friend class phdmesh::Array ;
600 };
601 
602 #endif /* DOXYGEN_COMPILE */
603 //----------------------------------------------------------------------
604 //----------------------------------------------------------------------
618 template< typename Scalar , ArrayOrder array_order >
619 class Array<Scalar,array_order,void,void,void,void,void,void,void,void>
620 {
621 public:
627  typedef Scalar value_type ;
628 
630  typedef unsigned size_type ;
631 
633  typedef const ArrayDimTag * tag_type ;
634 
635  //----------------------------------
636 
638  enum { Natural = NaturalOrder == array_order };
639 
641  enum { Reverse = FortranOrder == array_order };
642 
644  enum { Contiguous = true };
645 
647  unsigned rank() const { return m_rank ; }
648 
650  bool natural() const { return Natural ; }
651 
653  bool reverse() const { return Reverse ; }
654 
656  bool contiguous() const { return Contiguous ; }
657 
658  //----------------------------------
659 
661  tag_type tag( const unsigned ordinal ) const
662  {
663  array_check_ordinal( m_rank , ordinal );
664  const int i = Natural ? ( m_rank - 1 ) - ordinal : ordinal ;
665  return m_tag[i];
666  }
667 
668  //----------------------------------
669 
671  unsigned dimension( const unsigned ordinal ) const
672  {
673  array_check_ordinal( m_rank , ordinal );
674  const int i = Natural ? ( m_rank - 1 ) - ordinal : ordinal ;
675  return i ? m_stride[i] / m_stride[i-1] : m_stride[i] ;
676  }
677 
679  void dimensions( std::vector<unsigned> & n )
680  {
681  n.resize( m_rank );
682  for ( unsigned i = 0 ; i < m_rank ; ++i ) { n[i] = dimension(i); }
683  }
684 
686  size_type size() const { return m_stride[ m_rank - 1 ]; }
687 
689  //----------------------------------
697  Array truncate( const unsigned i ) const
698  {
699  Array tmp ;
700  if ( 1 < m_rank ) {
701  tmp.m_ptr = m_ptr + m_stride[ m_rank - 2 ] * i ;
702  tmp.m_rank = m_rank - 1 ;
703  unsigned k ;
704  for ( k = 0 ; k < m_rank - 1 ; ++k ) { tmp.m_stride[i] = m_stride[i] ; }
705  for ( ; k < 8 ; ++k ) { tmp.m_stride[i] = 0 ; }
706  for ( k = 0 ; k < m_rank - 1 ; ++k ) { tmp.m_tag[i] = m_tag[i] ; }
707  for ( ; k < 8 ; ++k ) { tmp.m_tag[i] = NULL ; }
708  }
709  return tmp ;
710  }
711 
713  value_type * contiguous_data() const { return m_ptr ; }
714 
717  {
718  ARRAY_CHECK( array_check_offset(size(),i) );
719  return m_ptr[ i ];
720  }
721 
722  //----------------------------------
724  value_type & operator()( const unsigned i1 , const unsigned i2 ,
725  const unsigned i3 , const unsigned i4 ,
726  const unsigned i5 , const unsigned i6 ,
727  const unsigned i7 , const unsigned i8 ) const
728  {
729  ARRAY_CHECK( array_check_rank( m_rank , 8 ) );
730  return m_ptr[
731  array_offset<array_order,8>(m_stride,i1,i2,i3,i4,i5,i6,i7,i8) ];
732  }
733 
734  value_type & operator()( const unsigned i1 , const unsigned i2 ,
735  const unsigned i3 , const unsigned i4 ,
736  const unsigned i5 , const unsigned i6 ,
737  const unsigned i7 ) const
738  {
739  ARRAY_CHECK( array_check_rank( m_rank , 7 ) );
740  return m_ptr[
741  array_offset<array_order,7>(m_stride,i1,i2,i3,i4,i5,i6,i7) ];
742  }
743 
744  value_type & operator()( const unsigned i1 , const unsigned i2 ,
745  const unsigned i3 , const unsigned i4 ,
746  const unsigned i5 , const unsigned i6 ) const
747  {
748  ARRAY_CHECK( array_check_rank( m_rank , 6 ) );
749  return m_ptr[ array_offset<array_order,6>(m_stride,i1,i2,i3,i4,i5,i6) ];
750  }
751 
752  value_type & operator()( const unsigned i1 , const unsigned i2 ,
753  const unsigned i3 , const unsigned i4 ,
754  const unsigned i5 ) const
755  {
756  ARRAY_CHECK( array_check_rank( m_rank , 5 ) );
757  return m_ptr[ array_offset<array_order,5>(m_stride,i1,i2,i3,i4,i5) ];
758  }
759 
760  value_type & operator()( const unsigned i1 , const unsigned i2 ,
761  const unsigned i3 , const unsigned i4 ) const
762  {
763  ARRAY_CHECK( array_check_rank( m_rank , 4 ) );
764  return m_ptr[ array_offset<array_order,4>(m_stride,i1,i2,i3,i4) ];
765  }
766 
767  value_type & operator()( const unsigned i1 , const unsigned i2 ,
768  const unsigned i3 ) const
769  {
770  ARRAY_CHECK( array_check_rank( m_rank , 3 ) );
771  return m_ptr[ array_offset<array_order,3>(m_stride,i1,i2,i3) ];
772  }
773 
774  value_type & operator()( const unsigned i1 , const unsigned i2 ) const
775  {
776  ARRAY_CHECK( array_check_rank( m_rank , 2 ) );
777  return m_ptr[ array_offset<array_order,2>(m_stride,i1,i2) ];
778  }
779 
780  value_type & operator()( const unsigned i1 ) const
781  {
782  ARRAY_CHECK( array_check_rank( m_rank , 1 ) );
783  return m_ptr[ array_offset<array_order,1>(m_stride,i1) ];
784  }
785 
787  //----------------------------------
792  typedef typename ArrayReverse< Array >::type ReverseType ;
793 
794  //----------------------------------
795 
796  Array()
797  : m_ptr(NULL), m_rank(0)
798  {
799  Copy<8>( m_stride , (size_type) 0 );
800  Copy<8>( m_tag , (tag_type) NULL );
801  }
802 
803  Array( const Array & rhs )
804  : m_ptr( rhs.m_ptr ), m_rank( rhs.m_rank )
805  {
806  Copy<8>( m_stride , rhs.m_stride );
807  Copy<8>( m_tag , rhs.m_tag );
808  }
809 
810  Array & operator = ( const Array & rhs )
811  {
812  m_ptr = rhs.m_ptr ;
813  m_rank = rhs.m_rank ;
814  Copy<8>( m_stride , rhs.m_stride );
815  Copy<8>( m_tag , rhs.m_tag );
816  return *this ;
817  }
818 
820  Array( const ReverseType & rhs )
821  : m_ptr( rhs.m_ptr ), m_rank( rhs.m_rank )
822  {
823  Copy<8>( m_stride , rhs.m_stride );
824  Copy<8>( m_tag , rhs.m_tag );
825  }
826 
828  Array & operator = ( const ReverseType & rhs )
829  {
830  m_ptr = rhs.m_ptr ;
831  m_rank = rhs.m_rank ;
832  Copy<8>( m_stride , rhs.m_stride );
833  Copy<8>( m_tag , rhs.m_tag );
834  return *this ;
835  }
836 
837  //----------------------------------
838 
842  template< ArrayOrder order ,
843  class Tag1 , class Tag2 , class Tag3 , class Tag4 ,
844  class Tag5 , class Tag6 , class Tag7 , class Tag8 >
847  : m_ptr( rhs.m_ptr ), m_rank( 0 )
848  {
850  enum { inRank = a_t::Rank };
851  enum { inNatural = a_t::Natural };
852  m_rank = inRank ;
853  Copy< inRank >( m_stride , rhs.m_stride );
854  Copy< 8 - inRank >( m_stride + inRank , (size_type) 0 );
855  unsigned i = 0 ;
856  if ( inNatural ) {
857  for ( ; i < inRank ; ++i ) { m_tag[i] = rhs.tag((inRank-1)-i); }
858  }
859  else {
860  for ( ; i < inRank ; ++i ) { m_tag[i] = rhs.tag(i); }
861  }
862  for ( ; i < 8 ; ++i ) { m_tag[i] = NULL ; }
863  }
864 
865  //----------------------------------
866  // Class specific constructors:
867 
868  Array( value_type * ptr ,
869  const unsigned rank ,
870  const unsigned * const dims ,
871  const tag_type * const tags )
872  : m_ptr( ptr ), m_rank( rank )
873  {
874  if ( Natural ) {
875  size_type n = 1 ;
876  unsigned i ;
877  for ( i = 0 ; i < rank ; ++i ) { m_stride[i] = n *= dims[(rank-1)-i]; }
878  for ( ; i < 8 ; ++i ) { m_stride[i] = 0 ; }
879  for ( i = 0 ; i < rank ; ++i ) { m_tag[i] = tags[(rank-1)-i]; }
880  for ( ; i < 8 ; ++i ) { m_tag[i] = NULL ; }
881  }
882  else {
883  size_type n = 1 ;
884  unsigned i ;
885  for ( i = 0 ; i < rank ; ++i ) { m_stride[i] = n *= dims[i] ; }
886  for ( ; i < 8 ; ++i ) { m_stride[i] = 0 ; }
887  for ( i = 0 ; i < rank ; ++i ) { m_tag[i] = tags[i]; }
888  for ( ; i < 8 ; ++i ) { m_tag[i] = NULL ; }
889  }
890  }
891 
893 protected:
894 
897 
899  unsigned m_rank ;
900 
903 
905  tag_type m_tag[8] ;
906 
907  template< typename , ArrayOrder ,
908  class , class , class , class ,
909  class , class , class , class >
910  friend class phdmesh::Array ;
911 };
912 
913 //----------------------------------------------------------------------
914 //----------------------------------------------------------------------
915 
916 } // namespace phdmesh
917 
918 #undef ARRAY_CHECK
919 
920 #endif
921 
value_type * contiguous_data() const
Pointer to contiguous block of member data.
Definition: Array.hpp:347
Array(const ReverseType &rhs)
Copy constructor for reverse type.
Definition: Array.hpp:820
value_type & operator()(const unsigned i1, const unsigned i2, const unsigned i3, const unsigned i4, const unsigned i5) const
Access member of a Rank 5 array.
Definition: Array.hpp:383
value_type & operator()(const unsigned i1, const unsigned i2, const unsigned i3, const unsigned i4, const unsigned i5, const unsigned i6) const
Access member of a Rank 6 array.
Definition: Array.hpp:375
Array(value_type *arg_ptr, const unsigned n1, const unsigned n2)
Construct a Rank 2..8 array; use Tag#::Size for defaults. The input dimensions are the 2 slowest stri...
Definition: Array.hpp:509
void dimensions(std::vector< unsigned > &n)
Dimension of all ordinate.
Definition: Array.hpp:679
Array(value_type *arg_ptr, const unsigned n1, const unsigned n2, const unsigned n3)
Construct a Rank 3..8 array; use Tag#::Size for defaults. The input dimensions are the 3 slowest stri...
Definition: Array.hpp:500
void Copy(T *, const T &)
dst[k] = src , k = 0..N-1
Array(const Array< value_type, order, Tag1, Tag2, Tag3, Tag4, Tag5, Tag6, Tag7, Tag8 > &rhs)
Copy constructor from an Array with compile-time defined rank and dimension tags. ...
Definition: Array.hpp:845
bool contiguous() const
If the member data storage is contiguous.
Definition: Array.hpp:279
unsigned rank() const
Rank of the array is the number of non-void dimension tags.
Definition: Array.hpp:270
value_type & operator()(const unsigned i1, const unsigned i2, const unsigned i3, const unsigned i4) const
Access member of a Rank 4 array.
Definition: Array.hpp:389
unsigned size_type
Type for sizes.
Definition: Array.hpp:250
Use the Natural or C-language ordering for multi-dimensions where the right-most dimension is stride-...
Definition: Array.hpp:111
Array()
Default constructor.
Definition: Array.hpp:418
value_type * m_ptr
Pointer to contiguous block of members.
Definition: Array.hpp:526
Array(value_type *arg_ptr, const unsigned n1, const unsigned n2, const unsigned n3, const unsigned n4, const unsigned n5, const unsigned n6, const unsigned n7)
Construct a Rank 7..8 array; use Tag#::Size for defaults. The input dimensions are the 7 slowest stri...
Definition: Array.hpp:460
unsigned dimension(const unsigned ordinate) const
Dimension of the given ordinate.
Definition: Array.hpp:306
value_type & operator()(const unsigned i1, const unsigned i2, const unsigned i3, const unsigned i4, const unsigned i5, const unsigned i6, const unsigned i7, const unsigned i8) const
Access member via Rank 8 multi-index.
Definition: Array.hpp:724
unsigned rank() const
Rank of the array is the number of non-void dimension tags.
Definition: Array.hpp:647
Array(value_type *arg_ptr, const unsigned n1, const unsigned n2, const unsigned n3, const unsigned n4, const unsigned n5, const unsigned n6)
Construct a Rank 6..8 array; use Tag#::Size for defaults. The input dimensions are the 6 slowest stri...
Definition: Array.hpp:471
size_type size() const
Total number of member data items.
Definition: Array.hpp:320
virtual const char * name() const =0
Name of the tag, typically the name of the derived class.
Scalar value_type
Type of member data.
Definition: Array.hpp:247
value_type * contiguous_data() const
Pointer to contiguous block of member data.
Definition: Array.hpp:713
Array(value_type *arg_ptr, const unsigned *const dims)
Construct with array of dimensions.
Definition: Array.hpp:445
bool natural() const
If the multidimension follows the natural ordering.
Definition: Array.hpp:650
tag_type tag(const unsigned ordinate) const
Access the dimension tag-singleton for a given ordinate.
Definition: Array.hpp:290
Use the Reverse or Fortran-language ordering for multi-dimensions where the left-most dimension is st...
Definition: Array.hpp:116
Array(value_type *arg_ptr)
Construct a Rank 1..8 array; use Tag#::Size for defaults.
Definition: Array.hpp:519
Array truncate(const unsigned i) const
Generate a subarray view of the array with the slowest striding ordinate offset by i and removed...
Definition: Array.hpp:697
bool reverse() const
If the multidimension follows the reverse (Fortran) ordering.
Definition: Array.hpp:653
value_type & operator()(const unsigned i1) const
Access member of a Rank 1 array.
Definition: Array.hpp:403
value_type & operator()(const unsigned i1, const unsigned i2, const unsigned i3) const
Access member of a Rank 3 array.
Definition: Array.hpp:394
Abstract base class for array dimension tags supplied to the Array template class.
Definition: Array.hpp:160
ArrayTruncate< Array >::type TruncateType
Subarray type that removes the slowest striding dimension (first natural or last fortran ordinate)...
Definition: Array.hpp:331
Array & operator=(const Array &rhs)
Assignment operator.
Definition: Array.hpp:425
Array(const ReverseType &rhs)
Copy constructor for compatible reverse type.
Definition: Array.hpp:433
ArrayOrder
Define Natural (C-language) or Fortran ordering of array dimensions. A RankZero array does not ha...
Definition: Array.hpp:107
static const ArrayDimension & tag()
Singleton.
const char * name() const
Name of the tag, typically the name of the derived class.
bool contiguous() const
If the member data storage is contiguous.
Definition: Array.hpp:656
const ArrayDimTag * tag_type
Type of runtime dimension tags.
Definition: Array.hpp:253
Array(value_type *arg_ptr, const unsigned n1, const unsigned n2, const unsigned n3, const unsigned n4)
Construct a Rank 4..8 array; use Tag#::Size for defaults. The input dimensions are the 4 slowest stri...
Definition: Array.hpp:491
virtual unsigned to_index(unsigned dimension, const std::string &label) const
Given a dimension and input strige produce an index. Default to converting label to an integer...
void dimensions(std::vector< unsigned > &n)
Dimensions of all ordinates.
Definition: Array.hpp:313
bool reverse() const
If the multidimension follows the reverse (Fortran) ordering.
Definition: Array.hpp:276
value_type * m_ptr
Pointer to contiguous block of members.
Definition: Array.hpp:896
An anonymous array dimension tag, which is NOT the recommended usage.
Definition: Array.hpp:190
value_type & operator()(const unsigned i1, const unsigned i2, const unsigned i3, const unsigned i4, const unsigned i5, const unsigned i6, const unsigned i7) const
Access member of a Rank 7 array.
Definition: Array.hpp:366
Special tag to indicate that an array specification has degenerated to rank-zero, i...
Definition: Array.hpp:121
value_type & operator[](size_type i) const
Access member via full ordering of members.
Definition: Array.hpp:716
unsigned dimension(const unsigned ordinal) const
Dimension of the given ordinate.
Definition: Array.hpp:671
const ArrayDimTag * tag_type
Type of runtime dimension tags.
Definition: Array.hpp:633
unsigned dimension() const
Dimension of the given ordinate.
Definition: Array.hpp:299
Array(value_type *arg_ptr, const unsigned n1)
Construct a Rank 1..8 array; use Tag#::Size for defaults. The input dimension is the slowest stride...
Definition: Array.hpp:515
Array(value_type *arg_ptr, const unsigned n1, const unsigned n2, const unsigned n3, const unsigned n4, const unsigned n5)
Construct a Rank 5..8 array; use Tag#::Size for defaults. The input dimensions are the 5 slowest stri...
Definition: Array.hpp:481
tag_type tag(const unsigned ordinal) const
Access the dimension tag-singleton for a given ordinate.
Definition: Array.hpp:661
value_type & operator()(const unsigned i1, const unsigned i2, const unsigned i3, const unsigned i4, const unsigned i5, const unsigned i6, const unsigned i7, const unsigned i8) const
Access member of a Rank 8 array.
Definition: Array.hpp:357
ArrayReverse< Array >::type ReverseType
The compatible multidimensional array with reversed multi-index ordering and dimension tags...
Definition: Array.hpp:415
Array(value_type *arg_ptr, const unsigned n1, const unsigned n2, const unsigned n3, const unsigned n4, const unsigned n5, const unsigned n6, const unsigned n7, const unsigned n8)
Construct a Rank 8 array.
Definition: Array.hpp:449
bool natural() const
If the multidimension follows the natural ordering.
Definition: Array.hpp:273
TruncateType truncate(const unsigned i) const
Generate a subarray view of the array with the slowest striding ordinate offset by i and removed...
Definition: Array.hpp:337
size_type m_stride[Rank]
Array of strides, smallest to largest.
Definition: Array.hpp:529
virtual std::string to_string(unsigned dimension, unsigned index) const
Given a dimension and index produce a string for output. Default to converting index to a string...
value_type & operator()(const unsigned i1, const unsigned i2) const
Access member of a Rank 2 array.
Definition: Array.hpp:399
The preferred multi-dimensional Array interface with compile-time user-defined dimension ordinate...
Definition: Array.hpp:129
Array(const Array &rhs)
Copy constructor.
Definition: Array.hpp:421
value_type & operator[](size_type i) const
Access member via offset into contiguous block.
Definition: Array.hpp:350