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

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

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