MPQC  3.0.0-alpha
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 #include <util/state/state.h>
32 
33 namespace sc {
34 
35 class SCElementOp;
36 class SCElementOp2;
37 class SCElementOp3;
38 
41 class SCMatrixBlock: public SavableState {
42  public:
43  int blocki, blockj;
44  public:
45  SCMatrixBlock();
47  virtual ~SCMatrixBlock();
48  void save_data_state(StateOut&s);
49 
53  virtual SCMatrixBlock *deepcopy() const;
54 
59  virtual double *dat();
60  virtual int ndat() const;
61 
62  // These routines are obsolete.
63  virtual void process(SCElementOp*) = 0;
64  virtual void process(SCElementOp2*, SCMatrixBlock*) = 0;
65  virtual void process(SCElementOp3*, SCMatrixBlock*, SCMatrixBlock*) = 0;
66 };
67 
68 
70  private:
71  void operator = (const SCMatrixBlockListLink&) {} // disallowed
72  SCMatrixBlock* _block;
73  SCMatrixBlockListLink* _next;
74  public:
77  void block(SCMatrixBlock*);
78  void next(SCMatrixBlockListLink* link) { _next = link; }
79  SCMatrixBlock* block() { return _block; }
80  SCMatrixBlockListLink* next() { return _next; }
81 };
82 
84  private:
86  public:
87  SCMatrixBlockListIter(): link(0) {}
89  int operator !=(const SCMatrixBlockListIter p) const {
90  return link != p.link;
91  }
92  void operator ++() { link = link->next(); }
93  void operator ++(int) { link = link->next(); }
94  SCMatrixBlock* block() const { return link->block(); }
95 };
96 
98  private:
99  SCMatrixBlockListLink* _begin;
100  public:
104  void save_data_state(StateOut&);
105  void insert(SCMatrixBlock*);
106  void append(SCMatrixBlock*);
107  SCMatrixBlockListIter begin() { return _begin; }
108  SCMatrixBlockListIter end() { return 0; }
109  SCMatrixBlockList *deepcopy();
110 };
111 
112 
124  public:
125  SCVectorSimpleBlock(int istart,int iend);
127  virtual ~SCVectorSimpleBlock();
128  void save_data_state(StateOut&);
129  int istart;
130  int iend;
131  double* data;
132 
133  SCMatrixBlock *deepcopy() const;
134 
135  void process(SCElementOp*);
136  void process(SCElementOp2*, SCMatrixBlock*);
137  void process(SCElementOp3*, SCMatrixBlock*, SCMatrixBlock*);
138 
139  double *dat();
140  int ndat() const;
141 };
142 
143 
155  public:
156  SCVectorSimpleSubBlock(int istart,int iend, int offset, double* data);
158  virtual ~SCVectorSimpleSubBlock();
159  void save_data_state(StateOut&);
160  int istart;
161  int iend;
162  int offset;
163  double* data;
164 
165  void process(SCElementOp*);
166  void process(SCElementOp2*, SCMatrixBlock*);
167  void process(SCElementOp3*, SCMatrixBlock*, SCMatrixBlock*);
168 };
169 
170 
184  public:
185  SCMatrixRectBlock(int is, int ie, int js, int je);
187  virtual ~SCMatrixRectBlock();
188  void save_data_state(StateOut&);
189  int istart;
190  int jstart;
191  int iend;
192  int jend;
193  double* data;
194 
195  SCMatrixBlock *deepcopy() const;
196 
197  void process(SCElementOp*);
198  void process(SCElementOp2*, SCMatrixBlock*);
199  void process(SCElementOp3*, SCMatrixBlock*, SCMatrixBlock*);
200 
201  double *dat();
202  int ndat() const;
203 };
204 
205 
220  public:
221  SCMatrixRectSubBlock(int is, int ie, int istride, int js, int je,
222  double* data);
224  // does not delete the data member
225  virtual ~SCMatrixRectSubBlock();
226  // does not save the data member
227  void save_data_state(StateOut&);
228  int istart;
229  int jstart;
230  int iend;
231  int jend;
232  int istride;
233  double* data;
234 
235  void process(SCElementOp*);
236  void process(SCElementOp2*, SCMatrixBlock*);
237  void process(SCElementOp3*, SCMatrixBlock*, SCMatrixBlock*);
238 };
239 
240 
254  public:
255  SCMatrixLTriBlock(int s,int e);
257  virtual ~SCMatrixLTriBlock();
258  void save_data_state(StateOut&);
259  int start;
260  int end;
261  double* data;
262 
263  SCMatrixBlock *deepcopy() const;
264 
265  void process(SCElementOp*);
266  void process(SCElementOp2*, SCMatrixBlock*);
267  void process(SCElementOp3*, SCMatrixBlock*, SCMatrixBlock*);
268 
269  double *dat();
270  int ndat() const;
271 };
272 
273 
289  public:
290  SCMatrixLTriSubBlock(int is,int ie,int js,int je,double*data);
292  // does not delete the data member
293  virtual ~SCMatrixLTriSubBlock();
294  // does not save the data member
295  void save_data_state(StateOut&);
296  int istart;
297  int iend;
298  int jstart;
299  int jend;
300  double* data;
301 
302  void process(SCElementOp*);
303  void process(SCElementOp2*, SCMatrixBlock*);
304  void process(SCElementOp3*, SCMatrixBlock*, SCMatrixBlock*);
305 };
306 
307 
319  public:
320  SCMatrixDiagBlock(int istart,int iend,int jstart);
321  SCMatrixDiagBlock(int istart,int iend);
323  virtual ~SCMatrixDiagBlock();
324  void save_data_state(StateOut&);
325  int istart;
326  int jstart;
327  int iend;
328  double* data;
329 
330  SCMatrixBlock *deepcopy() const;
331 
332  void process(SCElementOp*);
333  void process(SCElementOp2*, SCMatrixBlock*);
334  void process(SCElementOp3*, SCMatrixBlock*, SCMatrixBlock*);
335 
336  double *dat();
337  int ndat() const;
338 };
339 
340 
352  public:
353  SCMatrixDiagSubBlock(int istart,int iend,int jstart, int offset,
354  double*data);
355  SCMatrixDiagSubBlock(int istart,int iend, int offset, double*data);
357  // does not delete the data member
358  virtual ~SCMatrixDiagSubBlock();
359  // does not save the data member
360  void save_data_state(StateOut&);
361  int istart;
362  int jstart;
363  int iend;
364  int offset;
365  double* data;
366 
367  void process(SCElementOp*);
368  void process(SCElementOp2*, SCMatrixBlock*);
369  void process(SCElementOp3*, SCMatrixBlock*, SCMatrixBlock*);
370 };
371 
372 
373 // //////////////////////////////////////////////////////////////////
374 // Classes that iterate through the blocks of a matrix.
375 
380  public:
381  enum Access { Read, Write, Accum, None };
382  protected:
383  Access access_;
384  public:
387  SCMatrixSubblockIter(Access access): access_(access) {}
390  virtual void begin() = 0;
392  virtual int ready() = 0;
394  virtual void next() = 0;
396  virtual SCMatrixBlock *block() = 0;
398  Access access() const { return access_; }
399 };
400 
401 
403  protected:
404  Ref<SCMatrixBlock> block_;
405  int ready_;
406  public:
408  void begin();
409  int ready();
410  void next();
411  SCMatrixBlock *block();
412 };
413 
415  protected:
417  SCMatrixBlockListIter iter_;
418  public:
420  void begin();
421  int ready();
422  void next();
423  SCMatrixBlock *block();
424 };
425 
427  public:
429  SCMatrixNullSubblockIter(Access);
430  void begin();
431  int ready();
432  void next();
433  SCMatrixBlock *block();
434 };
435 
437  protected:
438  int niters_;
440  int iiter_;
441  public:
442  SCMatrixCompositeSubblockIter(Access, int niter);
446  void set_iter(int i, const Ref<SCMatrixSubblockIter> &);
447  void begin();
448  int ready();
449  void next();
450  SCMatrixBlock *block();
451  int current_block() const { return iiter_; }
452 };
453 
454 
456  protected:
457  int niters_;
459  public:
462  const Ref<SCMatrixSubblockIter>& = 0,
463  const Ref<SCMatrixSubblockIter>& = 0,
464  const Ref<SCMatrixSubblockIter>& = 0);
466  void begin();
467  int ready();
468  void next();
469  SCMatrixBlock *block();
470  SCMatrixBlock *block(int i);
471 };
472 
473 }
474 
475 #endif
476 
477 // Local Variables:
478 // mode: c++
479 // c-file-style: "CLJ"
480 // 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:41
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:159
sc::SCMatrixSubblockIter::access
Access access() const
Return the type of Access allowed for these blocks.
Definition: block.h:398
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:253
sc::Ref
A template class that maintains references counts.
Definition: ref.h:361
sc::SCMatrixRectBlock
The SCMatrixRectBlock describes a rectangular piece of a matrix.
Definition: block.h:183
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:402
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:288
sc::SCMatrixNullSubblockIter
Definition: block.h:426
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:414
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:387
sc::SCMatrixBlockListIter
Definition: block.h:83
sc::SCElementOp
Objects of class SCElementOp are used to perform operations on the elements of matrices.
Definition: elemop.h:94
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
Definition: statein.h:79
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:154
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:123
sc::StateOut
Definition: stateout.h:71
sc::SCMatrixJointSubblockIter
Definition: block.h:455
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:318
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:97
sc::SavableState
Base class for objects that can save/restore state.
Definition: state.h:45
sc::SCMatrixRectSubBlock
The SCMatrixRectSubBlock describes a rectangular piece of a matrix.
Definition: block.h:219
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:181
sc::RefCount
The base class for all reference counted objects.
Definition: ref.h:192
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:436
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:379
sc
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14
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:351
sc::SCMatrixBlock::deepcopy
virtual SCMatrixBlock * deepcopy() const
Return of copy of this.

Generated at Sun Jan 26 2020 23:24:00 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.8.16.