Main Page | User's Guide | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members

Array3D.hxx

00001 // Copyright (C) 2001-2004 Vivien Mallet
00002 //
00003 // This file is part of Seldon library.
00004 // Seldon library provides matrices and vectors structures for
00005 // linear algebra.
00006 // 
00007 // Seldon is free software; you can redistribute it and/or modify
00008 // it under the terms of the GNU General Public License as published by
00009 // the Free Software Foundation; either version 2 of the License, or
00010 // (at your option) any later version.
00011 // 
00012 // Seldon is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License (file "license") for more details.
00016 //
00017 // For more information, please see the Seldon home page:
00018 //     http://spacetown.free.fr/lib/seldon/
00019 
00020 // To be included by Seldon.hxx
00021 
00022 
00023 #ifndef SELDON_FILE_ARRAY3D_HXX
00024 
00025 #include "../Common/Common.hxx"
00026 #include "../Common/Errors.cxx"
00027 #include "../Common/Allocator.hxx"
00028 
00029 namespace Seldon
00030 {
00031 
00032   
00034 
00037   template <class T, class Allocator = SELDON_DEFAULT_ALLOCATOR<T> >
00038   class Array3D
00039   {
00040     // typdef declarations.
00041   public:
00042     typedef typename Allocator::value_type value_type;
00043     typedef typename Allocator::pointer pointer;
00044     typedef typename Allocator::const_pointer const_pointer;
00045     typedef typename Allocator::reference reference;
00046     typedef typename Allocator::const_reference const_reference;
00047 
00048     // Static attributes.
00049   protected:
00050     static Allocator array3D_allocator_;
00051 
00052     // Attributes.
00053   protected:
00054     // Length along dimension #1.
00055     int length1_;
00056     // Length along dimension #2.
00057     int length2_;
00058     // Length along dimension #3.
00059     int length3_;
00060 
00061     // Size of a slice (i.e. length1_ by length2_).
00062     int length23_;
00063 
00064     // Pointer to stored elements.
00065     pointer data_;
00066 
00067     // Methods.
00068   public:
00069     // Constructors.
00070     Array3D();
00071     Array3D(int i, int j, int k);
00072   
00073     // Destructor.
00074     ~Array3D();
00075 
00076     // Basic methods.
00077     int GetLength1() const;
00078     int GetLength2() const;
00079     int GetLength3() const;
00080     int GetSize() const;
00081     int GetDataSize() const;
00082     pointer GetData() const;
00083 
00084     // Memory management.
00085     void Reallocate(int i, int j, int k);
00086 
00087     // Element access and affectation.
00088     reference operator() (int i, int j, int k);
00089     const_reference operator() (int i, int j, int k) const;
00090     void Copy(const Array3D<T, Allocator>& A);
00091 
00092     // Convenient functions.
00093     void Zero();
00094     void Fill();
00095     template <class T0>
00096     void Fill(const T0& x);
00097     void FillRand();
00098     void Print() const;
00099 
00100   };
00101 
00102 
00103   // 3D array allocator.
00104   template <class T, class Allocator>
00105   Allocator Array3D<T, Allocator>::array3D_allocator_;
00106 
00107 
00108   template <class T, class Allocator>
00109   ostream& operator << (ostream& out,
00110                         const Array3D<T, Allocator>& A);
00111 
00112 
00113 } // namespace Seldon.
00114 
00115 
00116 #define SELDON_FILE_ARRAY3D_HXX
00117 #endif

Generated on Sun Jan 16 23:37:57 2005 for Multivac by  doxygen 1.4.0