Blender V2.61 - r43446

tnt_sparse_matrix_csr.h

Go to the documentation of this file.
00001 
00004 /*
00005 *
00006 * Template Numerical Toolkit (TNT)
00007 *
00008 * Mathematical and Computational Sciences Division
00009 * National Institute of Technology,
00010 * Gaithersburg, MD USA
00011 *
00012 *
00013 * This software was developed at the National Institute of Standards and
00014 * Technology (NIST) by employees of the Federal Government in the course
00015 * of their official duties. Pursuant to title 17 Section 105 of the
00016 * United States Code, this software is not subject to copyright protection
00017 * and is in the public domain. NIST assumes no responsibility whatsoever for
00018 * its use by other parties, and makes no guarantees, expressed or implied,
00019 * about its quality, reliability, or any other characteristic.
00020 *
00021 */
00022 
00023 
00024 #ifndef TNT_SPARSE_MATRIX_CSR_H
00025 #define TNT_SPARSE_MATRIX_CSR_H
00026 
00027 #include "tnt_array1d.h"
00028 
00029 namespace TNT
00030 {
00031 
00032 
00050 template <class T>
00051 class Sparse_Matrix_CompRow {
00052 
00053 private:
00054     Array1D<T>    val_;       // data values (nz_ elements)
00055     Array1D<int>  rowptr_;    // row_ptr (dim_[0]+1 elements)
00056     Array1D<int>  colind_;    // col_ind  (nz_ elements)
00057 
00058     int dim1_;        // number of rows
00059     int dim2_;        // number of cols
00060   
00061 public:
00062 
00063     Sparse_Matrix_CompRow(const Sparse_Matrix_CompRow &S);
00064     Sparse_Matrix_CompRow(int M, int N, int nz, const T *val, 
00065                         const int *r, const int *c);
00066     
00067 
00068 
00069     inline   const T&      val(int i) const { return val_[i]; }
00070     inline   const int&         row_ptr(int i) const { return rowptr_[i]; }
00071     inline   const int&         col_ind(int i) const { return colind_[i];}
00072 
00073     inline   int    dim1() const {return dim1_;}
00074     inline   int    dim2() const {return dim2_;}
00075        int          NumNonzeros() const {return val_.dim1();}
00076 
00077 
00078     Sparse_Matrix_CompRow& operator=(
00079                     const Sparse_Matrix_CompRow &R);
00080 
00081 
00082 
00083 };
00084 
00097 template <class T>
00098 Sparse_Matrix_CompRow<T>::Sparse_Matrix_CompRow(int M, int N, int nz,
00099     const T *val, const int *r, const int *c) : val_(nz,val), 
00100         rowptr_(M, r), colind_(nz, c), dim1_(M), dim2_(N) {}
00101 
00102 
00103 }
00104 // namespace TNT
00105 
00106 #endif