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 template<class T>
00055 inline label Matrix<T>::n() const
00056 {
00057 return n_;
00058 }
00059
00060
00061
00062 template<class T>
00063 inline label Matrix<T>::m() const
00064 {
00065 return m_;
00066 }
00067
00068
00069
00070 template<class T>
00071 inline label Matrix<T>::size() const
00072 {
00073 return n_*m_;
00074 }
00075
00076
00077
00078 template<class T>
00079 inline void Matrix<T>::checki(const label i) const
00080 {
00081 if (!n_)
00082 {
00083 FatalErrorIn("Matrix<T>::checki(const label)")
00084 << "attempt to access element from zero sized row"
00085 << abort(FatalError);
00086 }
00087 else if (i<0 || i>=n_)
00088 {
00089 FatalErrorIn("Matrix<T>::checki(const label)")
00090 << "index " << i << " out of range 0 ... " << n_-1
00091 << abort(FatalError);
00092 }
00093 }
00094
00095
00096
00097 template<class T>
00098 inline void Matrix<T>::checkj(const label j) const
00099 {
00100 if (!m_)
00101 {
00102 FatalErrorIn("Matrix<T>::checkj(const label)")
00103 << "attempt to access element from zero sized column"
00104 << abort(FatalError);
00105 }
00106 else if (j<0 || j>=m_)
00107 {
00108 FatalErrorIn("Matrix<T>::checkj(const label)")
00109 << "index " << j << " out of range 0 ... " << m_-1
00110 << abort(FatalError);
00111 }
00112 }
00113
00114
00115
00116
00117
00118 template<class T>
00119 inline T* Matrix<T>::operator[](const label i)
00120 {
00121 # ifdef FULLDEBUG
00122 checki(i);
00123 # endif
00124 return v_[i];
00125 }
00126
00127
00128
00129 template<class T>
00130 inline const T* Matrix<T>::operator[](const label i) const
00131 {
00132 # ifdef FULLDEBUG
00133 checki(i);
00134 # endif
00135 return v_[i];
00136 }
00137
00138
00139
00140
00141 }
00142
00143