MPQC 2.3.1
elemop.h
1//
2// elemop.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_elemop_h
29#define _math_scmat_elemop_h
30
31#ifdef __GNUC__
32#pragma interface
33#endif
34
35#include <util/state/state.h>
36#include <util/group/message.h>
37
38namespace sc {
39
40class SCMatrixBlock;
41class SCMatrixBlockIter;
42class SCMatrixRectBlock;
43class SCMatrixLTriBlock;
44class SCMatrixDiagBlock;
45class SCVectorSimpleBlock;
46class SCMatrixRectSubBlock;
47class SCMatrixLTriSubBlock;
48class SCMatrixDiagSubBlock;
49class SCVectorSimpleSubBlock;
50
51class SCMatrix;
52class SymmSCMatrix;
53class DiagSCMatrix;
54class SCVector;
55
61 public:
64 virtual ~SCElementOp();
72 virtual int has_collect();
73 virtual void defer_collect(int);
74 virtual void collect(const Ref<MessageGrp>&);
78 virtual void collect(const Ref<SCElementOp>&);
82 virtual int has_side_effects();
83
86 virtual bool threadsafe();
87
90 virtual bool cloneable();
91
96
99 virtual void process(SCMatrixBlockIter&) = 0;
100
106
112 virtual void process_spec_ltri(SCMatrixLTriBlock*);
113 virtual void process_spec_diag(SCMatrixDiagBlock*);
114 virtual void process_spec_vsimp(SCVectorSimpleBlock*);
115 virtual void process_spec_rectsub(SCMatrixRectSubBlock*);
116 virtual void process_spec_ltrisub(SCMatrixLTriSubBlock*);
117 virtual void process_spec_diagsub(SCMatrixDiagSubBlock*);
118 virtual void process_spec_vsimpsub(SCVectorSimpleSubBlock*);
119};
120
126 public:
127 SCElementOp2();
129 virtual ~SCElementOp2();
130 virtual int has_collect();
131 virtual void defer_collect(int);
132 virtual int has_side_effects();
133 virtual int has_side_effects_in_arg();
134 virtual void collect(const Ref<MessageGrp>&);
135 virtual void process(SCMatrixBlockIter&,SCMatrixBlockIter&) = 0;
136 void process_base(SCMatrixBlock*,SCMatrixBlock*);
137 virtual void process_spec_rect(SCMatrixRectBlock*,SCMatrixRectBlock*);
138 virtual void process_spec_ltri(SCMatrixLTriBlock*,SCMatrixLTriBlock*);
139 virtual void process_spec_diag(SCMatrixDiagBlock*,SCMatrixDiagBlock*);
140 virtual void process_spec_vsimp(SCVectorSimpleBlock*,SCVectorSimpleBlock*);
141};
142
148 public:
149 SCElementOp3();
151 virtual ~SCElementOp3();
152 virtual int has_collect();
153 virtual void defer_collect(int);
154 virtual int has_side_effects();
155 virtual int has_side_effects_in_arg1();
156 virtual int has_side_effects_in_arg2();
157 virtual void collect(const Ref<MessageGrp>&);
158 virtual void process(SCMatrixBlockIter&,
160 SCMatrixBlockIter&) = 0;
161 void process_base(SCMatrixBlock*,SCMatrixBlock*,SCMatrixBlock*);
162 virtual void process_spec_rect(SCMatrixRectBlock*,
165 virtual void process_spec_ltri(SCMatrixLTriBlock*,
168 virtual void process_spec_diag(SCMatrixDiagBlock*,
171 virtual void process_spec_vsimp(SCVectorSimpleBlock*,
174};
175
177 private:
178 int deferred_;
179 double product;
180 public:
185 void process(SCMatrixBlockIter&,SCMatrixBlockIter&);
186 int has_collect();
187 void defer_collect(int);
188 void collect(const Ref<MessageGrp>&);
189 double result();
190 void init() { product = 0.0; }
191};
192
193
203
205 private:
206 double scale;
207 public:
208 SCElementScale(double a);
214};
215
217 private:
218 double assign;
219 public:
226};
227
229 private:
230 double assign;
231 public:
232 SCElementAssign(double a);
238};
239
250
252 private:
253 double threshold_;
254 int nbelowthreshold_;
255 int deferred_;
256 public:
257 SCElementInvert(double threshold = 0.0);
264 void defer_collect(int);
265 void collect(const Ref<MessageGrp>&);
267 int result() { return nbelowthreshold_; }
268};
269
270
272 private:
273 double scale_diagonal;
274 public:
275 SCElementScaleDiagonal(double a);
281};
282
284 private:
285 double shift_diagonal;
286 public:
287 SCElementShiftDiagonal(double a);
293};
294
296 private:
297 int deferred_;
298 double r;
299 public:
306 void defer_collect(int);
307 void collect(const Ref<MessageGrp>&);
309 double result();
310};
311
312
314 private:
315 int deferred_;
316 double r;
317 public:
318 // rinit must be greater than the magnitude of the smallest element
319 SCElementMinAbs(double rinit);
325 void defer_collect(int);
326 void collect(const Ref<MessageGrp>&);
328 double result();
329};
330
331
333 private:
334 int deferred_;
335 double r;
336 public:
343 void defer_collect(int);
344 void collect(const Ref<MessageGrp>&);
346 double result();
347 void init() { r = 0.0; }
348};
349
352 private:
353 int deferred_;
354 double r_; // result
355 double k_; // norm parameter
356 public:
358 SCElementKNorm(double k = 2.0);
364 void defer_collect(int);
365 void collect(const Ref<MessageGrp>&);
367 double result();
368 void init() { r_ = 0.0; }
369};
370
372 private:
373 double** avects;
374 double** bvects;
375 int length;
376 public:
379 SCElementDot(double**a, double**b, int length);
382};
383
392
401
410
419
420}
421
422#endif
423
424// Local Variables:
425// mode: c++
426// c-file-style: "CLJ"
427// End:
The SymmSCMatrix class is the abstract base class for diagonal double valued matrices.
Definition abstract.h:503
A template class that maintains references counts.
Definition ref.h:332
Definition elemop.h:194
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
int has_side_effects()
By default this returns nonzero.
void process(SCMatrixBlockIter &)
This is the fallback routine to process blocks and is called by process_spec members that are not ove...
Definition elemop.h:384
int has_side_effects()
By default this returns nonzero.
void process(SCMatrixBlockIter &)
This is the fallback routine to process blocks and is called by process_spec members that are not ove...
Definition elemop.h:411
void process(SCMatrixBlockIter &)
This is the fallback routine to process blocks and is called by process_spec members that are not ove...
int has_side_effects()
By default this returns nonzero.
void process(SCMatrixBlockIter &)
This is the fallback routine to process blocks and is called by process_spec members that are not ove...
int has_side_effects()
By default this returns nonzero.
Definition elemop.h:228
int has_side_effects()
By default this returns nonzero.
void process(SCMatrixBlockIter &)
This is the fallback routine to process blocks and is called by process_spec members that are not ove...
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 elemop.h:371
void process(SCMatrixBlockIter &)
This is the fallback routine to process blocks and is called by process_spec members that are not ove...
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
int has_side_effects()
By default this returns nonzero.
Definition elemop.h:251
void collect(const Ref< SCElementOp > &)
Multithreaded use of cloneable SCElementOp objects requires that data from cloned objects be collecte...
int has_collect()
If duplicates of the SCElementOp exist (that is, there is more than one node), then if has_collect re...
void process(SCMatrixBlockIter &)
This is the fallback routine to process blocks and is called by process_spec members that are not ove...
int has_side_effects()
By default this returns nonzero.
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
Computed k-norm of matrix.
Definition elemop.h:351
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
SCElementKNorm(double k=2.0)
by default compute 2-norm
int has_collect()
If duplicates of the SCElementOp exist (that is, there is more than one node), then if has_collect re...
void process(SCMatrixBlockIter &)
This is the fallback routine to process blocks and is called by process_spec members that are not ove...
void collect(const Ref< SCElementOp > &)
Multithreaded use of cloneable SCElementOp objects requires that data from cloned objects be collecte...
Definition elemop.h:295
void process(SCMatrixBlockIter &)
This is the fallback routine to process blocks and is called by process_spec members that are not ove...
void collect(const Ref< SCElementOp > &)
Multithreaded use of cloneable SCElementOp objects requires that data from cloned objects be collecte...
int has_collect()
If duplicates of the SCElementOp exist (that is, there is more than one node), then if has_collect re...
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 elemop.h:313
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
int has_collect()
If duplicates of the SCElementOp exist (that is, there is more than one node), then if has_collect re...
void collect(const Ref< SCElementOp > &)
Multithreaded use of cloneable SCElementOp objects requires that data from cloned objects be collecte...
void process(SCMatrixBlockIter &)
This is the fallback routine to process blocks and is called by process_spec members that are not ove...
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
virtual Ref< SCElementOp > clone()
Returns a clone of this object.
virtual int has_collect()
If duplicates of the SCElementOp exist (that is, there is more than one node), then if has_collect re...
virtual void process_spec_rect(SCMatrixRectBlock *)
Matrices should call these members when the type of block is known.
virtual void collect(const Ref< SCElementOp > &)
Multithreaded use of cloneable SCElementOp objects requires that data from cloned objects be collecte...
virtual bool cloneable()
Returns true if this SCElementOp supports the cloneable member.
void process_base(SCMatrixBlock *block)
Lazy matrix implementors can call this member when the type of block specialization is unknown.
virtual int has_side_effects()
By default this returns nonzero.
virtual bool threadsafe()
Returns true if this SCElementOp is threadsafe.
virtual void process(SCMatrixBlockIter &)=0
This is the fallback routine to process blocks and is called by process_spec members that are not ove...
Definition elemop.h:216
void process(SCMatrixBlockIter &)
This is the fallback routine to process blocks and is called by process_spec members that are not ove...
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
int has_side_effects()
By default this returns nonzero.
Definition elemop.h:176
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 elemop.h:271
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
void process(SCMatrixBlockIter &)
This is the fallback routine to process blocks and is called by process_spec members that are not ove...
int has_side_effects()
By default this returns nonzero.
Definition elemop.h:204
int has_side_effects()
By default this returns nonzero.
void process(SCMatrixBlockIter &)
This is the fallback routine to process blocks and is called by process_spec members that are not ove...
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 elemop.h:283
int has_side_effects()
By default this returns nonzero.
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
void process(SCMatrixBlockIter &)
This is the fallback routine to process blocks and is called by process_spec members that are not ove...
Definition elemop.h:240
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
int has_side_effects()
By default this returns nonzero.
void process(SCMatrixBlockIter &)
This is the fallback routine to process blocks and is called by process_spec members that are not ove...
Definition elemop.h:332
int has_collect()
If duplicates of the SCElementOp exist (that is, there is more than one node), then if has_collect re...
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
void process(SCMatrixBlockIter &)
This is the fallback routine to process blocks and is called by process_spec members that are not ove...
void collect(const Ref< SCElementOp > &)
Multithreaded use of cloneable SCElementOp objects requires that data from cloned objects be collecte...
The SCMatrixBlockIter class is used to described iterates that loop through the elements in a block.
Definition blkiter.h:50
SCMatrixBlock is the base clase for all types of blocks that comprise matrices and vectors.
Definition block.h:45
The SCMatrixDiagBlock describes a diagonal piece of a matrix.
Definition block.h:322
The SCMatrixDiagSubBlock describes a diagonal subblock of a matrix.
Definition block.h:355
The SCMatrixLTriBlock describes a triangular piece of a matrix.
Definition block.h:257
The SCMatrixLTriSubBlock describes a triangular subblock of a matrix.
Definition block.h:292
The SCMatrixRectBlock describes a rectangular piece of a matrix.
Definition block.h:187
The SCMatrixRectSubBlock describes a rectangular piece of a matrix.
Definition block.h:223
The SCMatrix class is the abstract base class for general double valued n by m matrices.
Definition abstract.h:195
The SCVectorSimpleBlock describes a piece of a vector.
Definition block.h:127
The SCVectorSimpleSubBlock describes a subblock of a vector.
Definition block.h:158
The SCVector class is the abstract base class for double valued vectors.
Definition abstract.h:97
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
The SymmSCMatrix class is the abstract base class for symmetric double valued matrices.
Definition abstract.h:364

Generated at Thu Jul 18 2024 00:00:00 for MPQC 2.3.1 using the documentation package Doxygen 1.11.0.