Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SharedArray.hpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File SharedArray.hpp
4 //
5 // For more information, please see: http://www.nektar.info
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Scientific Computing and Imaging Institute,
10 // University of Utah (USA) and Department of Aeronautics, Imperial
11 // College London (UK).
12 //
13 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description:
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef NEKTAR_LIB_UTILITIES_BASIC_UTILS_SHARED_ARRAY_HPP
37 #define NEKTAR_LIB_UTILITIES_BASIC_UTILS_SHARED_ARRAY_HPP
38 
45 
46 #include <boost/assign/list_of.hpp>
47 #include <boost/multi_array.hpp>
48 #include <boost/shared_ptr.hpp>
49 
50 namespace Nektar
51 {
52  class LinearSystem;
53 
54  // Forward declaration for a ConstArray constructor.
55  template<typename Dim, typename DataType>
56  class Array;
57 
58  /// \brief 1D Array of constant elements with garbage collection and bounds checking.
59  template<typename DataType>
60  class Array<OneD, const DataType>
61  {
62  public:
63  typedef DataType* ArrayType;
64  typedef const DataType& const_reference;
65  typedef DataType& reference;
66 
67  typedef const DataType* const_iterator;
68  typedef DataType* iterator;
69 
70  typedef DataType element;
71  typedef unsigned int size_type;
72 
73 
74  public:
75  /// \brief Creates an empty array.
76  Array() :
77  m_size(0),
78  m_capacity(0),
79  m_data(0),
80  m_count(0),
81  m_offset(0)
82  {
83  CreateStorage(m_capacity);
84  }
85 
86  /// \brief Creates an array of size dim1Size.
87  ///
88  /// If DataType is a fundamental type (double, int, etc.), then the allocated array is
89  /// uninitialized. If it is any other type, each element is initialized with DataType's default
90  /// constructor.
91  explicit Array(unsigned int dim1Size) :
92  m_size(dim1Size),
93  m_capacity(dim1Size),
94  m_data(0),
95  m_count(0),
96  m_offset(0)
97  {
98  CreateStorage(m_capacity);
100  }
101 
102  /// \brief Creates a 1D array with each element
103  /// initialized to an initial value.
104  /// \param dim1Size The array's size.
105  /// \param initValue Each element's initial value.
106  ///
107  /// If DataType is a fundamental type (double, int, etc.),
108  /// then the initial value is copied directly into each
109  /// element. Otherwise, the DataType's copy constructor
110  /// is used to initialize each element.
111  Array(unsigned int dim1Size, const DataType& initValue) :
112  m_size(dim1Size),
113  m_capacity(dim1Size),
114  m_data(0),
115  m_count(0),
116  m_offset(0)
117  {
118  CreateStorage(m_capacity);
119  ArrayInitializationPolicy<DataType>::Initialize(m_data + 1, m_capacity, initValue);
120  }
121 
122  /// \brief Creates a 1D array a copies data into it.
123  /// \param dim1Size the array's size.
124  /// \param data The data to copy.
125  ///
126  /// If DataType is a fundamental type (double, int, etc.), then data is copied
127  /// directly into the underlying storage. Otherwise, the DataType's copy constructor
128  /// is used to copy each element.
129  Array(unsigned int dim1Size, const DataType* data) :
130  m_size(dim1Size),
131  m_capacity(dim1Size),
132  m_data(0),
133  m_count(0),
134  m_offset(0)
135  {
136  CreateStorage(m_capacity);
137  ArrayInitializationPolicy<DataType>::Initialize(m_data + 1, m_capacity, data);
138  }
139 
140  /// \brief Creates a 1D array that references rhs.
141  /// \param dim1Size The size of the array. This is useful
142  /// when you want this array to reference
143  /// a subset of the elements in rhs.
144  /// \param rhs Array to reference.
145  /// This constructor creates an array that references rhs.
146  /// Any changes to rhs will be reflected in this array.
147  /// The memory for the array will only be deallocated when
148  /// both rhs and this array have gone out of scope.
149  Array(unsigned int dim1Size, const Array<OneD, const DataType>& rhs) :
150  m_size(dim1Size),
151  m_capacity(rhs.m_capacity),
152  m_data(rhs.m_data),
153  m_count(rhs.m_count),
154  m_offset(rhs.m_offset)
155  {
156  *m_count += 1;
157  ASSERTL0(m_size <= rhs.num_elements(), "Requested size is larger than input array size.");
158  }
159 
160  /// \brief Creates a reference to rhs.
162  m_size(rhs.m_size),
163  m_capacity(rhs.m_capacity),
164  m_data(rhs.m_data),
165  m_count(rhs.m_count),
166  m_offset(rhs.m_offset)
167  {
168  *m_count += 1;
169  }
170 
172  {
173  if( m_count == 0 )
174  {
175  return;
176  }
177 
178  *m_count -= 1;
179  if( *m_count == 0 )
180  {
181  ArrayDestructionPolicy<DataType>::Destroy(m_data+1, m_capacity);
182  MemoryManager<DataType>::RawDeallocate(m_data, m_capacity+1);
183  }
184  }
185 
186  /// \brief Creates a reference to rhs.
188  {
189  *m_count -= 1;
190  if( *m_count == 0 )
191  {
192  ArrayDestructionPolicy<DataType>::Destroy(m_data+1, m_capacity);
193  MemoryManager<DataType>::RawDeallocate(m_data, m_capacity+1);
194  }
195 
196  m_data = rhs.m_data;
197  m_capacity = rhs.m_capacity;
198  m_count = rhs.m_count;
199  *m_count += 1;
200  m_offset = rhs.m_offset;
201  m_size = rhs.m_size;
202  return *this;
203  }
204 
205  const_iterator begin() const { return m_data + m_offset + 1; }
206  const_iterator end() const { return m_data + m_offset + m_size + 1; }
207 
208  const_reference operator[](unsigned int i) const
209  {
210  ASSERTL1(static_cast<size_type>(i) < m_size, (std::string("Element ") +
211  boost::lexical_cast<std::string>(i) + std::string(" requested in an array of size ") +
212  boost::lexical_cast<std::string>(m_size)));
213  return *(m_data + i + m_offset + 1);
214  }
215 
216  /// \brief Returns a c-style pointer to the underlying array.
217  const element* get() const { return m_data+m_offset+1; }
218 
219  /// \brief Returns a c-style pointer to the underlying array.
220  const element* data() const { return m_data+m_offset+1; }
221 
222  /// \brief Returns 1.
223  size_type num_dimensions() const { return 1; }
224 
225  /// \brief Returns the array's size.
226  size_type num_elements() const { return m_size; }
227 
228  size_type capacity() const { return m_capacity; }
229 
230  /// \brief Returns the array's offset.
231  unsigned int GetOffset() const { return m_offset; }
232 
233  /// \brief Returns true is this array and rhs overlap.
234  bool Overlaps(const Array<OneD, const DataType>& rhs) const
235  {
236  const element* start = get();
237  const element* end = start + m_size;
238 
239  const element* rhs_start = rhs.get();
240  const element* rhs_end = rhs_start + rhs.num_elements();
241 
242  return (rhs_start >= start && rhs_start <= end) ||
243  (rhs_end >= start && rhs_end <= end);
244  }
245 
246  template<typename T1, typename T2>
247  friend bool operator==(const Array<OneD, T1>&, const Array<OneD, T2>&);
250 
251  /// \brief Creates an array with a specified offset.
252  ///
253  /// The return value will reference the same array as lhs,
254  /// but with an offset.
255  ///
256  /// For example, in the following:
257  /// \code
258  /// Array<OneD, const double> result = anArray + 10;
259  /// \endcode
260  /// result[0] == anArray[10];
261  template<typename T>
262  friend Array<OneD, T> operator+(const Array<OneD, T>& lhs, unsigned int offset);
263 
264  template<typename T>
265  friend Array<OneD, T> operator+(unsigned int offset, const Array<OneD, T>& rhs);
266 
267  protected:
268  unsigned int m_size;
269  unsigned int m_capacity;
270  //boost::shared_ptr<DataType> m_data;
271  //NekPtr<DataType> m_data;
272  DataType* m_data;
273  unsigned int* m_count;
274  unsigned int m_offset;
275 
276 
277  private:
278  // struct DestroyArray
279  // {
280  // DestroyArray(unsigned int elements) :
281  // m_elements(elements) {}
282  //
283  // void operator()(DataType* p)
284  // {
285  // ArrayDestructionPolicy<DataType>::Destroy(p, m_elements);
286  // MemoryManager<DataType>::RawDeallocate(p, m_elements);
287  // }
288  // unsigned int m_elements;
289  // };
290  //
291  // boost::shared_ptr<DataType>
292  // NekPtr<DataType>
293  void
294  CreateStorage(unsigned int size)
295  {
296  DataType* storage = MemoryManager<DataType>::RawAllocate(size+1);
297  m_data = storage;
298  m_count = (unsigned int*)storage;
299  *m_count = 1;
300  //return NekPtr<DataType>(storage, size);
301  //return boost::shared_ptr<DataType>(storage,
302  //boost::bind(DeleteStorage<DataType>, storage, size) );
303  // DestroyArray(size), MemoryManager<DataType>() );
304  }
305 
306  template<typename T>
307  static Array<OneD, T> CreateWithOffset(const Array<OneD, T>& rhs, unsigned int offset)
308  {
309  Array<OneD, T> result(rhs);
310  result.m_offset += offset;
311  result.m_size = rhs.m_size - offset;
312  return result;
313  }
314 
315  };
316 
317 
318  /// \brief 2D array with garbage collection and bounds checking.
319  template<typename DataType>
320  class Array<TwoD, const DataType>
321  {
322  public:
323  typedef boost::multi_array_ref<DataType, 2> ArrayType;
324  typedef typename ArrayType::const_reference const_reference;
325  typedef typename ArrayType::reference reference;
326 
327  typedef typename ArrayType::index index;
328  typedef typename ArrayType::const_iterator const_iterator;
329  typedef typename ArrayType::iterator iterator;
330 
331  typedef typename ArrayType::element element;
332  typedef typename ArrayType::size_type size_type;
333 
334 
335 
336  public:
337  Array() :
338  m_data(CreateStorage<DataType>(0, 0))
339  {
340  }
341 
342  /// \brief Constructs a 3 dimensional array. The elements of the array are not initialized.
343  Array(unsigned int dim1Size, unsigned int dim2Size) :
344  m_data(CreateStorage<DataType>(dim1Size, dim2Size))
345  {
346  ArrayInitializationPolicy<DataType>::Initialize(m_data->data(), m_data->num_elements());
347  }
348 
349  Array(unsigned int dim1Size, unsigned int dim2Size, const DataType& initValue) :
350  m_data(CreateStorage<DataType>(dim1Size, dim2Size))
351  {
352  ArrayInitializationPolicy<DataType>::Initialize(m_data->data(), m_data->num_elements(), initValue);
353  }
354 
355  Array(unsigned int dim1Size, unsigned int dim2Size, const DataType* data) :
356  m_data(CreateStorage<DataType>(dim1Size, dim2Size))
357  {
358  ArrayInitializationPolicy<DataType>::Initialize(m_data->data(), m_data->num_elements(), data);
359  }
360 
362  m_data(rhs.m_data)
363  {
364  }
365 
367  {
368  m_data = rhs.m_data;
369  return *this;
370  }
371 
372  template<typename T>
373  friend bool operator==(const Array<TwoD, T>&, const Array<TwoD, T>&);
376 
377  const_iterator begin() const { return m_data->begin(); }
378  const_iterator end() const { return m_data->end(); }
379  const_reference operator[](index i) const { return (*m_data)[i]; }
380  const element* get() const { return m_data->data(); }
381  const element* data() const { return m_data->data(); }
382  size_type num_dimensions() const { return m_data->num_dimensions(); }
383  const size_type* shape() const { return m_data->shape(); }
384  size_type num_elements() const { return m_data->num_elements(); }
385 
386  size_type GetRows() const { return m_data->shape()[0]; }
387  size_type GetColumns() const { return m_data->shape()[1]; }
388 
389  protected:
390  boost::shared_ptr<ArrayType> m_data;
391 
392  private:
393 
394  };
395 
396  /// \brief 3D array with garbage collection and bounds checking.
397  template<typename DataType>
398  class Array<ThreeD, const DataType>
399  {
400  public:
401  typedef boost::multi_array_ref<DataType, 3> ArrayType;
402  typedef typename ArrayType::const_reference const_reference;
403  typedef typename ArrayType::reference reference;
404 
405  typedef typename ArrayType::index index;
406  typedef typename ArrayType::const_iterator const_iterator;
407  typedef typename ArrayType::iterator iterator;
408 
409  typedef typename ArrayType::element element;
410  typedef typename ArrayType::size_type size_type;
411 
412 
413 
414  public:
415  Array() :
416  m_data(CreateStorage<DataType>(0, 0, 0))
417  {
418  }
419 
420  /// \brief Constructs a 3 dimensional array. The elements of the array are not initialized.
421  Array(unsigned int dim1Size, unsigned int dim2Size, unsigned int dim3Size) :
422  m_data(CreateStorage<DataType>(dim1Size, dim2Size, dim3Size))
423  {
424  ArrayInitializationPolicy<DataType>::Initialize(m_data->data(), m_data->num_elements());
425  }
426 
427  Array(unsigned int dim1Size, unsigned int dim2Size, unsigned int dim3Size, const DataType& initValue) :
428  m_data(CreateStorage<DataType>(dim1Size, dim2Size, dim3Size))
429  {
430  ArrayInitializationPolicy<DataType>::Initialize(m_data->data(), m_data->num_elements(), initValue);
431  }
432 
434  m_data(rhs.m_data)
435  {
436  }
437 
439  {
440  m_data = rhs.m_data;
441  return *this;
442  }
443 
444  const_iterator begin() const { return m_data->begin(); }
445  const_iterator end() const { return m_data->end(); }
446  const_reference operator[](index i) const { return (*m_data)[i]; }
447  const element* get() const { return m_data->data(); }
448  const element* data() const { return m_data->data(); }
449  size_type num_dimensions() const { return m_data->num_dimensions(); }
450  const size_type* shape() const { return m_data->shape(); }
451  size_type num_elements() const { return m_data->num_elements(); }
452 
453  protected:
454  boost::shared_ptr<ArrayType> m_data;
455 
456  private:
457 
458  };
459 
460 
462  {
464  };
465 
466  /// \brief 1D Array
467  ///
468  /// \ref pageNekArrays
469  ///
470  /// Misc notes.
471  ///
472  /// Throught the 1D Array class you will see things like "using BaseType::begin" and
473  /// "using BaseType::end". This is necessary to bring the methods from the ConstArray
474  /// into scope in Array class. Typically this is not necessary, but since we have
475  /// method names which match those in the base class, the base class names are hidden.
476  /// Therefore, we have to explicitly bring them into scope to use them.
477  template<typename DataType>
478  class Array<OneD, DataType> : public Array<OneD, const DataType>
479  {
480  public:
482  typedef typename BaseType::iterator iterator;
483  typedef typename BaseType::reference reference;
484  typedef typename BaseType::size_type size_type;
485  typedef typename BaseType::element element;
486 
487  public:
488  Array() :
489  BaseType()
490  {
491  }
492 
493  explicit Array(unsigned int dim1Size) :
494  BaseType(dim1Size)
495  {
496  }
497 
498  Array(unsigned int dim1Size, const DataType& initValue) :
499  BaseType(dim1Size, initValue)
500  {
501  }
502 
503  Array(unsigned int dim1Size, const DataType* data) :
504  BaseType(dim1Size, data)
505  {
506  }
507 
508  Array(unsigned int dim1Size, const Array<OneD, DataType>& rhs) :
509  BaseType(dim1Size, rhs)
510  {
511  }
512 
513  Array(unsigned int dim1Size, const Array<OneD, const DataType>& rhs) :
514  BaseType(dim1Size, rhs.data())
515  {
516  }
517 
519  BaseType(rhs)
520  {
521  }
522 
524  BaseType(rhs.num_elements(), rhs.data())
525  {
526  }
527 
529  {
530  BaseType::operator=(rhs);
531  return *this;
532  }
533 
534  static Array<OneD, DataType> CreateWithOffset(const Array<OneD, DataType>& rhs, unsigned int offset)
535  {
536  Array<OneD, DataType> result(rhs);
537  result.m_offset += offset;
538  result.m_size = rhs.m_size - offset;
539  return result;
540  }
541 
542  using BaseType::begin;
543  iterator begin() { return this->m_data + 1 +this->m_offset; }
544 
545  using BaseType::end;
546  iterator end() { return this->m_data + 1 + this->m_offset + this->m_size; }
547 
548  using BaseType::operator[];
549  reference operator[](unsigned int i)
550  {
551  ASSERTL1(static_cast<size_type>(i) < this->num_elements(), (std::string("Element ") +
552  boost::lexical_cast<std::string>(i) + std::string(" requested in an array of size ") +
553  boost::lexical_cast<std::string>(this->num_elements())));
554  return (get())[i];
555  }
556 
557 
558  using BaseType::get;
559  element* get() { return this->m_data + 1 +this->m_offset; }
560 
561  using BaseType::data;
562  element* data() { return this->m_data + 1 +this->m_offset; }
563 
564  template<typename T1>
565  friend class NekVector;
566 
567  template<typename T1, typename T3>
568  friend class NekMatrix;
569 
570  friend class LinearSystem;
571 
572  protected:
574  BaseType(rhs)
575  {
576  }
577 
578  void ChangeSize(unsigned int newSize)
579  {
580  ASSERTL1(newSize <= this->m_capacity, "Can't change an array size to something larger than its capacity.");
581  this->m_size = newSize;
582  }
583 
584  private:
585 
586  };
587 
588  /// \brief A 2D array.
589  template<typename DataType>
590  class Array<TwoD, DataType> : public Array<TwoD, const DataType>
591  {
592  public:
594  typedef typename BaseType::iterator iterator;
595  typedef typename BaseType::reference reference;
596  typedef typename BaseType::index index;
597  typedef typename BaseType::size_type size_type;
598  typedef typename BaseType::element element;
599 
600  public:
601  Array() :
602  BaseType()
603  {
604  }
605 
606  Array(unsigned int dim1Size, unsigned int dim2Size) :
607  BaseType(dim1Size, dim2Size)
608  {
609  }
610 
611  Array(unsigned int dim1Size, unsigned int dim2Size, const DataType& initValue) :
612  BaseType(dim1Size, dim2Size, initValue)
613  {
614  }
615 
616  Array(unsigned int dim1Size, unsigned int dim2Size, const DataType* data) :
617  BaseType(dim1Size, dim2Size, data)
618  {
619  }
620 
622  BaseType(rhs)
623  {
624  }
625 
627  {
628  BaseType::operator=(rhs);
629  return *this;
630  }
631 
632  using BaseType::begin;
633  iterator begin() { return this->m_data->begin(); }
634 
635  using BaseType::end;
636  iterator end() { return this->m_data->end(); }
637 
638  using BaseType::operator[];
639  reference operator[](index i) { return (*this->m_data)[i]; }
640 
641  using BaseType::get;
642  element* get() { return this->m_data->data(); }
643 
644  using BaseType::data;
645  element* data() { return this->m_data->data(); }
646 
647  private:
648 
649  };
650 
651  /// \brief A 3D array.
652  template<typename DataType>
653  class Array<ThreeD, DataType> : public Array<ThreeD, const DataType>
654  {
655  public:
657  typedef typename BaseType::iterator iterator;
658  typedef typename BaseType::reference reference;
659  typedef typename BaseType::index index;
660  typedef typename BaseType::size_type size_type;
661  typedef typename BaseType::element element;
662 
663  public:
664  Array() :
665  BaseType()
666  {
667  }
668 
669  Array(unsigned int dim1Size, unsigned int dim2Size, unsigned int dim3Size) :
670  BaseType(dim1Size, dim2Size, dim3Size)
671  {
672  }
673 
674  Array(unsigned int dim1Size, unsigned int dim2Size, unsigned int dim3Size, const DataType& initValue) :
675  BaseType(dim1Size, dim2Size, dim3Size, initValue)
676  {
677  }
678 
680  BaseType(rhs)
681  {
682  }
683 
685  {
686  BaseType::operator=(rhs);
687  return *this;
688  }
689 
690  using BaseType::begin;
691  iterator begin() { return this->m_data->begin(); }
692 
693  using BaseType::end;
694  iterator end() { return this->m_data->end(); }
695 
696  using BaseType::operator[];
697  reference operator[](index i) { return (*this->m_data)[i]; }
698 
699  using BaseType::get;
700  element* get() { return this->m_data->data(); }
701 
702  using BaseType::data;
703  element* data() { return this->m_data->data(); }
704 
705  private:
706 
707  };
708 
709  LIB_UTILITIES_EXPORT bool IsEqual(const Array<OneD, const NekDouble>& lhs,
710  const Array<OneD, const NekDouble>& rhs,
712  LIB_UTILITIES_EXPORT bool operator==(const Array<OneD, NekDouble>& lhs, const Array<OneD, NekDouble>& rhs);
713 
714  template<typename T1, typename T2>
716  {
717  if( lhs.num_elements() != rhs.num_elements() )
718  {
719  return false;
720  }
721 
722  if( lhs.data() == rhs.data() )
723  {
724  return true;
725  }
726 
727  for(unsigned int i = 0; i < lhs.num_elements(); ++i)
728  {
729  if( lhs[i] != rhs[i] )
730  {
731  return false;
732  }
733  }
734 
735  return true;
736  }
737 
738  template<typename T1, typename T2>
740  {
741  return !(lhs == rhs);
742  }
743 
744  template<typename DataType>
746  {
748  }
749 
750  template<typename DataType>
751  Array<OneD, DataType> operator+(unsigned int offset, const Array<OneD, DataType>& rhs)
752  {
754  }
755 
756 // template<typename DataType>
757 // Array<OneD, DataType> operator+(const Array<OneD, DataType>& lhs, unsigned int offset)
758 // {
759 // return Array<OneD, DataType>::CreateWithOffset(lhs, offset);
760 // }
761 
762  template<typename ConstDataType, typename DataType>
764  {
765  if( dest.num_elements() != source.num_elements() )
766  {
767  dest = Array<OneD, DataType>(source.num_elements());
768  }
769 
770  std::copy(source.data(), source.data() + source.num_elements(), dest.data());
771  }
772 
773  template<typename ConstDataType, typename DataType>
774  void CopyArrayN(const Array<OneD, ConstDataType>& source, Array<OneD, DataType>& dest, unsigned int n)
775  {
776  if( dest.num_elements() != n )
777  {
778  dest = Array<OneD, DataType>(n);
779  }
780 
781  std::copy(source.data(), source.data() + n, dest.data());
782  }
783 
787 
789  const Array<TwoD, const NekDouble>& rhs,
792 
793  template<typename DataType>
795  {
796  return *lhs.m_data == *rhs.m_data;
797  }
798 
799  template<typename DataType>
801  {
802  return !(lhs == rhs);
803  }
804 
805  namespace LibUtilities
806  {
807  static std::vector<NekDouble> NullNekDoubleVector;
808  static std::vector<unsigned int> NullUnsignedIntVector;
809  static std::vector<std::vector<NekDouble> > NullVectorNekDoubleVector =
810  boost::assign::list_of(NullNekDoubleVector);
811  }
812 }
813 
814 #endif //NEKTAR_LIB_UTILITIES_BASIC_UTILS_SHARED_ARRAY_HPP
const_reference operator[](index i) const
ArrayType::const_iterator const_iterator
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
Array(unsigned int dim1Size, const DataType &initValue)
Creates a 1D array with each element initialized to an initial value.
Array(unsigned int dim1Size, unsigned int dim2Size, unsigned int dim3Size)
Constructs a 3 dimensional array. The elements of the array are not initialized.
Array(const Array< TwoD, DataType > &rhs)
Array(unsigned int dim1Size)
Creates an array of size dim1Size.
Definition: SharedArray.hpp:91
Array< ThreeD, DataType > & operator=(const Array< ThreeD, DataType > &rhs)
static Array< OneD, NekDouble > NullNekDouble1DArray
Array(unsigned int dim1Size, const Array< OneD, DataType > &rhs)
Array(unsigned int dim1Size, unsigned int dim2Size, const DataType &initValue)
Array(const Array< OneD, DataType > &rhs)
size_type num_dimensions() const
Returns 1.
Array< ThreeD, const DataType > & operator=(const Array< ThreeD, const DataType > &rhs)
Array(unsigned int dim1Size, unsigned int dim2Size, const DataType &initValue)
Array(const Array< TwoD, const DataType > &rhs)
Array(const Array< ThreeD, DataType > &rhs)
2D array with garbage collection and bounds checking.
Array(unsigned int dim1Size, unsigned int dim2Size, unsigned int dim3Size, const DataType &initValue)
Array()
Creates an empty array.
Definition: SharedArray.hpp:76
ArrayType::const_reference const_reference
Array< TwoD, DataType > & operator=(const Array< TwoD, DataType > &rhs)
void ChangeSize(unsigned int newSize)
bool operator==(const Array< OneD, NekDouble > &lhs, const Array< OneD, NekDouble > &rhs)
Array(const Array< OneD, const DataType > &rhs)
StandardMatrixTag & lhs
BaseType::size_type size_type
boost::shared_ptr< boost::multi_array_ref< DataType, Dim::Value > > CreateStorage(const ExtentListType &extent)
static std::vector< NekDouble > NullNekDoubleVector
Array(unsigned int dim1Size, const Array< OneD, const DataType > &rhs)
Creates a 1D array that references rhs.
size_type num_elements() const
Returns the array's size.
Array< TwoD, const DataType > & operator=(const Array< TwoD, const DataType > &rhs)
Array(unsigned int dim1Size)
Array< OneD, const DataType > & operator=(const Array< OneD, const DataType > &rhs)
Creates a reference to rhs.
Array(unsigned int dim1Size, const DataType *data)
Creates a 1D array a copies data into it.
static const NekDouble kNekZeroTol
boost::multi_array_ref< DataType, 2 > ArrayType
AllowWrappingOfConstArrays
static void RawDeallocate(DataType *array, unsigned int NumberOfElements)
Deallocates memory allocated from RawAllocate.
ArrayType::const_reference const_reference
3D array with garbage collection and bounds checking.
Array(const Array< OneD, const DataType > &rhs)
Creates a reference to rhs.
bool operator!=(const Array< OneD, T1 > &lhs, const Array< OneD, T2 > &rhs)
#define LIB_UTILITIES_EXPORT
bool Overlaps(const Array< OneD, const DataType > &rhs) const
Returns true is this array and rhs overlap.
void CopyArrayN(const Array< OneD, ConstDataType > &source, Array< OneD, DataType > &dest, unsigned int n)
static std::vector< std::vector< NekDouble > > NullVectorNekDoubleVector
static std::vector< unsigned int > NullUnsignedIntVector
const size_type * shape() const
Array< OneD, const DataType > BaseType
reference operator[](unsigned int i)
Array< ThreeD, const DataType > BaseType
Array(unsigned int dim1Size, unsigned int dim2Size)
Array(unsigned int dim1Size, unsigned int dim2Size, const DataType *data)
Array< OneD, DataType > operator+(const Array< OneD, DataType > &lhs, unsigned int offset)
double NekDouble
static Array< OneD, DataType > CreateWithOffset(const Array< OneD, DataType > &rhs, unsigned int offset)
void CopyArray(const Array< OneD, ConstDataType > &source, Array< OneD, DataType > &dest)
Array(const Array< ThreeD, const DataType > &rhs)
BaseType::reference reference
Array(unsigned int dim1Size, unsigned int dim2Size, unsigned int dim3Size, const DataType &initValue)
BaseType::size_type size_type
boost::shared_ptr< ArrayType > m_data
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
Array(unsigned int dim1Size, const Array< OneD, const DataType > &rhs)
Array(unsigned int dim1Size, const DataType *data)
Array(unsigned int dim1Size, unsigned int dim2Size, unsigned int dim3Size)
boost::shared_ptr< ArrayType > m_data
#define dest(otri, vertexptr)
Array(unsigned int dim1Size, unsigned int dim2Size)
Constructs a 3 dimensional array. The elements of the array are not initialized.
const_reference operator[](index i) const
Array(unsigned int dim1Size, const DataType &initValue)
ArrayType::const_iterator const_iterator
void CreateStorage(unsigned int size)
unsigned int GetOffset() const
Returns the array's offset.
const element * data() const
Returns a c-style pointer to the underlying array.
Array(unsigned int dim1Size, unsigned int dim2Size, const DataType *data)
static DataType * RawAllocate(unsigned int NumberOfElements)
Allocates a chunk of raw, uninitialized memory, capable of holding NumberOfElements objects...
const_reference operator[](unsigned int i) const
BaseType::reference reference
const size_type * shape() const
const element * get() const
Returns a c-style pointer to the underlying array.
boost::multi_array_ref< DataType, 3 > ArrayType
static Array< OneD, Array< OneD, NekDouble > > NullNekDoubleArrayofArray
static Array< OneD, int > NullInt1DArray
Array< OneD, DataType > & operator=(const Array< OneD, DataType > &rhs)
1D Array of constant elements with garbage collection and bounds checking.
Definition: SharedArray.hpp:60
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:228
Array(const Array< OneD, const DataType > &rhs, AllowWrappingOfConstArrays a)
Array< TwoD, const DataType > BaseType
bool IsEqual(const Array< OneD, const NekDouble > &lhs, const Array< OneD, const NekDouble > &rhs, NekDouble tol)
static Array< OneD, T > CreateWithOffset(const Array< OneD, T > &rhs, unsigned int offset)