MPQC  2.3.1
block.h
1 //
2 // block.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_block_h
29 #define _math_scmat_block_h
30 
31 #ifdef __GNUC__
32 #pragma interface
33 #endif
34 
35 #include <util/state/state.h>
36 
37 namespace sc {
38 
39 class SCElementOp;
40 class SCElementOp2;
41 class SCElementOp3;
42 
45 class SCMatrixBlock: public SavableState {
46  public:
47  int blocki, blockj;
48  public:
49  SCMatrixBlock();
51  virtual ~SCMatrixBlock();
52  void save_data_state(StateOut&s);
53 
57  virtual SCMatrixBlock *deepcopy() const;
58 
63  virtual double *dat();
64  virtual int ndat() const;
65 
66  // These routines are obsolete.
67  virtual void process(SCElementOp*) = 0;
68  virtual void process(SCElementOp2*, SCMatrixBlock*) = 0;
69  virtual void process(SCElementOp3*, SCMatrixBlock*, SCMatrixBlock*) = 0;
70 };
71 
72 
74  private:
75  void operator = (const SCMatrixBlockListLink&) {} // disallowed
76  SCMatrixBlock* _block;
77  SCMatrixBlockListLink* _next;
78  public:
81  void block(SCMatrixBlock*);
82  void next(SCMatrixBlockListLink* link) { _next = link; }
83  SCMatrixBlock* block() { return _block; }
84  SCMatrixBlockListLink* next() { return _next; }
85 };
86 
88  private:
90  public:
91  SCMatrixBlockListIter(): link(0) {}
93  int operator !=(const SCMatrixBlockListIter p) const {
94  return link != p.link;
95  }
96  void operator ++() { link = link->next(); }
97  void operator ++(int) { link = link->next(); }
98  SCMatrixBlock* block() const { return link->block(); }
99 };
100 
102  private:
103  SCMatrixBlockListLink* _begin;
104  public:
108  void save_data_state(StateOut&);
109  void insert(SCMatrixBlock*);
110  void append(SCMatrixBlock*);
111  SCMatrixBlockListIter begin() { return _begin; }
112  SCMatrixBlockListIter end() { return 0; }
113  SCMatrixBlockList *deepcopy();
114 };
115 
116 
128  public:
129  SCVectorSimpleBlock(int istart,int iend);
131  virtual ~SCVectorSimpleBlock();
132  void save_data_state(StateOut&);
133  int istart;
134  int iend;
135  double* data;
136 
137  SCMatrixBlock *deepcopy() const;
138 
139  void process(SCElementOp*);
140  void process(SCElementOp2*, SCMatrixBlock*);
141  void process(SCElementOp3*, SCMatrixBlock*, SCMatrixBlock*);
142 
143  double *dat();
144  int ndat() const;
145 };
146 
147 
159  public:
160  SCVectorSimpleSubBlock(int istart,int iend, int offset, double* data);
162  virtual ~SCVectorSimpleSubBlock();
163  void save_data_state(StateOut&);
164  int istart;
165  int iend;
166  int offset;
167  double* data;
168 
169  void process(SCElementOp*);
170  void process(SCElementOp2*, SCMatrixBlock*);
171  void process(SCElementOp3*, SCMatrixBlock*, SCMatrixBlock*);
172 };
173 
174 
188  public:
189  SCMatrixRectBlock(int is, int ie, int js, int je);
191  virtual ~SCMatrixRectBlock();
192  void save_data_state(StateOut&);
193  int istart;
194  int jstart;
195  int iend;
196  int jend;
197  double* data;
198 
199  SCMatrixBlock *deepcopy() const;
200 
201  void process(SCElementOp*);
202  void process(SCElementOp2*, SCMatrixBlock*);
203  void process(SCElementOp3*, SCMatrixBlock*, SCMatrixBlock*);
204 
205  double *dat();
206  int ndat() const;
207 };
208 
209 
224  public:
225  SCMatrixRectSubBlock(int is, int ie, int istride, int js, int je,
226  double* data);
228  // does not delete the data member
229  virtual ~SCMatrixRectSubBlock();
230  // does not save the data member
231  void save_data_state(StateOut&);
232  int istart;
233  int jstart;
234  int iend;
235  int jend;
236  int istride;
237  double* data;
238 
239  void process(SCElementOp*);
240  void process(SCElementOp2*, SCMatrixBlock*);
241  void process(SCElementOp3*, SCMatrixBlock*, SCMatrixBlock*);
242 };
243 
244 
258  public:
259  SCMatrixLTriBlock(int s,int e);
261  virtual ~SCMatrixLTriBlock();
262  void save_data_state(StateOut&);
263  int start;
264  int end;
265  double* data;
266 
267  SCMatrixBlock *deepcopy() const;
268 
269  void process(SCElementOp*);
270  void process(SCElementOp2*, SCMatrixBlock*);
271  void process(SCElementOp3*, SCMatrixBlock*, SCMatrixBlock*);
272 
273  double *dat();
274  int ndat() const;
275 };
276 
277 
293  public:
294  SCMatrixLTriSubBlock(int is,int ie,int js,int je,double*data);
296  // does not delete the data member
297  virtual ~SCMatrixLTriSubBlock();
298  // does not save the data member
299  void save_data_state(StateOut&);
300  int istart;
301  int iend;
302  int jstart;
303  int jend;
304  double* data;
305 
306  void process(SCElementOp*);
307  void process(SCElementOp2*, SCMatrixBlock*);
308  void process(SCElementOp3*, SCMatrixBlock*, SCMatrixBlock*);
309 };
310 
311 
323  public:
324  SCMatrixDiagBlock(int istart,int iend,int jstart);
325  SCMatrixDiagBlock(int istart,int iend);
327  virtual ~SCMatrixDiagBlock();
328  void save_data_state(StateOut&);
329  int istart;
330  int jstart;
331  int iend;
332  double* data;
333 
334  SCMatrixBlock *deepcopy() const;
335 
336  void process(SCElementOp*);
337  void process(SCElementOp2*, SCMatrixBlock*);
338  void process(SCElementOp3*, SCMatrixBlock*, SCMatrixBlock*);
339 
340  double *dat();
341  int ndat() const;
342 };
343 
344 
356  public:
357  SCMatrixDiagSubBlock(int istart,int iend,int jstart, int offset,
358  double*data);
359  SCMatrixDiagSubBlock(int istart,int iend, int offset, double*data);
361  // does not delete the data member
362  virtual ~SCMatrixDiagSubBlock();
363  // does not save the data member
364  void save_data_state(StateOut&);
365  int istart;
366  int jstart;
367  int iend;
368  int offset;
369  double* data;
370 
371  void process(SCElementOp*);
372  void process(SCElementOp2*, SCMatrixBlock*);
373  void process(SCElementOp3*, SCMatrixBlock*, SCMatrixBlock*);
374 };
375 
376 
377 // //////////////////////////////////////////////////////////////////
378 // Classes that iterate through the blocks of a matrix.
379 
384  public:
385  enum Access { Read, Write, Accum, None };
386  protected:
387  Access access_;
388  public:
391  SCMatrixSubblockIter(Access access): access_(access) {}
394  virtual void begin() = 0;
396  virtual int ready() = 0;
398  virtual void next() = 0;
400  virtual SCMatrixBlock *block() = 0;
402  Access access() const { return access_; }
403 };
404 
405 
407  protected:
408  Ref<SCMatrixBlock> block_;
409  int ready_;
410  public:
412  void begin();
413  int ready();
414  void next();
415  SCMatrixBlock *block();
416 };
417 
419  protected:
421  SCMatrixBlockListIter iter_;
422  public:
424  void begin();
425  int ready();
426  void next();
427  SCMatrixBlock *block();
428 };
429 
431  public:
433  SCMatrixNullSubblockIter(Access);
434  void begin();
435  int ready();
436  void next();
437  SCMatrixBlock *block();
438 };
439 
441  protected:
442  int niters_;
444  int iiter_;
445  public:
446  SCMatrixCompositeSubblockIter(Access, int niter);
450  void set_iter(int i, const Ref<SCMatrixSubblockIter> &);
451  void begin();
452  int ready();
453  void next();
454  SCMatrixBlock *block();
455  int current_block() const { return iiter_; }
456 };
457 
458 
460  protected:
461  int niters_;
463  public:
466  const Ref<SCMatrixSubblockIter>& = 0,
467  const Ref<SCMatrixSubblockIter>& = 0,
468  const Ref<SCMatrixSubblockIter>& = 0);
470  void begin();
471  int ready();
472  void next();
473  SCMatrixBlock *block();
474  SCMatrixBlock *block(int i);
475 };
476 
477 }
478 
479 #endif
480 
481 // Local Variables:
482 // mode: c++
483 // c-file-style: "CLJ"
484 // End:
sc::SCMatrixNullSubblockIter::ready
int ready()
Returns nonzero if there is another block.
sc::SCMatrixNullSubblockIter::next
void next()
Proceed to the next block.
sc::SCMatrixRectSubBlock::save_data_state
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
sc::SCMatrixBlock
SCMatrixBlock is the base clase for all types of blocks that comprise matrices and vectors.
Definition: block.h:45
sc::SCMatrixListSubblockIter::begin
void begin()
Start at the beginning.
sc::SCElementOp2
The SCElementOp2 class is very similar to the SCElementOp class except that pairs of blocks are treat...
Definition: elemop.h:125
sc::SCMatrixSubblockIter::access
Access access() const
Return the type of Access allowed for these blocks.
Definition: block.h:402
sc::SCVectorSimpleBlock::dat
double * dat()
Return a pointer to the block's data and the number of elements in the block.
sc::SCMatrixRectBlock::dat
double * dat()
Return a pointer to the block's data and the number of elements in the block.
sc::SCMatrixLTriBlock
The SCMatrixLTriBlock describes a triangular piece of a matrix.
Definition: block.h:257
sc::Ref
A template class that maintains references counts.
Definition: ref.h:332
sc::SCMatrixRectBlock
The SCMatrixRectBlock describes a rectangular piece of a matrix.
Definition: block.h:187
sc::SCMatrixLTriBlock::save_data_state
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
sc::SCMatrixSimpleSubblockIter
Definition: block.h:406
sc::SCMatrixJointSubblockIter::begin
void begin()
Start at the beginning.
sc::SCMatrixSubblockIter::next
virtual void next()=0
Proceed to the next block.
sc::SCMatrixLTriSubBlock
The SCMatrixLTriSubBlock describes a triangular subblock of a matrix.
Definition: block.h:292
sc::SCMatrixNullSubblockIter
Definition: block.h:430
sc::SCMatrixJointSubblockIter::next
void next()
Proceed to the next block.
sc::SCMatrixRectBlock::save_data_state
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
sc::SCMatrixDiagBlock::deepcopy
SCMatrixBlock * deepcopy() const
Return of copy of this.
sc::SCMatrixJointSubblockIter::block
SCMatrixBlock * block()
Return the current block.
sc::SCMatrixListSubblockIter::ready
int ready()
Returns nonzero if there is another block.
sc::SCMatrixLTriSubBlock::save_data_state
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
sc::SCMatrixListSubblockIter
Definition: block.h:418
sc::SCMatrixSimpleSubblockIter::ready
int ready()
Returns nonzero if there is another block.
sc::SCMatrixSubblockIter::SCMatrixSubblockIter
SCMatrixSubblockIter(Access access)
The access variable should be one of Read, Write, Accum, and None, with the SCMatrixSubblockIter:: sc...
Definition: block.h:391
sc::SCMatrixBlockListIter
Definition: block.h:87
sc::SCElementOp
Objects of class SCElementOp are used to perform operations on the elements of matrices.
Definition: elemop.h:60
sc::SCVectorSimpleBlock::save_data_state
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
sc::StateIn
Restores objects that derive from SavableState.
Definition: statein.h:70
sc::SCMatrixLTriBlock::deepcopy
SCMatrixBlock * deepcopy() const
Return of copy of this.
sc::SCMatrixListSubblockIter::block
SCMatrixBlock * block()
Return the current block.
sc::SCVectorSimpleSubBlock
The SCVectorSimpleSubBlock describes a subblock of a vector.
Definition: block.h:158
sc::SCMatrixCompositeSubblockIter::block
SCMatrixBlock * block()
Return the current block.
sc::SCMatrixSubblockIter::begin
virtual void begin()=0
Start at the beginning.
sc::SCMatrixCompositeSubblockIter::begin
void begin()
Start at the beginning.
sc::SCMatrixNullSubblockIter::begin
void begin()
Start at the beginning.
sc::SCMatrixRectBlock::deepcopy
SCMatrixBlock * deepcopy() const
Return of copy of this.
sc::SCMatrixDiagBlock::dat
double * dat()
Return a pointer to the block's data and the number of elements in the block.
sc::SCMatrixSimpleSubblockIter::begin
void begin()
Start at the beginning.
sc::SCMatrixJointSubblockIter::ready
int ready()
Returns nonzero if there is another block.
sc::SCVectorSimpleBlock
The SCVectorSimpleBlock describes a piece of a vector.
Definition: block.h:127
sc::StateOut
Serializes objects that derive from SavableState.
Definition: stateout.h:61
sc::SCMatrixJointSubblockIter
Definition: block.h:459
sc::SCMatrixDiagSubBlock::save_data_state
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
sc::SCMatrixCompositeSubblockIter::next
void next()
Proceed to the next block.
sc::SCMatrixDiagBlock
The SCMatrixDiagBlock describes a diagonal piece of a matrix.
Definition: block.h:322
sc::SCMatrixSubblockIter::block
virtual SCMatrixBlock * block()=0
Return the current block.
sc::SCMatrixSubblockIter::ready
virtual int ready()=0
Returns nonzero if there is another block.
sc::SCMatrixNullSubblockIter::block
SCMatrixBlock * block()
Return the current block.
sc::SCMatrixCompositeSubblockIter::ready
int ready()
Returns nonzero if there is another block.
sc::SCMatrixBlock::dat
virtual double * dat()
Return a pointer to the block's data and the number of elements in the block.
sc::SCVectorSimpleSubBlock::save_data_state
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
sc::SCMatrixBlock::save_data_state
void save_data_state(StateOut &s)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
sc::SCMatrixSimpleSubblockIter::block
SCMatrixBlock * block()
Return the current block.
sc::SCMatrixBlockList
Definition: block.h:101
sc::SavableState
Base class for objects that can save/restore state.
Definition: state.h:46
sc::SCMatrixRectSubBlock
The SCMatrixRectSubBlock describes a rectangular piece of a matrix.
Definition: block.h:223
sc::SCVectorSimpleBlock::deepcopy
SCMatrixBlock * deepcopy() const
Return of copy of this.
sc::SCElementOp3
The SCElementOp3 class is very similar to the SCElementOp class except that a triplet of blocks is tr...
Definition: elemop.h:147
sc::RefCount
The base class for all reference counted objects.
Definition: ref.h:194
sc::SCMatrixDiagBlock::save_data_state
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
sc::SCMatrixListSubblockIter::next
void next()
Proceed to the next block.
sc::SCMatrixCompositeSubblockIter
Definition: block.h:440
sc::SCMatrixSimpleSubblockIter::next
void next()
Proceed to the next block.
sc::SCMatrixSubblockIter
Objects of class SCMatrixSubblockIter are used to iterate through the blocks of a matrix.
Definition: block.h:383
sc::SCMatrixLTriBlock::dat
double * dat()
Return a pointer to the block's data and the number of elements in the block.
sc::SCMatrixBlockList::save_data_state
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
sc::SCMatrixDiagSubBlock
The SCMatrixDiagSubBlock describes a diagonal subblock of a matrix.
Definition: block.h:355
sc::SCMatrixBlock::deepcopy
virtual SCMatrixBlock * deepcopy() const
Return of copy of this.

Generated at Sun Jan 26 2020 23:33:03 for MPQC 2.3.1 using the documentation package Doxygen 1.8.16.