MPQC 3.0.0-alpha
Loading...
Searching...
No Matches
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
35namespace sc {
36
37class LocalSCMatrixKit;
38class LocalSCVector;
39class LocalSCMatrix;
40class LocalSymmSCMatrix;
41class LocalDiagSCMatrix;
42
46 public:
51 SymmSCMatrix* symmmatrix(const RefSCDimension&);
52 DiagSCMatrix* diagmatrix(const RefSCDimension&);
53 SCVector* vector(const RefSCDimension&);
54};
55
56class LocalSCVector: public SCVector {
57 friend class LocalSCMatrix;
58 friend class LocalSymmSCMatrix;
59 friend class LocalDiagSCMatrix;
60 private:
62
63 void resize(int);
64 public:
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*);
81 void element_op(const Ref<SCElementOp2>&,
82 SCVector*);
83 void element_op(const Ref<SCElementOp3>&,
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
95class 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:
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);
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*);
134 double invert_this();
136 double solve_this(SCVector*);
137 double determ_this();
138 double trace();
140 int schmidt_orthog_tol(SymmSCMatrix*, double tol, double *res=0);
142 void element_op(const Ref<SCElementOp2>&,
143 SCMatrix*);
144 void element_op(const Ref<SCElementOp3>&,
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);
185 void assign_row(SCVector *v, int i);
186 void accumulate_row(SCVector *v, int i);
187
188 void accumulate_product_rr(SCMatrix*,SCMatrix*);
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
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*);
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);
241 double invert_this();
242 double determ_this();
243 double trace();
244 void gen_invert_this(double condition_number_threshold = 1e8);
245
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:
The SymmSCMatrix class is the abstract base class for diagonal double valued matrices.
Definition abstract.h:555
int n() const
Return the dimension.
Definition abstract.h:598
static std::ostream & out0()
Return an ostream that writes from node 0.
Local DiagSCMatrix.
Definition local.h:224
double invert_this()
Invert this.
void accumulate(const DiagSCMatrix *)
Sum m into this.
Ref< SCMatrixSubblockIter > all_blocks(SCMatrixSubblockIter::Access)
Returns iterators for the all blocks used in this matrix.
void gen_invert_this(double condition_number_threshold=1e8)
Return the generalized inverse of this using SVD decomposition.
void element_op(const Ref< SCElementOp > &)
Perform the element operation op on each element of this.
double get_element(int) const
Return or modify an element.
double trace()
Return the trace.
Ref< SCMatrixSubblockIter > local_blocks(SCMatrixSubblockIter::Access)
Returns iterators for the local (rapidly accessible) blocks used in this matrix.
double determ_this()
Return the determinant of this. this is overwritten.
The LocalSCMatrixKit produces matrices that work in a single processor environment.
Definition local.h:45
SCMatrix * matrix(const RefSCDimension &, const RefSCDimension &)
Given the dimensions, create matrices or vectors.
Definition local.h:95
void transpose_this()
Transpose this.
void schmidt_orthog(SymmSCMatrix *, int)
Schmidt orthogonalize this.
void assign_subblock(SCMatrix *, int, int, int, int, int=0, int=0)
Assign m to a subblock of this.
SCMatrix * get_subblock(int, int, int, int)
Return a subblock of this.
Ref< SCMatrixSubblockIter > all_blocks(SCMatrixSubblockIter::Access)
Returns iterators for the all blocks used in this matrix.
double trace()
Return the trace.
void assign_val(double)
Overridden to implement to assign members.
void svd_this(SCMatrix *U, DiagSCMatrix *sigma, SCMatrix *V)
Compute the singular value decomposition for this, possibly destroying this.
void accumulate_row(SCVector *v, int i)
Sum v to a row or column of this.
double invert_this()
Invert this.
void assign_row(SCVector *v, int i)
Assign v to a row or column of this.
double get_element(int, int) const
Return or modify an element.
void element_op(const Ref< SCElementOp > &)
Perform the element operation op on each element of this.
Ref< SCMatrixSubblockIter > local_blocks(SCMatrixSubblockIter::Access)
Returns iterators for the local (rapidly accessible) blocks used in this matrix.
double determ_this()
Return the determinant of this. this is overwritten.
int schmidt_orthog_tol(SymmSCMatrix *, double tol, double *res=0)
Schmidt orthogonalize this.
SCVector * get_row(int i)
Return a row or column of this.
void accumulate_subblock(SCMatrix *, int, int, int, int, int=0, int=0)
Sum m into a subblock of this.
void accumulate_outer_product(SCVector *, SCVector *)
Sum into this the products of various vectors or matrices.
void accumulate(const SCMatrix *)
Sum m into this.
Definition local.h:56
void set_element(int, double)
Set element i to val.
void accumulate(const SCMatrix *)
Sum m into this. One of m's dimensions must be 1.
Ref< SCMatrixSubblockIter > local_blocks(SCMatrixSubblockIter::Access)
Returns iterators for the local (rapidly accessible) blocks used in this vector.
Ref< SCMatrixSubblockIter > all_blocks(SCMatrixSubblockIter::Access)
Returns iterators for the all blocks used in this vector.
void accumulate(const SCVector *)
Sum v into this.
double get_element(int) const
Return the value of element i.
void assign_val(double)
Overridden to implement the assign functions.
double scalar_product(SCVector *)
Return the dot product.
void element_op(const Ref< SCElementOp > &)
Perform the element operation op on each element of this.
void accumulate_element(int, double)
Add val to element i.
Local SymmSCMatrix.
Definition local.h:158
double determ_this()
Return the determinant of this. this is overwritten.
Ref< SCMatrixSubblockIter > all_blocks(SCMatrixSubblockIter::Access)
Returns iterators for the all blocks used in this matrix.
SCMatrix * get_subblock(int, int, int, int)
Return a subblock of this.
SCVector * get_row(int i)
Return a row of this.
double invert_this()
Invert this.
Ref< SCMatrixSubblockIter > local_blocks(SCMatrixSubblockIter::Access)
Returns iterators for the local (rapidly accessible) blocks used in this matrix.
void assign_subblock(SCMatrix *, int, int, int, int)
Assign m to a subblock of this.
double scalar_product(SCVector *)
Return the scalar obtained by multiplying this on the left and right by v.
void gen_invert_this(double condition_number_threshold=1e8)
Return the generalized inverse of this using SVD decomposition.
void element_op(const Ref< SCElementOp > &)
only applied to the unique elements of this.
void assign_row(SCVector *v, int i)
Assign v to a row of this.
void accumulate(const SymmSCMatrix *)
Sum m into this.
void accumulate_symmetric_product(SCMatrix *)
Sum into this a * a.t()
void diagonalize(DiagSCMatrix *, SCMatrix *)
Diagonalize this, placing the eigenvalues in d and the eigenvectors in m.
void accumulate_row(SCVector *v, int i)
Sum v to a row of this.
double get_element(int, int) const
Return or modify an element.
double trace()
Return the trace.
void accumulate_symmetric_sum(SCMatrix *)
Sum into a + a.t()
void eigensystem(SymmSCMatrix *, DiagSCMatrix *, SCMatrix *)
Solve generalized eigensystem for this with metric s, placing the eigenvalues in d and the eigenvecto...
void accumulate_subblock(SCMatrix *, int, int, int, int)
Sum m into a subblock of this.
The RefSCDimension class is a smart pointer to an SCDimension specialization.
Definition dim.h:152
A template class that maintains references counts.
Definition ref.h:361
The SCMatrixKit abstract class acts as a factory for producing matrices.
Definition abstract.h:57
The SCMatrix class is the abstract base class for general double valued n by m matrices.
Definition abstract.h:199
Transform
types of matrix transforms. Only real-valued matrices are assumed.
Definition abstract.h:205
The SCVector class is the abstract base class for double valued vectors.
Definition abstract.h:97
Serializes fundamental and user-defined types.
Definition stateout.h:71
The SymmSCMatrix class is the abstract base class for symmetric double valued matrices.
Definition abstract.h:389
int n() const
Return the dimension.
Definition abstract.h:443
Contains all MPQC code up to version 3.
Definition mpqcin.h:14

Generated at Wed Sep 25 2024 02:45:30 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.12.0.