MatrixImplementation.hpp

Go to the documentation of this file.
00001 #pragma ident "$Id: MatrixImplementation.hpp 3140 2012-06-18 15:03:02Z susancummins $"
00002 
00003 
00004 
00010 #ifndef GPSTK_MATRIX_IMPLEMENTATION_HPP
00011 #define GPSTK_MATRIX_IMPLEMENTATION_HPP
00012 
00013 //============================================================================
00014 //
00015 //  This file is part of GPSTk, the GPS Toolkit.
00016 //
00017 //  The GPSTk is free software; you can redistribute it and/or modify
00018 //  it under the terms of the GNU Lesser General Public License as published
00019 //  by the Free Software Foundation; either version 2.1 of the License, or
00020 //  any later version.
00021 //
00022 //  The GPSTk is distributed in the hope that it will be useful,
00023 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00024 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00025 //  GNU Lesser General Public License for more details.
00026 //
00027 //  You should have received a copy of the GNU Lesser General Public
00028 //  License along with GPSTk; if not, write to the Free Software Foundation,
00029 //  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
00030 //  
00031 //  Copyright 2004, The University of Texas at Austin
00032 //
00033 //============================================================================
00034 
00035 namespace gpstk
00036 {
00037 
00040 
00041    template <class T>
00042    Matrix<T>::Matrix()
00043          : v((size_t)0), r(0), c(0), s(0)
00044    {}
00045 
00046 
00047    template <class T>
00048    Matrix<T>::Matrix(size_t rows, size_t cols)
00049          : v(rows * cols), r(rows), c(cols), s(rows * cols)
00050    {}
00051 
00052    template <class T>
00053    Matrix<T>::Matrix(size_t rows, size_t cols,
00054                   T initialValue)
00055          : v(rows * cols, initialValue), r(rows), c(cols), s(rows * cols)
00056    {}
00057 
00058    template <class T>
00059    Matrix<T>::Matrix(size_t rows, size_t cols,
00060                      const T* vec)
00061          : v(rows * cols), r(rows), c(cols), s(rows * cols)
00062    {
00063       assignFrom(vec);
00064    }
00065 
00066    template <class T>
00067    MatrixRowSlice<T> Matrix<T>::rowRef(size_t rowNum, const std::slice& s)
00068    {
00069       return MatrixRowSlice<T>(*this, rowNum, s);
00070    }
00071 
00072    template <class T>
00073    MatrixRowSlice<T> Matrix<T>::rowRef(size_t rowNum, size_t colNum)
00074    {
00075       return MatrixRowSlice<T>(*this, rowNum, 
00076                             std::slice(colNum, cols()-colNum, 1));
00077    }
00078 
00079    template <class T>
00080    ConstMatrixRowSlice<T> Matrix<T>::row(size_t rowNum, const std::slice& s) 
00081       const
00082    {
00083       return ConstMatrixRowSlice<T>(*this, rowNum, s);
00084    }
00085 
00086    template <class T>
00087    ConstMatrixRowSlice<T> Matrix<T>::row(size_t rowNum, size_t colNum)
00088       const
00089    {
00090       return ConstMatrixRowSlice<T>(*this, rowNum, 
00091                                  std::slice(colNum, cols()-colNum, 1));
00092    }
00093 
00094    template <class T>
00095    MatrixColSlice<T> Matrix<T>::colRef(size_t colNum, const std::slice& s)
00096    {
00097       return MatrixColSlice<T>(*this, colNum, s);
00098    }
00099 
00100    template <class T>
00101    MatrixColSlice<T> Matrix<T>::colRef(size_t colNum, size_t rowNum)
00102    {
00103       return MatrixColSlice<T>(*this, colNum, 
00104                             std::slice(rowNum, rows() - rowNum, 1));
00105    }
00106 
00107    template <class T>
00108    ConstMatrixColSlice<T> Matrix<T>::col(size_t colNum, 
00109                                    const std::slice& s) const
00110    {
00111       return ConstMatrixColSlice<T>(*this, colNum, s);
00112    }
00113 
00114    template <class T>
00115    ConstMatrixColSlice<T> Matrix<T>::col(size_t colNum, 
00116                                    size_t rowNum) const
00117    {
00118       return ConstMatrixColSlice<T>(*this, colNum,
00119                                  std::slice(colNum * r + rowNum, r - rowNum, 1));
00120    }
00121 
00122    template <class T>
00123    Matrix<T>& Matrix<T>::resize(size_t rows, size_t cols)
00124    {
00125       v.resize(rows * cols);
00126       c = cols;
00127       r = rows;
00128       s = rows * cols;
00129       return *this;
00130    }
00131 
00132    template <class T>
00133    Matrix<T>& Matrix<T>::resize(size_t rows, size_t cols,
00134                           const T initialValue)
00135    {
00136       v.resize(rows * cols, initialValue);
00137       c = cols;
00138       r = rows;
00139       s = rows * cols;
00140       return *this;
00141    }
00142 
00144 
00145 }  // namespace
00146 
00147 #endif

Generated on Thu May 23 03:31:09 2013 for GPS ToolKit Software Library by  doxygen 1.3.9.1