00001
00002
00003
00004
00005
00006 #ifndef SYNAPS_LINALG_ARRAY3D_H
00007 #define SYNAPS_LINALG_ARRAY3D_H
00008
00009 #include <synaps/init.h>
00010 #include <synaps/arithm/Norm.h>
00011 #include <synaps/linalg/MethodName.h>
00012 #include <synaps/base/stride_iterator.h>
00013 #include <synaps/linalg/rep1d.h>
00014
00015
00016 __BEGIN_NAMESPACE_SYNAPS
00017
00018 namespace linalg {
00019
00020 typedef unsigned size_type;
00021
00026 template < class C >
00027 struct rep3d : public rep1d<C> {
00028
00029 typedef rep1d<C> rep1d;
00030
00032 size_type n1_, n2_, n3_;
00033
00035 rep3d(): linalg::rep1d< C >(){}
00036
00038 rep3d( const rep3d< C > & v ):
00039 linalg::rep1d< C >( v ), n1_( v.n1_ ), n2_( v.n2_ ), n3_( v.n3_ ) {}
00040
00042 rep3d( size_type i, size_type j, size_type k ):
00043 linalg::rep1d< C >( i*j*k ), n1_( i ), n2_( j ), n3_( k ) {}
00044
00045 rep3d( size_type i, size_type j, size_type k, C* t):
00046 linalg::rep1d< C >( i*j*k,t ), n1_( i ), n2_( j ), n3_( k ) {}
00047
00048 rep3d( size_type i, size_type j, size_type k, C* t, char c );
00049
00050 rep3d( const char * nm );
00051
00052 rep3d< C > & operator=( const rep3d< C > & v);
00053
00054 C & operator()( size_type i, size_type j, size_type k ) {
00055 assert( i < n1_ && j < n2_ && k < n3_ );
00056 return this->tab_[ i+n1_*j+n1_*n2_*k ];
00057 }
00058
00059 const C & operator()( size_type i, size_type j, size_type k ) const {
00060 assert( i < n1_ && j < n2_ && k < n3_);
00061 return this->tab_[ i+n1_*j+n1_*n2_*k ];
00062 }
00063
00065 size_type nbrow() const { return n1_; }
00066 size_type nbcol() const { return n2_; }
00067 size_type nbhgt() const { return n3_; }
00068
00069 void resize( size_type i, size_type j, size_type k ){
00070 this->linalg::rep1d< C >::resize( i*j*k );
00071 n1_ = i;
00072 n2_ = j;
00073 n3_ = k;
00074 }
00075
00076 };
00077
00078
00079 template < class C >
00080 rep3d< C >::rep3d(const char * nm){
00081 std::ifstream ins( nm, std::ios::in );
00082 ins >> n1_ >> n2_ >>n3_;
00083 this->size_ = n1_*n2_*n3_; this->tab_ = new C[this->size_];
00084 for( size_type i = 0; i < this->size_ ; i++ )
00085 ins >>this->tab_[i];
00086 ins.close();
00087 }
00088
00089
00090 template < class C >
00091 rep3d< C > & rep3d< C >::operator=( const rep3d< C > & v ){
00092 this->linalg::rep1d< C >::operator=( v );
00093 n1_ = v.nbrow();
00094 n2_ = v.nbcol();
00095 n3_ = v.nbhgt();
00096 return (*this);
00097 }
00098
00099 }
00100
00101
00102 __END_NAMESPACE_SYNAPS
00103
00104 #endif // SYNAPS_LINALG_ARRAY3D_H
00105