| 1 | //
 | 
|---|
| 2 | // blkiter.h
 | 
|---|
| 3 | //
 | 
|---|
| 4 | // Copyright (C) 1996 Limit Point Systems, Inc.
 | 
|---|
| 5 | //
 | 
|---|
| 6 | // Author: Curtis Janssen <cljanss@limitpt.com>
 | 
|---|
| 7 | // Maintainer: LPS
 | 
|---|
| 8 | //
 | 
|---|
| 9 | // This file is part of the SC Toolkit.
 | 
|---|
| 10 | //
 | 
|---|
| 11 | // The SC Toolkit is free software; you can redistribute it and/or modify
 | 
|---|
| 12 | // it under the terms of the GNU Library General Public License as published by
 | 
|---|
| 13 | // the Free Software Foundation; either version 2, or (at your option)
 | 
|---|
| 14 | // any later version.
 | 
|---|
| 15 | //
 | 
|---|
| 16 | // The SC Toolkit is distributed in the hope that it will be useful,
 | 
|---|
| 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|---|
| 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|---|
| 19 | // GNU Library General Public License for more details.
 | 
|---|
| 20 | //
 | 
|---|
| 21 | // You should have received a copy of the GNU Library General Public License
 | 
|---|
| 22 | // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
 | 
|---|
| 23 | // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 | 
|---|
| 24 | //
 | 
|---|
| 25 | // The U.S. Government is granted a limited license as per AL 91-7.
 | 
|---|
| 26 | //
 | 
|---|
| 27 | 
 | 
|---|
| 28 | #ifndef _math_scmat_blkiter_h
 | 
|---|
| 29 | #define _math_scmat_blkiter_h
 | 
|---|
| 30 | 
 | 
|---|
| 31 | #ifdef __GNUC__
 | 
|---|
| 32 | #pragma interface
 | 
|---|
| 33 | #endif
 | 
|---|
| 34 | 
 | 
|---|
| 35 | #include <math/scmat/block.h>
 | 
|---|
| 36 | 
 | 
