28 #ifndef _math_scmat_abstract_h
29 #define _math_scmat_abstract_h
35 #include <util/group/message.h>
37 #include <util/state/state.h>
38 #include <math/scmat/dim.h>
39 #include <math/scmat/block.h>
106 virtual void restore(
StateIn&);
119 int n()
const {
return d->n(); }
121 virtual double maxabs()
const;
129 void assign(
const double* v) { assign_p(v); }
135 virtual void assign_p(
const double* v);
138 virtual void convert(
double* v)
const;
142 virtual void convert_accumulate(
SCVector*);
144 virtual void scale(
double val);
156 { accumulate_product_sv(m,v); }
158 { accumulate_product_rv(m,v); }
159 virtual void accumulate_product_sv(SymmSCMatrix* m, SCVector* v);
160 virtual void accumulate_product_rv(SCMatrix* m, SCVector* v) = 0;
162 virtual void accumulate(
const SCVector*v) = 0;
164 virtual void accumulate(
const SCMatrix*m) = 0;
168 virtual void element_op(
const Ref<SCElementOp>&) = 0;
169 virtual void element_op(
const Ref<SCElementOp2>&,
171 virtual void element_op(
const Ref<SCElementOp3>&,
172 SCVector*,SCVector*) = 0;
175 void print(
const char* title=0,std::ostream&out=
ExEnv::out0(),
int=10)
const;
176 virtual void vprint(
const char*title=0,std::ostream&out=
ExEnv::out0(),
187 SCMatrixSubblockIter::Access) = 0;
189 virtual Ref<SCMatrixSubblockIter>
all_blocks(SCMatrixSubblockIter::Access) = 0;
201 enum Transform { NormalTransform = 0, TransposeTransform = 1 };
209 virtual void restore(
StateIn&);
215 int nrow()
const {
return d1->n(); }
217 int ncol()
const {
return d2->n(); }
219 virtual double maxabs()
const;
225 void assign(
const double* m) { assign_p(m); }
227 void assign(
const double** m) { assign_pp(m); }
232 virtual void assign_p(
const double* m);
233 virtual void assign_pp(
const double** m);
237 virtual void convert(
double*)
const;
238 virtual void convert(
double**)
const;
242 virtual void convert_accumulate(
SCMatrix*);
244 virtual void scale(
double val);
262 virtual void set_element(
int,
int,
double) = 0;
263 virtual void accumulate_element(
int,
int,
double) = 0;
268 virtual SCMatrix *
get_subblock(
int br,
int er,
int bc,
int ec) =0;
271 virtual void assign_subblock(SCMatrix *m,
int,
int,
int,
int,
int=0,
int=0) =0;
277 virtual SCVector *
get_row(
int i) =0;
278 virtual SCVector * get_column(
int i) =0;
281 virtual void assign_row(SCVector *v,
int i) =0;
282 virtual void assign_column(SCVector *v,
int i) =0;
286 virtual void accumulate_column(SCVector *v,
int i) =0;
289 virtual void accumulate(
const SCMatrix* m) = 0;
290 virtual void accumulate(
const SymmSCMatrix* m) = 0;
291 virtual void accumulate(
const DiagSCMatrix* m) = 0;
295 void accumulate_product(SCMatrix*m1,SCMatrix*m2)
296 { accumulate_product_rr(m1,m2); }
297 void accumulate_product(SCMatrix*m1,SymmSCMatrix*m2)
298 { accumulate_product_rs(m1,m2); }
299 void accumulate_product(SCMatrix*m1,DiagSCMatrix*m2)
300 { accumulate_product_rd(m1,m2); }
301 void accumulate_product(SymmSCMatrix*m1,SCMatrix*m2)
302 { accumulate_product_sr(m1,m2); }
303 void accumulate_product(DiagSCMatrix*m1,SCMatrix*m2)
304 { accumulate_product_dr(m1,m2); }
305 void accumulate_product(SymmSCMatrix*m1,SymmSCMatrix*m2)
306 { accumulate_product_ss(m1,m2); }
307 virtual void accumulate_product_rr(SCMatrix*,SCMatrix*) = 0;
308 virtual void accumulate_product_rs(SCMatrix*,SymmSCMatrix*);
309 virtual void accumulate_product_rd(SCMatrix*,DiagSCMatrix*);
310 virtual void accumulate_product_sr(SymmSCMatrix*,SCMatrix*);
311 virtual void accumulate_product_dr(DiagSCMatrix*,SCMatrix*);
312 virtual void accumulate_product_ss(SymmSCMatrix*,SymmSCMatrix*);
316 virtual double trace() =0;
324 virtual void svd_this(SCMatrix *U, DiagSCMatrix *sigma, SCMatrix *V);
325 virtual double solve_this(SCVector*) = 0;
326 virtual void gen_invert_this();
338 virtual void element_op(
const Ref<SCElementOp>&) = 0;
339 virtual void element_op(
const Ref<SCElementOp2>&,
341 virtual void element_op(
const Ref<SCElementOp3>&,
342 SCMatrix*,SCMatrix*) = 0;
347 virtual void vprint(
const char*title=0,
356 SCMatrixSubblockIter::Access) = 0;
359 SCMatrixSubblockIter::Access) = 0;
377 virtual void restore(
StateIn&);
379 virtual double maxabs()
const;
385 void assign(
const double* m) { assign_p(m); }
387 void assign(
const double** m) { assign_pp(m); }
393 virtual void assign_p(
const double* m);
394 virtual void assign_pp(
const double** m);
397 virtual void convert(
double*)
const;
398 virtual void convert(
double**)
const;
404 virtual void scale(
double);
412 int n()
const {
return d->n(); }
423 virtual void set_element(
int,
int,
double) = 0;
424 virtual void accumulate_element(
int,
int,
double) = 0;
456 virtual void accumulate_symmetric_product(
SCMatrix*);
458 SCMatrix::Transform = SCMatrix::NormalTransform);
460 SCMatrix::Transform = SCMatrix::NormalTransform);
462 virtual void accumulate_symmetric_outer_product(
SCVector*);
467 virtual double trace() = 0;
473 virtual double solve_this(
SCVector*) = 0;
474 virtual void gen_invert_this() = 0;
486 virtual void vprint(
const char* title=0,
495 SCMatrixSubblockIter::Access) = 0;
498 SCMatrixSubblockIter::Access) = 0;
516 virtual void restore(
StateIn&);
519 virtual double maxabs()
const;
525 void assign(
const double*p) { assign_p(p); }
531 virtual void assign_p(
const double*);
534 virtual void convert(
double*)
const;
540 virtual void scale(
double);
542 int n()
const {
return d->n(); }
553 virtual void set_element(
int,
double) = 0;
554 virtual void accumulate_element(
int,
double) = 0;
558 virtual double trace() = 0;
573 void print(
const char* title=0,
575 virtual void vprint(
const char* title=0,
584 SCMatrixSubblockIter::Access) = 0;
587 SCMatrixSubblockIter::Access) = 0;
virtual SCMatrix * copy()
Return a matrix with the same dimension and same elements.
virtual double determ_this()=0
Return the determinant of this. this is overwritten.
virtual double get_element(int, int) const =0
Return or modify an element.
void assign(const double *m)
Assign element i, j to m[i*(i+1)/2+j].
Definition: abstract.h:385
Ref< SCMatrixKit > kit() const
Return the SCMatrixKit used to create this object.
Definition: abstract.h:512
virtual void accumulate(const SCMatrix *m)=0
Sum m into this.
virtual void randomize()
Assign each element to a random number between -1 and 1.
virtual void scale_diagonal(double)
Scale the diagonal elements by val.
void assign(DiagSCMatrix *d_a)
Make this have the same elements as m.
Definition: abstract.h:528
virtual double maxabs() const
Return the maximum absolute value element of this vector.
virtual void convert(double *v) const
Assign v[i] to element i for all i.
virtual void transpose_this()=0
Transpose this.
virtual void assign_val(double val)
Overridden to implement the assign members.
virtual void accumulate_outer_product(SCVector *, SCVector *)=0
Sum into this the products of various vectors or matrices.
void print(std::ostream &o=ExEnv::out0()) const
Print out the matrix.
void assign(const double *m)
Assign element i, j to m[ir*nrow()+j].
Definition: abstract.h:225
The SCVector class is the abstract base class for double valued vectors.
Definition: abstract.h:97
RefSCDimension dim() const
Return the dimension.
Definition: abstract.h:550
virtual double get_element(int, int) const =0
Return or modify an element.
virtual Ref< SCMatrixSubblockIter > local_blocks(SCMatrixSubblockIter::Access)=0
Returns iterators for the local (rapidly accessible) blocks used in this vector.
virtual Ref< SCMatrixSubblockIter > all_blocks(SCMatrixSubblockIter::Access)=0
Returns iterators for the all blocks used in this vector.
virtual void scale(double val)
Multiply each element by val.
virtual void save(StateOut &)
Save and restore this in an implementation independent way.
virtual void save(StateOut &)
Save and restore this in an implementation independent way.
virtual void randomize()
Assign each element to a random number between -1 and 1.
virtual double scalar_product(SCVector *v)
Return the scalar obtained by multiplying this on the left and right by v.
virtual void save(StateOut &)
Save and restore this in an implementation independent way.
virtual SCMatrix * matrix(const RefSCDimension &, const RefSCDimension &)=0
Given the dimensions, create matrices or vectors.
A template class that maintains references counts.
Definition: ref.h:332
virtual void accumulate_subblock(SCMatrix *m, int, int, int, int, int=0, int=0)=0
Sum m into a subblock of this.
int ncol() const
Return the number of columns.
Definition: abstract.h:217
virtual double determ_this()=0
Return the determinant of this. this is overwritten.
void assign(SymmSCMatrix *m)
Make this have the same elements as m.
Definition: abstract.h:390
virtual void accumulate_row(SCVector *v, int i)=0
Sum v to a row of this.
virtual void diagonalize(DiagSCMatrix *d, SCMatrix *m)=0
Diagonalize this, placing the eigenvalues in d and the eigenvectors in m.
Ref< SCMatrixKit > kit() const
Return the SCMatrixKit object that created this object.
Definition: abstract.h:373
virtual void randomize()
Assign each element to a random number between -1 and 1.
virtual SCMatrix * clone()
Return a matrix with the same dimension but uninitialized memory.
virtual void scale(double)
Multiply all elements by val.
virtual DiagSCMatrix * copy()
Return a matrix with the same dimension and same elements.
virtual void assign_val(double val)
Overridden to implement the assign functions.
virtual double invert_this()=0
Invert this.
The SCMatrixKit abstract class acts as a factory for producing matrices.
Definition: abstract.h:58
void print(std::ostream &o=ExEnv::out0()) const
Print out the matrix.
virtual void assign_val(double val)
Overridden to implement the assign functions.
virtual void assign_val(double val)
Overridden to implement to assign members.
Ref< SCMatrixKit > kit() const
Return the SCMatrixKit used to create this object.
Definition: abstract.h:212
virtual void schmidt_orthog(SymmSCMatrix *, int n)=0
Schmidt orthogonalize this.
virtual void convert(double *) const
Like the assign member, but this writes values to the argument.
void accumulate_product(SymmSCMatrix *m, SCVector *v)
Sum the result of m times v into this.
Definition: abstract.h:155
virtual SCMatrix * get_subblock(int br, int er, int bc, int ec)=0
Return a subblock of this.
virtual void element_op(const Ref< SCElementOp > &)=0
Perform the element operation op on each element of this.
RefSCDimension dim() const
Return the RefSCDimension corresponding to this vector.
Definition: abstract.h:147
virtual void accumulate(const SymmSCMatrix *m)=0
Sum m into this.
The SymmSCMatrix class is the abstract base class for diagonal double valued matrices.
Definition: abstract.h:503
virtual void set_element(int i, double val)=0
Set element i to val.
virtual double trace()=0
Return the trace.
virtual void scale_diagonal(double val)
Scale the diagonal elements by val.
void assign(const double *v)
Assign element i to v[i] for all i.
Definition: abstract.h:129
Restores objects that derive from SavableState.
Definition: statein.h:70
virtual void element_op(const Ref< SCElementOp > &)=0
Perform the element operation op on each element of this.
virtual void scale(double)
Multiply all elements by val.
The RefSCDimension class is a smart pointer to an SCDimension specialization.
Definition: dim.h:156
virtual void assign_subblock(SCMatrix *m, int, int, int, int, int=0, int=0)=0
Assign m to a subblock of this.
virtual Ref< SCMatrixSubblockIter > local_blocks(SCMatrixSubblockIter::Access)=0
Returns iterators for the local (rapidly accessible) blocks used in this matrix.
Ref< MessageGrp > messagegrp() const
Returns the message group used by the matrix kit.
virtual void scale(double val)
Multiply all elements by val.
Ref< MessageGrp > messagegrp() const
Returns the message group used by the matrix kit.
virtual void accumulate_subblock(SCMatrix *m, int, int, int, int)=0
Sum m into a subblock of this.
Ref< SCMatrixKit > kit() const
Return the SCMatrixKit used to create this object.
Definition: abstract.h:109
virtual SymmSCMatrix * copy()
Return a matrix with the same dimension and same elements.
virtual void accumulate_symmetric_sum(SCMatrix *)=0
Sum into this the products of various vectors or matrices.
static SCMatrixKit * default_matrixkit()
This returns a LocalSCMatrixKit, unless the default has been changed with set_default_matrixkit.
void assign(SCMatrix *m)
Make this have the same elements as m. The dimensions must match.
Definition: abstract.h:229
void assign(const double *p)
Assign element i, i to m[i].
Definition: abstract.h:525
virtual double determ_this()=0
Return the determinant of this. this is overwritten.
virtual void element_op(const Ref< SCElementOp > &)=0
Perform the element operation op on each element of this.
int n() const
Return the dimension.
Definition: abstract.h:412
virtual void accumulate(const SCVector *v)=0
Sum v into this.
int n() const
Return the dimension.
Definition: abstract.h:542
virtual void unit()
Make this equal to the unit matrix.
virtual void randomize()
Assign each element to a random number between -1 and 1.
virtual void accumulate_element(int, double)=0
Add val to element i.
void assign(SCVector *v)
Make this have the same elements as v.
Definition: abstract.h:132
void assign(const double **m)
Assign element i, j to m[i][j].
Definition: abstract.h:227
virtual SCVector * copy()
Return a vector with the same dimension and same elements.
SCMatrix * restore_matrix(StateIn &, const RefSCDimension &, const RefSCDimension &)
Given the dimensions and a StateIn object, restore matrices or vectors.
RefSCDimension rowdim() const
Return the row or column dimension.
Definition: abstract.h:258
virtual SCVector * clone()
Return a vector with the same dimension but uninitialized memory.
virtual void assign_row(SCVector *v, int i)=0
Assign v to a row of this.
virtual void shift_diagonal(double)
Shift the diagonal elements by val.
virtual int schmidt_orthog_tol(SymmSCMatrix *, double tol, double *res=0)=0
Schmidt orthogonalize this.
virtual SCMatrix * get_subblock(int br, int er, int bc, int ec)=0
Return a subblock of this.
virtual double invert_this()=0
Invert this.
Serializes objects that derive from SavableState.
Definition: stateout.h:61
void assign(double val)
Assign all elements of this to val.
Definition: abstract.h:127
virtual Ref< SCMatrixSubblockIter > all_blocks(SCMatrixSubblockIter::Access)=0
Returns iterators for the all blocks used in this matrix.
virtual void save(StateOut &)
Save and restore this in an implementation independent way.
void assign(const double **m)
Assign element i, j to m[i][j].
Definition: abstract.h:387
virtual SCVector * get_row(int i)=0
Return a row of this.
The SymmSCMatrix class is the abstract base class for symmetric double valued matrices.
Definition: abstract.h:364
void print(std::ostream &o=ExEnv::out0()) const
Print out the matrix.
Ref< MessageGrp > messagegrp() const
Returns the message group used by the matrix kit.
virtual Ref< SCMatrixSubblockIter > local_blocks(SCMatrixSubblockIter::Access)=0
Returns iterators for the local (rapidly accessible) blocks used in this matrix.
Classes which need runtime information about themselves and their relationship to other classes can v...
Definition: class.h:244
virtual void normalize()
Normalize this.
virtual Ref< SCMatrixSubblockIter > all_blocks(SCMatrixSubblockIter::Access)=0
Returns iterators for the all blocks used in this matrix.
virtual void convert(double *) const
Like the assign members, but these write values to the arguments.
virtual void unit()
Make this equal to the unit matrix.
virtual double scalar_product(SCVector *)=0
Return the dot product.
Ref< MessageGrp > messagegrp() const
Returns the message group used by the matrix kit.
virtual void assign_subblock(SCMatrix *m, int, int, int, int)=0
Assign m to a subblock of this.
static std::ostream & out0()
Return an ostream that writes from node 0.
The SCMatrix class is the abstract base class for general double valued n by m matrices.
Definition: abstract.h:195
virtual double maxabs() const
Return the maximum absolute value element of this vector.
virtual void element_op(const Ref< SCElementOp > &)=0
Perform the element operation op on each element of this.
void assign(double val)
Set all elements to val.
Definition: abstract.h:383
virtual DiagSCMatrix * clone()
Return a matrix with the same dimension but uninitialized memory.
void print(std::ostream &o=ExEnv::out0()) const
Print out the vector.
virtual double get_element(int) const =0
Return or modify an element.
virtual double get_element(int i) const =0
Return the value of element i.
void assign(double val)
Set all elements to val.
Definition: abstract.h:223
virtual void accumulate_row(SCVector *v, int i)=0
Sum v to a row or column of this.
virtual double trace()=0
Return the trace.
virtual void assign_row(SCVector *v, int i)=0
Assign v to a row or column of this.
virtual void shift_diagonal(double val)
Shift the diagonal elements by val.
virtual double maxabs() const
Return the maximum absolute value element of this vector.
virtual Ref< SCMatrixSubblockIter > all_blocks(SCMatrixSubblockIter::Access)=0
Returns iterators for the all blocks used in this matrix.
int nrow() const
Return the number of rows.
Definition: abstract.h:215
RefSCDimension dim() const
Return the dimension.
Definition: abstract.h:420
virtual double maxabs() const
Return the maximum absolute value element.
virtual double trace()=0
Return the trace.
virtual SCVector * get_row(int i)=0
Return a row or column of this.
int n() const
Return the length of the vector.
Definition: abstract.h:119
virtual double invert_this()=0
Invert this.
virtual void convert(double *) const
Like the assign members, but these write values to the arguments.
virtual void svd_this(SCMatrix *U, DiagSCMatrix *sigma, SCMatrix *V)
Compute the singular value decomposition for this, possibly destroying this.
virtual SymmSCMatrix * clone()
Return a matrix with the same dimension but uninitialized memory.
virtual void gen_invert_this()=0
Do a generalized inversion of this.
void assign(double val)
Set all elements to val.
Definition: abstract.h:523
virtual void accumulate(const DiagSCMatrix *m)=0
Sum m into this.
virtual Ref< SCMatrixSubblockIter > local_blocks(SCMatrixSubblockIter::Access)=0
Returns iterators for the local (rapidly accessible) blocks used in this matrix.
Generated at Sun Jan 26 2020 23:33:03 for MPQC
2.3.1 using the documentation package Doxygen
1.8.16.