28 #ifndef _math_scmat_elemop_h
29 #define _math_scmat_elemop_h
34 #include <util/state/state.h>
35 #include <util/state/statein.h>
36 #include <util/state/stateout.h>
37 #include <util/group/message.h>
38 #include <math/scmat/blkiter.h>
39 #include <math/scmat/predicate.h>
44 class SCMatrixBlockIter;
45 class SCMatrixRectBlock;
46 class SCMatrixLTriBlock;
47 class SCMatrixDiagBlock;
48 class SCVectorSimpleBlock;
49 class SCMatrixRectSubBlock;
50 class SCMatrixLTriSubBlock;
51 class SCMatrixDiagSubBlock;
52 class SCVectorSimpleSubBlock;
60 enum Values {AllElements = 0,
66 typedef double value_type;
67 SCElement() : irow(
null.irow), icol(
null.icol), value(
null.value) {}
68 SCElement(
int ir,
int ic, value_type v) : irow(ir), icol(ic), value(v) {}
75 operator value_type()
const {
83 template <
class BinaryPredicate>
86 return BinaryPredicate()(a.value,b.value);
107 virtual void defer_collect(
int);
164 virtual int has_collect();
165 virtual void defer_collect(
int);
166 virtual int has_side_effects();
167 virtual int has_side_effects_in_arg();
186 virtual int has_collect();
187 virtual void defer_collect(
int);
188 virtual int has_side_effects();
189 virtual int has_side_effects_in_arg1();
190 virtual int has_side_effects_in_arg2();
224 void defer_collect(
int);
227 void init() { product = 0.0; }
239 int has_side_effects();
252 int has_side_effects();
309 int nbelowthreshold_;
319 void defer_collect(
int);
322 int result() {
return nbelowthreshold_; }
328 double scale_diagonal;
340 double shift_diagonal;
357 template <
class BinaryPredicate = std::less<
double>, SCMatrixIterationRanges::Values IterationRanges = SCMatrixIterationRanges::AllElements>
366 int nchar; s.
get(nchar);
371 memcpy(&r[0], r_char, nchar);
382 int nchar = r.size() *
sizeof(
SCElement);
385 s.
put((
char*)(&r[0]), nchar);
391 for (i.
reset(); i; ++i) {
393 switch(IterationRanges) {
394 case SCMatrixIterationRanges::AllElements:
range = 0;
break;
395 case SCMatrixIterationRanges::Columns:
range = i.
j();
break;
396 case SCMatrixIterationRanges::Rows:
range = i.
i();
break;
398 if (
range >= r.size()) {
399 const size_t old_size = r.size();
401 for(
size_t i=old_size; i<r.size(); ++i) {
405 double value = i.
get();
406 if (Op(r[
range].value, value)) {
413 void defer_collect(
int h) { deferred_=h; }
415 void collect(
const Ref<MessageGrp>& msg) {
417 GrpCompareReduce<SCElement, SCElementBinaryPredicateAdapter<BinaryPredicate> > reduce;
418 msg->reduce<SCElement>(&r[0], r.size(), reduce);
422 throw std::runtime_error(
423 "SCElementMaxAbs::collect(const Ref<SCElementOp> &): not implemented");
426 const std::vector<SCElement>& result() {
return r; }
431 std::vector<SCElement> r;
434 static ClassDesc class_desc_;
437 template <
class BinaryPredicate, SCMatrixIterationRanges::Values IterationRanges>
438 ClassDesc SCElementFindExtremum<BinaryPredicate,IterationRanges>::class_desc_(
440 typeid(this_type).name(),
441 1,
"public SCElementOp",
442 0, 0,
sc::create<
typename SCElementFindExtremum<BinaryPredicate,IterationRanges>::this_type>);
455 void defer_collect(
int);
474 void defer_collect(
int);
491 void defer_collect(
int);
495 void init() { r = 0.0; }
517 void defer_collect(
int);
521 void init() { r_ = 0.0; }
int has_side_effects()
By default this returns nonzero.
virtual int j()=0
Returns the column index.
int has_side_effects()
By default this returns nonzero.
SCMatrixBlock is the base clase for all types of blocks that comprise matrices and vectors.
Definition: block.h:41
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 SCElementOp2 class is very similar to the SCElementOp class except that pairs of blocks are treat...
Definition: elemop.h:159
void process(SCMatrixBlockIter &)
This is the fallback routine to process blocks and is called by process_spec members that are not ove...
The SCVector class is the abstract base class for double valued vectors.
Definition: abstract.h:97
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 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.
virtual void reset()=0
Start the iteration over.
The SCMatrixLTriBlock describes a triangular piece of a matrix.
Definition: block.h:253
SCElementKNorm(unsigned int k=2)
by default compute 2-norm
A template class that maintains references counts.
Definition: ref.h:361
void process(SCMatrixBlockIter &)
This is the fallback routine to process blocks and is called by process_spec members that are not ove...
void process(SCMatrixBlockIter &)
This is the fallback routine to process blocks and is called by process_spec members that are not ove...
virtual bool threadsafe() const
Returns true if this SCElementOp is threadsafe.
The SCMatrixRectBlock describes a rectangular piece of a matrix.
Definition: block.h:183
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 ...
The SCMatrixLTriSubBlock describes a triangular subblock of a matrix.
Definition: block.h:288
void process(SCMatrixBlockIter &)
This is the fallback routine to process blocks and is called by process_spec members that are not ove...
DescribedClass * create()
This is used to pass a function that make void constructor calls to the ClassDesc constructor.
Definition: class.h:102
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 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: elemop.h:379
virtual double get()=0
Return the value of the current element.
The SymmSCMatrix class is the abstract base class for diagonal double valued matrices.
Definition: abstract.h:551
does
Definition: elemop.h:234
virtual void process_spec_rect(SCMatrixRectBlock *)
Matrices should call these members when the type of block is known.
void process(SCMatrixBlockIter &i)
This is the fallback routine to process blocks and is called by process_spec members that are not ove...
Definition: elemop.h:390
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
Objects of class SCElementOp are used to perform operations on the elements of matrices.
Definition: elemop.h:94
The SCVectorSimpleSubBlock describes a subblock of a vector.
Definition: block.h:154
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.
virtual int i()=0
Returns the row index.
Computes k-norm of matrix.
Definition: elemop.h:499
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 ...
void process(SCMatrixBlockIter &)
This is the fallback routine to process blocks and is called by process_spec members that are not ove...
void process(SCMatrixBlockIter &)
This is the fallback routine to process blocks and is called by process_spec members that are not ove...
void process(SCMatrixBlockIter &)
This is the fallback routine to process blocks and is called by process_spec members that are not ove...
Adapts a binary predicate that acts on SCElement::value_type.
Definition: elemop.h:84
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.
virtual Ref< SCElementOp > clone()
Returns a clone of this object.
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...
virtual bool cloneable() const
Returns true if this SCElementOp supports the clone() member.
The SCVectorSimpleBlock describes a piece of a vector.
Definition: block.h:123
int has_side_effects()
By default this returns nonzero.
Definition: stateout.h:71
void process(SCMatrixBlockIter &)
This is the fallback routine to process blocks and is called by process_spec members that are not ove...
The SCMatrixBlockIter class is used to described iterates that loop through the elements in a block.
Definition: blkiter.h:46
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 SCMatrixDiagBlock describes a diagonal piece of a matrix.
Definition: block.h:318
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.
The SymmSCMatrix class is the abstract base class for symmetric double valued matrices.
Definition: abstract.h:385
virtual int has_collect()
If duplicates of the SCElementOp exist (that is, there is more than one node), then if has_collect re...
does
Definition: elemop.h:247
evaluates
Definition: elemop.h:213
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 ...
void save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
Searches each range in IterationRanges for element i so that there is no element j in that Range for ...
Definition: elemop.h:358
void process(SCMatrixBlockIter &)
This is the fallback routine to process blocks and is called by process_spec members that are not ove...
The SCMatrix class is the abstract base class for general double valued n by m matrices.
Definition: abstract.h:195
void collect(const Ref< SCElementOp > &op)
Multithreaded use of cloneable SCElementOp objects requires that data from cloned objects be collecte...
Definition: elemop.h:421
virtual int put(const ClassDesc *)
Write out information about the given ClassDesc.
Base class for objects that can save/restore state.
Definition: state.h:45
int has_collect()
If duplicates of the SCElementOp exist (that is, there is more than one node), then if has_collect re...
int has_side_effects()
By default this returns nonzero.
The SCMatrixRectSubBlock describes a rectangular piece of a matrix.
Definition: block.h:219
virtual void process(SCMatrixBlockIter &)=0
This is the fallback routine to process blocks and is called by process_spec members that are not ove...
The SCElementOp3 class is very similar to the SCElementOp class except that a triplet of blocks is tr...
Definition: elemop.h:181
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 save_data_state(StateOut &)
Save the base classes (with save_data_state) and the members in the same order that the StateIn CTOR ...
virtual int get(const ClassDesc **)
This restores ClassDesc's.
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.
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 ...
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14
int has_side_effects()
By default this returns nonzero.
int has_collect()
If duplicates of the SCElementOp exist (that is, there is more than one node), then if has_collect re...
Definition: elemop.h:412
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_collect()
If duplicates of the SCElementOp exist (that is, there is more than one node), then if has_collect re...
The SCMatrixDiagSubBlock describes a diagonal subblock of a matrix.
Definition: block.h:351
int has_collect()
If duplicates of the SCElementOp exist (that is, there is more than one node), then if has_collect re...
Generated at Sun Jan 26 2020 23:24:00 for MPQC
3.0.0-alpha using the documentation package Doxygen
1.8.16.