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
37namespace sc {
38
39class SCElementOp;
40class SCElementOp2;
41class SCElementOp3;
42
46 public:
47 int blocki, blockj;
48 public:
51 virtual ~SCMatrixBlock();
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;
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:
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();
133 int istart;
134 int iend;
135 double* data;
136
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();
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();
193 int istart;
194 int jstart;
195 int iend;
196 int jend;
197 double* data;
198
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
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();
263 int start;
264 int end;
265 double* data;
266
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
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();
329 int istart;
330 int jstart;
331 int iend;
332 double* data;
333
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
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();
416};
417
419 protected:
422 public:
424 void begin();
425 int ready();
426 void next();
428};
429
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();
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();
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:
The base class for all reference counted objects.
Definition ref.h:194
A template class that maintains references counts.
Definition ref.h:332
The SCElementOp2 class is very similar to the SCElementOp class except that pairs of blocks are treat...
Definition elemop.h:125
The SCElementOp3 class is very similar to the SCElementOp class except that a triplet of blocks is tr...
Definition elemop.h:147
Objects of class SCElementOp are used to perform operations on the elements of matrices.
Definition elemop.h:60
Definition block.h:87
Definition block.h:101
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
SCMatrixBlock is the base clase for all types of blocks that comprise matrices and vectors.
Definition block.h:45
virtual double * dat()
Return a pointer to the block's data and the number of elements in the block.
virtual SCMatrixBlock * deepcopy() const
Return of copy of this.
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 ...
Definition block.h:440
int ready()
Returns nonzero if there is another block.
void next()
Proceed to the next block.
SCMatrixBlock * block()
Return the current block.
void begin()
Start at the beginning.
The SCMatrixDiagBlock describes a diagonal piece of a matrix.
Definition block.h:322
double * dat()
Return a pointer to the block's data and the number of elements in the block.
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
SCMatrixBlock * deepcopy() const
Return of copy of this.
The SCMatrixDiagSubBlock describes a diagonal subblock of a matrix.
Definition block.h:355
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
Definition block.h:459
void begin()
Start at the beginning.
void next()
Proceed to the next block.
int ready()
Returns nonzero if there is another block.
SCMatrixBlock * block()
Return the current block.
The SCMatrixLTriBlock describes a triangular piece of a matrix.
Definition block.h:257
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
double * dat()
Return a pointer to the block's data and the number of elements in the block.
SCMatrixBlock * deepcopy() const
Return of copy of this.
The SCMatrixLTriSubBlock describes a triangular subblock of a matrix.
Definition block.h:292
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
Definition block.h:418
int ready()
Returns nonzero if there is another block.
void begin()
Start at the beginning.
void next()
Proceed to the next block.
SCMatrixBlock * block()
Return the current block.
Definition block.h:430
int ready()
Returns nonzero if there is another block.
SCMatrixBlock * block()
Return the current block.
void begin()
Start at the beginning.
void next()
Proceed to the next block.
The SCMatrixRectBlock describes a rectangular piece of a matrix.
Definition block.h:187
double * dat()
Return a pointer to the block's data and the number of elements in the block.
SCMatrixBlock * deepcopy() const
Return of copy of this.
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
The SCMatrixRectSubBlock describes a rectangular piece of a matrix.
Definition block.h:223
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
Definition block.h:406
int ready()
Returns nonzero if there is another block.
void begin()
Start at the beginning.
SCMatrixBlock * block()
Return the current block.
void next()
Proceed to the next block.
Objects of class SCMatrixSubblockIter are used to iterate through the blocks of a matrix.
Definition block.h:383
Access access() const
Return the type of Access allowed for these blocks.
Definition block.h:402
virtual void next()=0
Proceed to the next block.
virtual SCMatrixBlock * block()=0
Return the current block.
virtual int ready()=0
Returns nonzero if there is another block.
virtual void begin()=0
Start at the beginning.
SCMatrixSubblockIter(Access access)
The access variable should be one of Read, Write, Accum, and None, with the SCMatrixSubblockIter:: sc...
Definition block.h:391
The SCVectorSimpleBlock describes a piece of a vector.
Definition block.h:127
SCMatrixBlock * deepcopy() const
Return of copy of this.
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
double * dat()
Return a pointer to the block's data and the number of elements in the block.
The SCVectorSimpleSubBlock describes a subblock of a vector.
Definition block.h:158
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
Base class for objects that can save/restore state.
Definition state.h:46
Restores objects that derive from SavableState.
Definition statein.h:70
Serializes objects that derive from SavableState.
Definition stateout.h:61

Generated at Fri May 31 2024 00:00:00 for MPQC 2.3.1 using the documentation package Doxygen 1.11.0.