MPQC  3.0.0-alpha
local.h
1 //
2 // local.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_local_h
29 #define _math_scmat_local_h
30 
31 #include <math/scmat/block.h>
32 #include <math/scmat/matrix.h>
33 #include <math/scmat/abstract.h>
34 
35 namespace sc {
36 
37 class LocalSCMatrixKit;
38 class LocalSCVector;
39 class LocalSCMatrix;
40 class LocalSymmSCMatrix;
41 class LocalDiagSCMatrix;
42 
46  public:
51  SymmSCMatrix* symmmatrix(const RefSCDimension&);
52  DiagSCMatrix* diagmatrix(const RefSCDimension&);
54 };
55 
56 class LocalSCVector: public SCVector {
57  friend class LocalSCMatrix;
58  friend class LocalSymmSCMatrix;
59  friend class LocalDiagSCMatrix;
60  private:
62 
63  void resize(int);
64  public:
65  LocalSCVector();
67  ~LocalSCVector();
68  void assign_val(double);
69  void assign_v(SCVector*);
70  void assign_p(const double*);
71 
72  void set_element(int,double);
73  void accumulate_element(int,double);
74  double get_element(int) const;
75  void accumulate_product_sv(SymmSCMatrix*,SCVector*);
76  void accumulate_product_rv(SCMatrix*,SCVector*);
77  void accumulate(const SCVector*);
78  void accumulate(const SCMatrix*);
79  double scalar_product(SCVector*);
80  void element_op(const Ref<SCElementOp>&);
81  void element_op(const Ref<SCElementOp2>&,
82  SCVector*);
83  void element_op(const Ref<SCElementOp3>&,
84  SCVector*,SCVector*);
85  void vprint(const char* title=0,
86  std::ostream& out=ExEnv::out0(), int =10) const;
87 
88  // return a pointer to the data for fast access
89  double *get_data();
90 
91  Ref<SCMatrixSubblockIter> local_blocks(SCMatrixSubblockIter::Access);
92  Ref<SCMatrixSubblockIter> all_blocks(SCMatrixSubblockIter::Access);
93 };
94 
95 class LocalSCMatrix: public SCMatrix {
96  friend class LocalSymmSCMatrix;
97  friend class LocalDiagSCMatrix;
98  friend class LocalSCVector;
99  private:
101  double** rows;
102  private:
103  // utility functions
104  int compute_offset(int,int) const;
105  void resize(int,int);
106  public:
109  ~LocalSCMatrix();
110 
111  // implementations and overrides of virtual functions
112  void assign_val(double);
113  double get_element(int,int) const;
114  void set_element(int,int,double);
115  void accumulate_element(int,int,double);
116  SCMatrix * get_subblock(int,int,int,int);
117  void assign_subblock(SCMatrix*, int,int,int,int,int=0,int=0);
118  void accumulate_subblock(SCMatrix*, int,int,int,int,int=0,int=0);
119  SCVector * get_row(int i);
120  SCVector * get_column(int i);
121  void assign_row(SCVector *v, int i);
122  void assign_column(SCVector *v, int i);
123  void accumulate_row(SCVector *v, int i);
124  void accumulate_column(SCVector *v, int i);
126  void accumulate_product_rr(SCMatrix*,SCMatrix*);
127  void accumulate_product_rs(SCMatrix*,SymmSCMatrix*);
128  void accumulate_product_rd(SCMatrix*,DiagSCMatrix*);
129  void accumulate(const SCMatrix*);
130  void accumulate(const SymmSCMatrix*);
131  void accumulate(const DiagSCMatrix*);
132  void accumulate(const SCVector*);
133  void transpose_this();
134  double invert_this();
136  double solve_this(SCVector*);
137  double determ_this();
138  double trace();
139  void schmidt_orthog(SymmSCMatrix*,int);
140  int schmidt_orthog_tol(SymmSCMatrix*, double tol, double *res=0);
141  void element_op(const Ref<SCElementOp>&);
142  void element_op(const Ref<SCElementOp2>&,
143  SCMatrix*);
144  void element_op(const Ref<SCElementOp3>&,
145  SCMatrix*,SCMatrix*);
146  void vprint(const char* title=0,
147  std::ostream& out=ExEnv::out0(), int =10) const;
148 
149  // return a pointer to the data for fast access
150  double *get_data();
151  double **get_rows();
152 
153  Ref<SCMatrixSubblockIter> local_blocks(SCMatrixSubblockIter::Access);
154  Ref<SCMatrixSubblockIter> all_blocks(SCMatrixSubblockIter::Access);
155 };
156 
159  friend class LocalSCMatrix;
160  friend class LocalDiagSCMatrix;
161  friend class LocalSCVector;
162  private:
164  double** rows;
165  private:
166  // utility functions
167  int compute_offset(int,int) const;
168  void resize(int n);
169  public:
172 
173  // implementations and overrides of virtual functions
174  double get_element(int,int) const;
175  void set_element(int,int,double);
176  void accumulate_element(int,int,double);
177 
178  SCMatrix * get_subblock(int,int,int,int);
179  SymmSCMatrix * get_subblock(int,int);
180  void assign_subblock(SCMatrix*, int,int,int,int);
181  void assign_subblock(SymmSCMatrix*, int,int);
182  void accumulate_subblock(SCMatrix*, int,int,int,int);
183  void accumulate_subblock(SymmSCMatrix*, int,int);
184  SCVector * get_row(int i);
185  void assign_row(SCVector *v, int i);
186  void accumulate_row(SCVector *v, int i);
187 
188  void accumulate_product_rr(SCMatrix*,SCMatrix*);
189  void accumulate(const SymmSCMatrix*);
190  double invert_this();
191  double solve_this(SCVector*);
192  double trace();
193  double determ_this();
194  void gen_invert_this(double condition_number_threshold = 1e8);
195 
196  double scalar_product(SCVector*);
199  void accumulate_symmetric_outer_product(SCVector*);
202  void accumulate_transform(SCMatrix*,SymmSCMatrix*,
203  SCMatrix::Transform = SCMatrix::NormalTransform);
204  void accumulate_transform(SCMatrix*,DiagSCMatrix*,
205  SCMatrix::Transform = SCMatrix::NormalTransform);
206  void accumulate_transform(SymmSCMatrix*,SymmSCMatrix*);
207  void element_op(const Ref<SCElementOp>&);
208  void element_op(const Ref<SCElementOp2>&,
209  SymmSCMatrix*);
210  void element_op(const Ref<SCElementOp3>&,
212  void vprint(const char* title=0,
213  std::ostream& out=ExEnv::out0(), int =10) const;
214 
215  // return a pointer to the data for fast access
216  double *get_data();
217  double **get_rows();
218 
219  Ref<SCMatrixSubblockIter> local_blocks(SCMatrixSubblockIter::Access);
220  Ref<SCMatrixSubblockIter> all_blocks(SCMatrixSubblockIter::Access);
221 };
222 
225  friend class LocalSCMatrix;
226  friend class LocalSymmSCMatrix;
227  friend class LocalSCVector;
228  private:
230  void resize(int n);
231  public:
234 
235  // implementations and overrides of virtual functions
236  void save_data_state(StateOut&);
237  double get_element(int) const;
238  void set_element(int,double);
239  void accumulate_element(int,double);
240  void accumulate(const DiagSCMatrix*);
241  double invert_this();
242  double determ_this();
243  double trace();
244  void gen_invert_this(double condition_number_threshold = 1e8);
245 
246  void element_op(const Ref<SCElementOp>&);
247  void element_op(const Ref<SCElementOp2>&,
248  DiagSCMatrix*);
249  void element_op(const Ref<SCElementOp3>&,
251  void vprint(const char* title=0,
252  std::ostream& out=ExEnv::out0(), int =10) const;
253 
254  // return a pointer to the data for fast access
255  double *get_data();
256 
257  Ref<SCMatrixSubblockIter> local_blocks(SCMatrixSubblockIter::Access);
258  Ref<SCMatrixSubblockIter> all_blocks(SCMatrixSubblockIter::Access);
259 };
260 
261 }
262 
263 #endif
264 
265 // Local Variables:
266 // mode: c++
267 // c-file-style: "CLJ"
268 // End:
sc::LocalSCMatrix::accumulate_subblock
void accumulate_subblock(SCMatrix *, int, int, int, int, int=0, int=0)
Sum m into a subblock of this.
sc::LocalSymmSCMatrix::diagonalize
void diagonalize(DiagSCMatrix *, SCMatrix *)
Diagonalize this, placing the eigenvalues in d and the eigenvectors in m.
sc::LocalSCMatrix::element_op
void element_op(const Ref< SCElementOp > &)
Perform the element operation op on each element of this.
sc::LocalSCMatrix::local_blocks
Ref< SCMatrixSubblockIter > local_blocks(SCMatrixSubblockIter::Access)
Returns iterators for the local (rapidly accessible) blocks used in this matrix.
sc::LocalSymmSCMatrix::get_subblock
SCMatrix * get_subblock(int, int, int, int)
Return a subblock of this.
sc::LocalSCMatrix::assign_subblock
void assign_subblock(SCMatrix *, int, int, int, int, int=0, int=0)
Assign m to a subblock of this.
mpqc::ci::sigma
void sigma(const CI< Type, Index > &ci, const mpqc::Vector &h, const Matrix &V, ci::Vector &C, ci::Vector &S)
Computes sigma 1,2,3 contributions.
Definition: sigma.hpp:30
sc::SCVector
The SCVector class is the abstract base class for double valued vectors.
Definition: abstract.h:97
sc::LocalSCMatrix::get_subblock
SCMatrix * get_subblock(int, int, int, int)
Return a subblock of this.
sc::LocalDiagSCMatrix::accumulate
void accumulate(const DiagSCMatrix *)
Sum m into this.
sc::LocalSymmSCMatrix::determ_this
double determ_this()
Return the determinant of this. this is overwritten.
sc::LocalSCMatrixKit::matrix
SCMatrix * matrix(const RefSCDimension &, const RefSCDimension &)
Given the dimensions, create matrices or vectors.
sc::LocalSymmSCMatrix::assign_row
void assign_row(SCVector *v, int i)
Assign v to a row of this.
sc::LocalSymmSCMatrix::accumulate_symmetric_sum
void accumulate_symmetric_sum(SCMatrix *)
Sum into a + a.t()
sc::LocalSymmSCMatrix::invert_this
double invert_this()
Invert this.
sc::LocalSCVector::get_element
double get_element(int) const
Return the value of element i.
sc::LocalSCMatrix::get_row
SCVector * get_row(int i)
Return a row or column of this.
sc::LocalSymmSCMatrix
Local SymmSCMatrix.
Definition: local.h:158
sc::Ref
A template class that maintains references counts.
Definition: ref.h:361
sc::LocalSCVector::set_element
void set_element(int, double)
Set element i to val.
sc::LocalSCVector
Definition: local.h:56
sc::LocalSymmSCMatrix::get_row
SCVector * get_row(int i)
Return a row of this.
sc::SCMatrixKit
The SCMatrixKit abstract class acts as a factory for producing matrices.
Definition: abstract.h:57
sc::LocalSCVector::assign_val
void assign_val(double)
Overridden to implement the assign functions.
sc::LocalSCVector::local_blocks
Ref< SCMatrixSubblockIter > local_blocks(SCMatrixSubblockIter::Access)
Returns iterators for the local (rapidly accessible) blocks used in this vector.
sc::LocalSymmSCMatrix::scalar_product
double scalar_product(SCVector *)
Return the scalar obtained by multiplying this on the left and right by v.
sc::LocalSCMatrix::all_blocks
Ref< SCMatrixSubblockIter > all_blocks(SCMatrixSubblockIter::Access)
Returns iterators for the all blocks used in this matrix.
sc::LocalSymmSCMatrix::gen_invert_this
void gen_invert_this(double condition_number_threshold=1e8)
Return the generalized inverse of this using SVD decomposition.
sc::LocalSCMatrix::invert_this
double invert_this()
Invert this.
sc::DiagSCMatrix
The SymmSCMatrix class is the abstract base class for diagonal double valued matrices.
Definition: abstract.h:551
sc::LocalDiagSCMatrix::determ_this
double determ_this()
Return the determinant of this. this is overwritten.
sc::LocalDiagSCMatrix::invert_this
double invert_this()
Invert this.
sc::LocalSymmSCMatrix::eigensystem
void eigensystem(SymmSCMatrix *, DiagSCMatrix *, SCMatrix *)
Solve generalized eigensystem for this with metric s, placing the eigenvalues in d and the eigenvecto...
sc::RefSCDimension
The RefSCDimension class is a smart pointer to an SCDimension specialization.
Definition: dim.h:152
sc::LocalSymmSCMatrix::assign_subblock
void assign_subblock(SCMatrix *, int, int, int, int)
Assign m to a subblock of this.
sc::LocalSCVector::all_blocks
Ref< SCMatrixSubblockIter > all_blocks(SCMatrixSubblockIter::Access)
Returns iterators for the all blocks used in this vector.
sc::LocalSCMatrix::trace
double trace()
Return the trace.
sc::LocalSCMatrix::accumulate_row
void accumulate_row(SCVector *v, int i)
Sum v to a row or column of this.
sc::LocalSCMatrix::assign_val
void assign_val(double)
Overridden to implement to assign members.
sc::LocalSymmSCMatrix::element_op
void element_op(const Ref< SCElementOp > &)
only applied to the unique elements of this.
sc::SymmSCMatrix::n
int n() const
Return the dimension.
Definition: abstract.h:443
sc::DiagSCMatrix::n
int n() const
Return the dimension.
Definition: abstract.h:598
sc::LocalSymmSCMatrix::accumulate_symmetric_product
void accumulate_symmetric_product(SCMatrix *)
Sum into this a * a.t()
sc::LocalSCMatrix::accumulate
void accumulate(const SCMatrix *)
Sum m into this.
sc::LocalSymmSCMatrix::accumulate
void accumulate(const SymmSCMatrix *)
Sum m into this.
sc::LocalSCMatrix
Definition: local.h:95
sc::LocalDiagSCMatrix
Local DiagSCMatrix.
Definition: local.h:224
sc::LocalSCVector::element_op
void element_op(const Ref< SCElementOp > &)
Perform the element operation op on each element of this.
sc::LocalSymmSCMatrix::trace
double trace()
Return the trace.
sc::LocalSymmSCMatrix::local_blocks
Ref< SCMatrixSubblockIter > local_blocks(SCMatrixSubblockIter::Access)
Returns iterators for the local (rapidly accessible) blocks used in this matrix.
sc::LocalSCMatrix::get_element
double get_element(int, int) const
Return or modify an element.
sc::StateOut
Definition: stateout.h:71
sc::LocalSCMatrix::schmidt_orthog_tol
int schmidt_orthog_tol(SymmSCMatrix *, double tol, double *res=0)
Schmidt orthogonalize this.
sc::LocalDiagSCMatrix::trace
double trace()
Return the trace.
sc::LocalSymmSCMatrix::get_element
double get_element(int, int) const
Return or modify an element.
sc::LocalSCVector::scalar_product
double scalar_product(SCVector *)
Return the dot product.
sc::LocalSCMatrix::assign_row
void assign_row(SCVector *v, int i)
Assign v to a row or column of this.
sc::LocalSCMatrixKit
The LocalSCMatrixKit produces matrices that work in a single processor environment.
Definition: local.h:45
sc::SymmSCMatrix
The SymmSCMatrix class is the abstract base class for symmetric double valued matrices.
Definition: abstract.h:385
sc::SCMatrix::Transform
Transform
types of matrix transforms. Only real-valued matrices are assumed.
Definition: abstract.h:205
sc::LocalSCMatrix::transpose_this
void transpose_this()
Transpose this.
sc::LocalDiagSCMatrix::element_op
void element_op(const Ref< SCElementOp > &)
Perform the element operation op on each element of this.
sc::LocalSCVector::accumulate_element
void accumulate_element(int, double)
Add val to element i.
sc::LocalSymmSCMatrix::all_blocks
Ref< SCMatrixSubblockIter > all_blocks(SCMatrixSubblockIter::Access)
Returns iterators for the all blocks used in this matrix.
sc::ExEnv::out0
static std::ostream & out0()
Return an ostream that writes from node 0.
sc::LocalSCMatrix::determ_this
double determ_this()
Return the determinant of this. this is overwritten.
sc::SCMatrix
The SCMatrix class is the abstract base class for general double valued n by m matrices.
Definition: abstract.h:195
sc::LocalDiagSCMatrix::gen_invert_this
void gen_invert_this(double condition_number_threshold=1e8)
Return the generalized inverse of this using SVD decomposition.
sc::LocalSCMatrix::schmidt_orthog
void schmidt_orthog(SymmSCMatrix *, int)
Schmidt orthogonalize this.
sc::LocalSymmSCMatrix::accumulate_subblock
void accumulate_subblock(SCMatrix *, int, int, int, int)
Sum m into a subblock of this.
mpqc::vector
Vector class derived from Eigen::Matrix with additional MPQC integration.
Definition: matrix.hpp:133
sc::LocalDiagSCMatrix::local_blocks
Ref< SCMatrixSubblockIter > local_blocks(SCMatrixSubblockIter::Access)
Returns iterators for the local (rapidly accessible) blocks used in this matrix.
sc::LocalSCMatrix::accumulate_outer_product
void accumulate_outer_product(SCVector *, SCVector *)
Sum into this the products of various vectors or matrices.
sc::LocalSymmSCMatrix::accumulate_row
void accumulate_row(SCVector *v, int i)
Sum v to a row of this.
sc::LocalDiagSCMatrix::all_blocks
Ref< SCMatrixSubblockIter > all_blocks(SCMatrixSubblockIter::Access)
Returns iterators for the all blocks used in this matrix.
sc
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14
sc::LocalDiagSCMatrix::get_element
double get_element(int) const
Return or modify an element.
sc::LocalSCMatrix::svd_this
void svd_this(SCMatrix *U, DiagSCMatrix *sigma, SCMatrix *V)
Compute the singular value decomposition for this, possibly destroying this.
sc::LocalSCVector::accumulate
void accumulate(const SCVector *)
Sum v into this.

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