Warning: this documentation for the development version is under construction.

/home/vivien/public_html/.src_seldon/vector/Vector3.hxx

00001 // Copyright (C) 2010-2012, INRIA
00002 // Author(s): Marc Fragu, Vivien Mallet
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     int GetNelement(int beg0, int end0, int beg1, int end1) const;
00107     Vector<int> GetShape(int i) const;
00108     void GetShape(int i, Vector<int>& shape) const;
00109     void Reallocate(int N);
00110     void Reallocate(int i, int N);
00111     void Reallocate(int i, int j, int N);
00112 
00113     template <class Td, class Allocatord>
00114     void Flatten(Vector<Td, VectFull, Allocatord>& data) const;
00115     template <class Td, class Allocatord>
00116     void Flatten(int beg, int end, Vector<Td, VectFull, Allocatord>& data)
00117       const;
00118     template <class Td, class Allocatord>
00119     void Flatten(int beg0, int end0, int beg1, int end1,
00120                  Vector<Td, VectFull, Allocatord>& data) const;
00121 
00122     void PushBack(int i, int j, const T& x);
00123     void PushBack(int i, const Vector<T, Vect_Full, Allocator0>& X);
00124     void PushBack(const Vector<Vector<T, Vect_Full, Allocator0>,
00125                   Vect_Full, Allocator1>& X);
00126     void PushBack(const Vector<Vector<Vector<T, Vect_Full, Allocator0>,
00127                   Vect_Full, Allocator1>, Vect_Full, Allocator2>& X);
00128     void PushBack(const Vector3<T, Allocator0, Allocator1, Allocator2>& X);
00129 
00130 
00131     void Clear();
00132     void Clear(int i);
00133     void Clear(int i, int j);
00134 
00135     void Fill(const T& x);
00136 
00137     Vector<Vector<Vector<T, Vect_Full, Allocator0>, Vect_Full, Allocator1>,
00138            Vect_Full, Allocator2>&
00139     GetVector();
00140     const Vector<Vector<Vector<T, Vect_Full, Allocator0>,
00141                         Vect_Full, Allocator1>, Vect_Full, Allocator2>&
00142     GetVector() const;
00143 
00144     Vector<Vector<T, Vect_Full, Allocator0>, VectFull, Allocator1>&
00145     GetVector(int i);
00146     const Vector<Vector<T, Vect_Full, Allocator0>, VectFull, Allocator1>&
00147     GetVector(int i) const;
00148 
00149     Vector<T, Vect_Full, Allocator0>& GetVector(int i, int j);
00150     const Vector<T, Vect_Full, Allocator0>& GetVector(int i, int j) const;
00151 
00152     /*** Element access and assignment ***/
00153     const
00154     Vector<Vector<T, Vect_Full, Allocator0>, VectFull, Allocator1>&
00155     operator() (int i) const;
00156     Vector<Vector<T, Vect_Full, Allocator0>, VectFull, Allocator1>&
00157     operator() (int i);
00158 
00159     const Vector<T, Vect_Full, Allocator0>& operator() (int i, int j)
00160       const;
00161     Vector<T, Vect_Full, Allocator0>& operator() (int i, int j);
00162 
00163     const_reference operator() (int i, int j, int k) const;
00164     reference operator() (int i, int j, int k);
00165 
00166     /*** Convenient method ***/
00167 
00168     void Print() const;
00169 
00170     /*** Input/output functions ***/
00171 
00172     void Write(string file_name, bool with_size = true) const;
00173     void Write(ostream& file_stream, bool with_size = true) const;
00174     void Read(string file_name, bool with_size = true);
00175     void Read(istream& file_stream, bool with_size = true);
00176   };
00177 
00178 }
00179 
00180 
00181 #define SELDON_FILE_VECTOR_VECTOR_3_HXX
00182 #endif