|---|
| 37 | namespace sc {
 | 
|---|
| 38 | 
 | 
|---|
| 39 | class SCMatrixRectBlock;
 | 
|---|
| 40 | class SCMatrixLTriBlock;
 | 
|---|
| 41 | class SCMatrixDiagBlock;
 | 
|---|
| 42 | class SCVectorSimpleBlock;
 | 
|---|
| 43 | 
 | 
|---|
| 44 | class SCElementOp;
 | 
|---|
| 45 | class SCElementOp2;
 | 
|---|
| 46 | class SCElementOp3;
 | 
|---|
| 47 | 
 | 
|---|
| 48 | /** The SCMatrixBlockIter class is used to described iterates that
 | 
|---|
| 49 |     loop through the elements in a block. */
 | 
|---|
| 50 | class SCMatrixBlockIter {
 | 
|---|
| 51 |   public:
 | 
|---|
| 52 |     SCMatrixBlockIter() {}
 | 
|---|
| 53 |     virtual ~SCMatrixBlockIter();
 | 
|---|
| 54 |     /// Returns the row index.
 | 
|---|
| 55 |     virtual int i() = 0;
 | 
|---|
| 56 |     /// Returns the column index.
 | 
|---|
| 57 |     virtual int j() = 0;
 | 
|---|
| 58 |     /// Set the current element to val.
 | 
|---|
| 59 |     virtual void set(double val) = 0;
 | 
|---|
| 60 |     /// Add val to the current element.
 | 
|---|
| 61 |     virtual void accum(double val);
 | 
|---|
| 62 |     /// Return the value of the current element.
 | 
|---|
| 63 |     virtual double get() = 0;
 | 
|---|
| 64 |     /// Return nonzero if there are more elements.
 | 
|---|
| 65 |     virtual operator int() = 0;
 | 
|---|
| 66 |     /// Move to the next element.
 | 
|---|
| 67 |     virtual void operator++() = 0; // prefix ++
 | 
|---|
| 68 |     void operator++(int) { operator++(); }
 | 
|---|
| 69 |     /// Start the iteration over.
 | 
|---|
| 70 |     virtual void reset() = 0;
 | 
|---|
| 71 | };
 | 
|---|
| 72 | 
 | 
|---|
| 73 | class SCMatrixRectBlockIter: public SCMatrixBlockIter {
 | 
|---|
| 74 |   private:
 | 
|---|
| 75 |     SCMatrixRectBlock* block;
 | 
|---|
| 76 |     int i_;
 | 
|---|
| 77 |     int block_index;
 | 
|---|
| 78 |     int j_;
 | 
|---|
| 79 |   public:
 | 
|---|
| 80 |     SCMatrixRectBlockIter(SCMatrixRectBlock*);
 | 
|---|
| 81 |     virtual ~SCMatrixRectBlockIter();
 | 
|---|
| 82 |     int i();
 | 
|---|
| 83 |     int j();
 | 
|---|
| 84 |     double get();
 | 
|---|
| 85 |     void set(double);
 | 
|---|
| 86 |     operator int();
 | 
|---|
| 87 |     void operator++();
 | 
|---|
| 88 |     void reset();
 | 
|---|
| 89 | };
 | 
|---|
| 90 | 
 | 
|---|
| 91 | class SCMatrixRectSubBlockIter: public SCMatrixBlockIter {
 | 
|---|
| 92 |   private:
 | 
|---|
| 93 |     SCMatrixRectSubBlock* block;
 | 
|---|
| 94 |     int i_;
 | 
|---|
| 95 |     int block_index;
 | 
|---|
| 96 |     int j_;
 | 
|---|
| 97 |   public:
 | 
|---|
| 98 |     SCMatrixRectSubBlockIter(SCMatrixRectSubBlock*);
 | 
|---|
| 99 |     virtual ~SCMatrixRectSubBlockIter();
 | 
|---|
| 100 |     int i();
 | 
|---|
| 101 |     int j();
 | 
|---|
| 102 |     double get();
 | 
|---|
| 103 |     void set(double);
 | 
|---|
| 104 |     operator int();
 | 
|---|
| 105 |     void operator++();
 | 
|---|
| 106 |     void reset();
 | 
|---|
| 107 | };
 | 
|---|
| 108 | 
 | 
|---|
| 109 | class SCMatrixLTriBlockIter: public SCMatrixBlockIter {
 | 
|---|
| 110 |   private:
 | 
|---|
| 111 |     SCMatrixLTriBlock* block;
 | 
|---|
| 112 |     int block_index;
 | 
|---|
| 113 |     int i_;
 | 
|---|
| 114 |     int j_;
 | 
|---|
| 115 |   public:
 | 
|---|
| 116 |     SCMatrixLTriBlockIter(SCMatrixLTriBlock*);
 | 
|---|
| 117 |     virtual ~SCMatrixLTriBlockIter();
 | 
|---|
| 118 |     int i();
 | 
|---|
| 119 |     int j();
 | 
|---|
| 120 |     double get();
 | 
|---|
| 121 |     void set(double);
 | 
|---|
| 122 |     operator int();
 | 
|---|
| 123 |     void operator++();
 | 
|---|
| 124 |     void reset();
 | 
|---|
| 125 | };
 | 
|---|
| 126 | 
 | 
|---|
| 127 | class SCMatrixLTriSubBlockIter: public SCMatrixBlockIter {
 | 
|---|
| 128 |   private:
 | 
|---|
| 129 |     SCMatrixLTriSubBlock* block;
 | 
|---|
| 130 |     int block_index;
 | 
|---|
| 131 |     int i_;
 | 
|---|
| 132 |     int j_;
 | 
|---|
| 133 |   public:
 | 
|---|
| 134 |     SCMatrixLTriSubBlockIter(SCMatrixLTriSubBlock*);
 | 
|---|
| 135 |     virtual ~SCMatrixLTriSubBlockIter();
 | 
|---|
| 136 |     int i();
 | 
|---|
| 137 |     int j();
 | 
|---|
| 138 |     double get();
 | 
|---|
| 139 |     void set(double);
 | 
|---|
| 140 |     operator int();
 | 
|---|
| 141 |     void operator++();
 | 
|---|
| 142 |     void reset();
 | 
|---|
| 143 | };
 | 
|---|
| 144 | 
 | 
|---|
| 145 | class SCMatrixDiagBlockIter: public SCMatrixBlockIter {
 | 
|---|
| 146 |   private:
 | 
|---|
| 147 |     SCMatrixDiagBlock* block;
 | 
|---|
| 148 |     int block_index;
 | 
|---|
| 149 |     int i_;
 | 
|---|
| 150 |   public:
 | 
|---|
| 151 |     SCMatrixDiagBlockIter(SCMatrixDiagBlock*);
 | 
|---|
| 152 |     virtual ~SCMatrixDiagBlockIter();
 | 
|---|
| 153 |     int i();
 | 
|---|
| 154 |     int j();
 | 
|---|
| 155 |     double get();
 | 
|---|
| 156 |     void set(double);
 | 
|---|
| 157 |     operator int();
 | 
|---|
| 158 |     void operator++();
 | 
|---|
| 159 |     void reset();
 | 
|---|
| 160 | };
 | 
|---|
| 161 | 
 | 
|---|
| 162 | class SCMatrixDiagSubBlockIter: public SCMatrixBlockIter {
 | 
|---|
| 163 |   private:
 | 
|---|
| 164 |     SCMatrixDiagSubBlock* block;
 | 
|---|
| 165 |     int block_index;
 | 
|---|
| 166 |     int i_;
 | 
|---|
| 167 |   public:
 | 
|---|
| 168 |     SCMatrixDiagSubBlockIter(SCMatrixDiagSubBlock*);
 | 
|---|
| 169 |     virtual ~SCMatrixDiagSubBlockIter();
 | 
|---|
| 170 |     int i();
 | 
|---|
| 171 |     int j();
 | 
|---|
| 172 |     double get();
 | 
|---|
| 173 |     void set(double);
 | 
|---|
| 174 |     operator int();
 | 
|---|
| 175 |     void operator++();
 | 
|---|
| 176 |     void reset();
 | 
|---|
| 177 | };
 | 
|---|
| 178 | 
 | 
|---|
| 179 | class SCVectorSimpleBlockIter: public SCMatrixBlockIter {
 | 
|---|
| 180 |   private:
 | 
|---|
| 181 |     SCVectorSimpleBlock* block;
 | 
|---|
| 182 |     int block_index;
 | 
|---|
| 183 |     int i_;
 | 
|---|
| 184 |   public:
 | 
|---|
| 185 |     SCVectorSimpleBlockIter(SCVectorSimpleBlock*);
 | 
|---|
| 186 |     virtual ~SCVectorSimpleBlockIter();
 | 
|---|
| 187 |     int i();
 | 
|---|
| 188 |     int j();
 | 
|---|
| 189 |     double get();
 | 
|---|
| 190 |     void set(double);
 | 
|---|
| 191 |     operator int();
 | 
|---|
| 192 |     void operator++();
 | 
|---|
| 193 |     void reset();
 | 
|---|
| 194 | };
 | 
|---|
| 195 | 
 | 
|---|
| 196 | class SCVectorSimpleSubBlockIter: public SCMatrixBlockIter {
 | 
|---|
| 197 |   private:
 | 
|---|
| 198 |     SCVectorSimpleSubBlock* block;
 | 
|---|
| 199 |     int block_index;
 | 
|---|
| 200 |     int i_;
 | 
|---|
| 201 |   public:
 | 
|---|
| 202 |     SCVectorSimpleSubBlockIter(SCVectorSimpleSubBlock*);
 | 
|---|
| 203 |     virtual ~SCVectorSimpleSubBlockIter();
 | 
|---|
| 204 |     int i();
 | 
|---|
| 205 |     int j();
 | 
|---|
| 206 |     double get();
 | 
|---|
| 207 |     void set(double);
 | 
|---|
| 208 |     operator int();
 | 
|---|
| 209 |     void operator++();
 | 
|---|
| 210 |     void reset();
 | 
|---|
| 211 | };
 | 
|---|
| 212 | 
 | 
|---|
| 213 | }
 | 
|---|
| 214 | 
 | 
|---|
| 215 | #endif
 | 
|---|
| 216 | 
 | 
|---|
| 217 | // Local Variables:
 | 
|---|
| 218 | // mode: c++
 | 
|---|
| 219 | // c-file-style: "CLJ"
 | 
|---|
| 220 | // End:
 | 
|---|