00001 /* 00002 File: SubSVec.h 00003 00004 Function: Defines a scatter-gather sparse vector, i.e., a subvector 00005 of another vector or the row, column or diagonal of a 00006 sparse matrix. 00007 00008 Author(s): Andrew Willmott 00009 00010 Copyright: (c) 1995-2000, Andrew Willmott 00011 */ 00012 00013 #ifndef __SubSVec__ 00014 #define __SubSVec__ 00015 00016 #include "vl/Vec.h" 00017 00018 00019 class TSparseVec; 00020 00021 class TSubSVec 00022 { 00023 public: 00024 TSubSVec(Int start, Int length, TSparseVec *target, 00025 Int span = 1); 00026 TSubSVec(const TSubSVec &v); 00027 00028 inline Int Elts() const { return(elts); }; 00029 00030 TSubSVec &operator = (const TSubSVec &v); 00031 TSubSVec &operator = (const TSparseVec &v); 00032 Void Store(TSparseVec &sv) const; 00033 00034 protected: 00035 00036 Int elts; // # of elements 00037 Int start; // start element in the target vector 00038 Int colSpan; // columns between elements 00039 Int rowSpan; // rows between elements 00040 TSparseVec *target; // the sparse vector this is a subvector of 00041 }; 00042 00043 // --- Sub-vector operator ---------------------------------------------------- 00044 00045 TSubSVec sub(const TSparseVec &v, Int start, Int length); 00046 00047 #endif