00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "error.H"
00028
00029
00030
00031 namespace Foam
00032 {
00033
00034
00035
00036 template<class T>
00037 inline Matrix<T>::Matrix()
00038 :
00039 n_(0),
00040 m_(0),
00041 v_(NULL)
00042 {}
00043
00044
00045 template<class T>
00046 inline autoPtr<Matrix<T> > Matrix<T>::clone() const
00047 {
00048 return autoPtr<Matrix<T> >(new Matrix<T>(*this));
00049 }
00050
00051
00052
00053
00054
00055 template<class T>
00056 inline label Matrix<T>::n() const
00057 {
00058 return n_;
00059 }
00060
00061
00062
00063 template<class T>
00064 inline label Matrix<T>::m() const
00065 {
00066 return m_;
00067 }
00068
00069
00070
00071 template<class T>
00072 inline label Matrix<T>::size() const
00073 {
00074 return n_*m_;
00075 }
00076
00077
00078
00079 template<class T>
00080 inline void Matrix<T>::checki(const label i) const
00081 {
00082 if (!n_)
00083 {
00084 FatalErrorIn("Matrix<T>::checki(const label)")
00085 << "attempt to access element from zero sized row"
00086 << abort(FatalError);
00087 }
00088 else if (i<0 || i>=n_)
00089 {
00090 FatalErrorIn("Matrix<T>::checki(const label)")
00091 << "index " << i << " out of range 0 ... " << n_-1
00092 << abort(FatalError);
00093 }
00094 }
00095
00096
00097
00098 template<class T>
00099 inline void Matrix<T>::checkj(const label j) const
00100 {
00101 if (!m_)
00102 {
00103 FatalErrorIn("Matrix<T>::checkj(const label)")
00104 << "attempt to access element from zero sized column"
00105 << abort(FatalError);
00106 }
00107 else if (j<0 || j>=m_)
00108 {
00109 FatalErrorIn("Matrix<T>::checkj(const label)")
00110 << "index " << j << " out of range 0 ... " << m_-1
00111 << abort(FatalError);
00112 }
00113 }
00114
00115
00116
00117
00118
00119 template<class T>
00120 inline T* Matrix<T>::operator[](const label i)
00121 {
00122 # ifdef FULLDEBUG
00123 checki(i);
00124 # endif
00125 return v_[i];
00126 }
00127
00128
00129
00130 template<class T>
00131 inline const T* Matrix<T>::operator[](const label i) const
00132 {
00133 # ifdef FULLDEBUG
00134 checki(i);
00135 # endif
00136 return v_[i];
00137 }
00138
00139
00140
00141
00142 }
00143
00144
Copyright © 2000-2007 OpenCFD Ltd