vector/Vector3.hxx

00001 // Copyright (C) 2010, INRIA
00002 // Author(s): Marc Fragu
00003 //
00004 // This file is part of the linear-algebra library Seldon,
00005 // http://seldon.sourceforge.net/.
00006 //
00007 // Seldon is free software; you can redistribute it and/or modify it under the
00008 // terms of the GNU Lesser General Public License as published by the Free
00009 // Software Foundation; either version 2.1 of the License, or (at your option)
00010 // any later version.
00011 //
00012 // Seldon is distributed in the hope that it will be useful, but WITHOUT ANY
00013 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00014 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
00015 // more details.
00016 //
00017 // You should have received a copy of the GNU Lesser General Public License
00018 // along with Seldon. If not, see http://www.gnu.org/licenses/.
00019 
00020 
00021 #ifndef SELDON_FILE_VECTOR_VECTOR_3_HXX
00022 
00023 
00024 #ifndef SELDON_VECTOR3_DEFAULT_ALLOCATOR_0
00025 
00028 #define SELDON_VECTOR3_DEFAULT_ALLOCATOR_0 SELDON_DEFAULT_ALLOCATOR
00029 #endif
00030 
00031 #ifndef SELDON_VECTOR3_DEFAULT_ALLOCATOR_1
00032 
00035 #define SELDON_VECTOR3_DEFAULT_ALLOCATOR_1 MallocObject
00036 #endif
00037 
00038 #ifndef SELDON_VECTOR3_DEFAULT_ALLOCATOR_2
00039 #define SELDON_VECTOR3_DEFAULT_ALLOCATOR_2 MallocObject
00040 
00043 #endif
00044 
00045 
00046 namespace Seldon
00047 {
00048 
00050 
00064   template <class T,
00065             class Allocator0 = SELDON_VECTOR3_DEFAULT_ALLOCATOR_0<T>,
00066             class Allocator1 = SELDON_VECTOR3_DEFAULT_ALLOCATOR_1<
00067               Vector<T, Vect_Full, Allocator0> >,
00068             class Allocator2 =
00069             SELDON_VECTOR3_DEFAULT_ALLOCATOR_2<
00070               Vector<Vector<T, Vect_Full, Allocator0>,
00071                      Vect_Full, Allocator1> > >
00072   class Vector3
00073   {
00074   public:
00075     typedef T value_type;
00076     typedef T* pointer;
00077     typedef const T* const_pointer;
00078     typedef T& reference;
00079     typedef const T& const_reference;
00080 
00081   protected:
00082     Vector<Vector<Vector<T, Vect_Full, Allocator0>, Vect_Full, Allocator1>,
00083            Vect_Full, Allocator2> data_;
00084 
00085   public:
00086 
00087     /*** Constructors and destructor ***/
00088 
00089     Vector3();
00090     Vector3(int);
00091     Vector3(Vector<int>& length);
00092     template <class Allocator>
00093     Vector3(Vector<Vector<int>, Vect_Full, Allocator>& length);
00094     ~Vector3();
00095 
00096     /*** Management of the vectors ***/
00097 
00098     int GetLength() const;
00099     int GetSize() const;
00100     int GetLength(int i) const;
00101     int GetSize(int i) const;
00102     int GetLength(int i, int j) const;
00103     int GetSize(int i, int j) const;
00104     int GetNelement() const;
00105     int GetNelement(int beg, int end) const;
00106     void Reallocate(int N);
00107     void Reallocate(int i, int N);
00108     void Reallocate(int i, int j, int N);
00109 
00110     template <class Td, class Allocatord>
00111     void Flatten(Vector<Td, VectFull, Allocatord>& data) const;
00112     template <class Td, class Allocatord>
00113     void Flatten(int beg, int end, Vector<Td, VectFull, Allocatord>& data)
00114       const;
00115 
00116     void PushBack(int i, int j, const T& x);
00117     void PushBack(int i, const Vector<T, Vect_Full, Allocator0>& X);
00118     void PushBack(const Vector<Vector<T, Vect_Full, Allocator0>,
00119                   Vect_Full, Allocator1>& X);
00120     void PushBack(const Vector<Vector<Vector<T, Vect_Full, Allocator0>,
00121                   Vect_Full, Allocator1>, Vect_Full, Allocator2>& X);
00122     void PushBack(const Vector3<T, Allocator0, Allocator1, Allocator2>& X);
00123 
00124 
00125     void Clear();
00126     void Clear(int i);
00127     void Clear(int i, int j);
00128 
00129     void Fill(const T& x);
00130 
00131     Vector<Vector<Vector<T, Vect_Full, Allocator0>, Vect_Full, Allocator1>,
00132            Vect_Full, Allocator2>&
00133     GetVector();
00134     const Vector<Vector<Vector<T, Vect_Full, Allocator0>,
00135                         Vect_Full, Allocator1>, Vect_Full, Allocator2>&
00136     GetVector() const;
00137 
00138     Vector<Vector<T, Vect_Full, Allocator0>, VectFull, Allocator1>&
00139     GetVector(int i);
00140     const Vector<Vector<T, Vect_Full, Allocator0>, VectFull, Allocator1>&
00141     GetVector(int i) const;
00142 
00143     Vector<T, Vect_Full, Allocator0>& GetVector(int i, int j);
00144     const Vector<T, Vect_Full, Allocator0>& GetVector(int i, int j)
00145       const;
00146 
00147     /*** Element access and assignment ***/
00148     const
00149     Vector<Vector<T, Vect_Full, Allocator0>, VectFull, Allocator1>&
00150     operator() (int i) const;
00151     Vector<Vector<T, Vect_Full, Allocator0>, VectFull, Allocator1>&
00152     operator() (int i);
00153 
00154     const Vector<T, Vect_Full, Allocator0>& operator() (int i, int j)
00155       const;
00156     Vector<T, Vect_Full, Allocator0>& operator() (int i, int j);
00157 
00158     const_reference operator() (int i, int j, int k) const;
00159     reference operator() (int i, int j, int k);
00160 
00161     /*** Convenient method ***/
00162 
00163     void Print() const;
00164   };
00165 
00166 }
00167 
00168 
00169 #define SELDON_FILE_VECTOR_VECTOR_3_HXX
00170 #endif