| [5d30c1] | 1 | 
 | 
|---|
 | 2 | /** \page scmat The Matrix Library
 | 
|---|
 | 3 | 
 | 
|---|
 | 4 | The scientific computing matrix library (SCMAT) is designed around a set of
 | 
|---|
 | 5 | matrix abstractions that permit very general matrix implementations.  This
 | 
|---|
 | 6 | flexibility is needed to support diverse computing environments.  For
 | 
|---|
 | 7 | example, this library must support, at a minimum: simple matrices that
 | 
|---|
 | 8 | provide efficient matrix computations in a uniprocessor environment,
 | 
|---|
 | 9 | clusters of processors with enough memory to store all matrices connected
 | 
|---|
 | 10 | by a relatively slow network (workstations on an LAN), clusters of
 | 
|---|
 | 11 | processors with enough memory to store all matrices and a fast interconnect
 | 
|---|
 | 12 | network (a massively parallel machine such as the Intel Paragon), and
 | 
|---|
 | 13 | clusters of machines that don't have enough memory to hold entire matrices.
 | 
|---|
 | 14 | 
 | 
|---|
 | 15 | <ul>
 | 
|---|
 | 16 |   <li> \ref scmatover
 | 
|---|
 | 17 |   <li> \ref scmatdim
 | 
|---|
 | 18 |   <li> \ref scmatref
 | 
|---|
 | 19 |   <li> \ref scmatabstract
 | 
|---|
 | 20 |   <li> \ref scmatstor
 | 
|---|
 | 21 |   <li> \ref scmatop
 | 
|---|
 | 22 |   <li> \ref scmatopsp
 | 
|---|
 | 23 |   <li> \ref scmatlocal
 | 
|---|
 | 24 |   <li> \ref scmatrepl
 | 
|---|
 | 25 |   <li> \ref scmatdist
 | 
|---|
 | 26 |   <li> \ref scmatblocked
 | 
|---|
 | 27 | </ul>
 | 
|---|
 | 28 | 
 | 
|---|
 | 29 | \section scmatover Overview
 | 
|---|
 | 30 | 
 | 
|---|
 | 31 | The design of SCMAT differs from other object-oriented matrix packages in
 | 
|---|
 | 32 | two important ways.  First, the matrix classes are abstract base classes.
 | 
|---|
 | 33 | No storage layout is defined and virtual function calls must be used to
 | 
|---|
 | 34 | access individual matrix elements.  This would have a negative performance
 | 
|---|
 | 35 | impact if users needed to frequently access matrix elements.  The interface
 | 
|---|
 | 36 | to the matrix classes is hopefully rich enough to avoid individual matrix
 | 
|---|
 | 37 | element access for any computationally significant task.  The second major
 | 
|---|
 | 38 | difference is that symmetric matrices do not inherit from matrices, etc.
 | 
|---|
 | 39 | The SCMAT user must know whether a matrix is symmetric at all places it is
 | 
|---|
 | 40 | used if any performance gain, by virtue of symmetry, is expected.
 | 
|---|
 | 41 | 
 | 
|---|
 | 42 | Dimension information is contained objects of the SCDimension type.  In
 | 
|---|
 | 43 | addition to the simple integer dimension, application specific blocking
 | 
|---|
 | 44 | information can be provided.  For example, in a quantum chemistry
 | 
|---|
 | 45 | application, the dimension corresponding to the atomic orbital basis set
 | 
|---|
 | 46 | will have block sizes that correspond to the shells.  Dimensions are used
 | 
|---|
 | 47 | to create new matrix or vector objects.
 | 
|---|
 | 48 | 
 | 
|---|
 | 49 | The primary abstract classes are SCMatrix, SymmSCMatrix, DiagSCMatrix, and
 | 
|---|
 | 50 | SCVector.  These represent matrices, symmetric matrices, diagonal matrices,
 | 
|---|
 | 51 | and vectors, respectively.  These abstract classes are specialized into
 | 
|---|
 | 52 | groups of classes.  For example, the locally stored matrix implementation
 | 
|---|
 | 53 | specializes the abstract classes to LocalSCMatrix, LocalSymmSCMatrix,
 | 
|---|
 | 54 | LocalDiagSCMatrix, LocalSCVector, LocalSCDimension, and LocalSCMatrixKit.
 | 
|---|
 | 55 | These specializations are all designed to work with each other.  However, a
 | 
|---|
 | 56 | given specialization is incompatible with other matrix specializations.  An
 | 
|---|
 | 57 | attempt to multiply a local matrix by a distributed matrix would generate
 | 
|---|
 | 58 | an error at runtime.
 | 
|---|
 | 59 | 
 | 
|---|
 | 60 | Since the different groups of classes do not interoperate, some mechanism
 | 
|---|
 | 61 | of creating consistent specializations is needed.  This is done with
 | 
|---|
 | 62 | SCMatrixKit objects.  SCMatrixKit is an abstract base type which has
 | 
|---|
 | 63 | specializations that correspond to each group of the matrix
 | 
|---|
 | 64 | specializations.  It is used to create matrices and vectors from that
 | 
|---|
 | 65 | group.  For example, the DistSCMatrixKit is used to create objects of type
 | 
|---|
 | 66 | DistSCMatrix, DistSymmSCMatrix, DistDiagSCMatrix, and DistSCVector.
 | 
|---|
 | 67 | 
 | 
|---|
 | 68 | The abstract matrix classes and their derivations are usually not directly
 | 
|---|
 | 69 | used by SCMAT users.  The most convenient classes to use are the smart
 | 
|---|
 | 70 | pointer classes RefSCMatrix, RefSymmSCMatrix, RefDiagSCMatrix,
 | 
|---|
 | 71 | and RefSCDimension.
 | 
|---|
 | 72 | These classes respectively inherit from Ref<SCMatrix>, Ref<SymmSCMatrix>,
 | 
|---|
 | 73 | Ref<DiagSCMatrix>, and Ref<SCDimension>, providing automatic memory
 | 
|---|
 | 74 | management through reference counting.
 | 
|---|
 | 75 | The smart pointer classes also have matrix
 | 
|---|
 | 76 | operations such as operator *(), operator -(), and operator +() defined as
 | 
|---|
 | 77 | members for convenience.  These forward the operations to the contained
 | 
|---|
 | 78 | matrix object.  The smart pointer classes also simplify creation of
 | 
|---|
 | 79 | matrices by providing constructors that take as arguments one or more
 | 
|---|
 | 80 | RefSCDimension's and a Ref<SCMatrixKit>.  These initialize the smart pointer
 | 
|---|
 | 81 | to contain a new matrix with a specialization corresponding to that of the
 | 
|---|
 | 82 | Ref<SCMatrixKit>.  Matrix operations not provided by the smart pointer
 | 
|---|
 | 83 | classes but present as member in the abstract classes can be accessed with
 | 
|---|
 | 84 | operator->().
 | 
|---|
 | 85 | 
 | 
|---|
 | 86 | If a needed matrix operation is missing, mechanisms exist to add more
 | 
|---|
 | 87 | general operations.  Operations which only depend on individual elements of
 | 
|---|
 | 88 | matrices can be provided by specializations of the SCElementOp class.
 | 
|---|
 | 89 | Sometimes we need operations on matrices with identical dimensions that
 | 
|---|
 | 90 | examine each element in one matrix along with the corresponding element
 | 
|---|
 | 91 | from the other matrix.  This is accomplished with SCElementOp2 for two
 | 
|---|
 | 92 | matrices and with SCElementOp3 for three.
 | 
|---|
 | 93 | 
 | 
|---|
 | 94 | Other features of SCMAT include run-time type facilities and persistence.
 | 
|---|
 | 95 | Castdown operations (type conversions from less to more derived objects)
 | 
|---|
 | 96 | and other run-time type information are provided by the DescribedClass base
 | 
|---|
 | 97 | class.  Persistence is not provided by inheriting from SavableState base
 | 
|---|
 | 98 | clase as is the case with many other classes in the SC class hierarchies,
 | 
|---|
 | 99 | because it is necessary to save objects in an implementation independent
 | 
|---|
 | 100 | manner.  If a calculation checkpoints a matrix on a single processor
 | 
|---|
 | 101 | machine and later is restarted on a multiprocessor machine the matrix would
 | 
|---|
 | 102 | need to be restored as a different matrix specialization.  This is handled
 | 
|---|
 | 103 | by saving and restoring matrices' and vectors' data without reference to
 | 
|---|
 | 104 | the specialization.
 | 
|---|
 | 105 | 
 | 
|---|
 | 106 | The following include files are provided by the matrix library:
 | 
|---|
 | 107 | 
 | 
|---|
 | 108 | <dl>
 | 
|---|
 | 109 | <dt><tt>matrix.h</tt><dd>
 | 
|---|
 | 110 | Usually, this is the only include file needed by users of matrices.  It
 | 
|---|
 | 111 | declares reference counting pointers to abstract matrices.
 | 
|---|
 | 112 | 
 | 
|---|
 | 113 | If kit for a matrix must be created, or a member specific to an
 | 
|---|
 | 114 | implementation is needed, then that implementation's header file must be
 | 
|---|
 | 115 | included.
 | 
|---|
 | 116 | 
 | 
|---|
 | 117 | <dt><tt>elemop.h</tt><dd>
 | 
|---|
 | 118 | This is the next most useful include file.  It defines useful
 | 
|---|
 | 119 | SCElementOp, SCElementOp2, and SCElementOp3
 | 
|---|
 | 120 | specializations.
 | 
|---|
 | 121 | 
 | 
|---|
 | 122 | <dt><tt>abstract.h</tt><dd>
 | 
|---|
 | 123 | This include file contains the declarations for abstract classes that
 | 
|---|
 | 124 | users do not usually need to see.  These include SCDimension,
 | 
|---|
 | 125 | SCMatrix, SymmSCMatrix, DiagSCMatrix,
 | 
|---|
 | 126 | SCMatrixKit.  This file is currently included by
 | 
|---|
 | 127 | matrix.h.
 | 
|---|
 | 128 | 
 | 
|---|
 | 129 | <dt><tt>block.h</tt><dd>
 | 
|---|
 | 130 | This file declares SCMatrixBlock and specializations.  It
 | 
|---|
 | 131 | only need be include by users implementing new SCElementOp
 | 
|---|
 | 132 | specializations.
 | 
|---|
 | 133 | 
 | 
|---|
 | 134 | <dt><tt>blkiter.h</tt><dd>
 | 
|---|
 | 135 | This include file declares the implementations of
 | 
|---|
 | 136 | SCMatrixBlockIter.  It only need be include by users implementing
 | 
|---|
 | 137 | new SCElementOp specializations.
 | 
|---|
 | 138 | 
 | 
|---|
 | 139 | <dt><tt>vector3.h</tt><dd>
 | 
|---|
 | 140 | This declares SCVector3, a lightweight vector of length three.
 | 
|---|
 | 141 | 
 | 
|---|
 | 142 | <dt><tt>matrix3.h</tt><dd>
 | 
|---|
 | 143 | This declares SCMatrix3, a lightweight matrix of dimension three by
 | 
|---|
 | 144 | three.  It includes vector3.h.
 | 
|---|
 | 145 | 
 | 
|---|
 | 146 | <dt><tt>local.h</tt><dd>
 | 
|---|
 | 147 | This include file is the matrix implementation for locally stored
 | 
|---|
 | 148 | matrices.  These are suitable for use in a uniprocessor environment.  The
 | 
|---|
 | 149 | LocalSCMatrixKit is the default matrix implementation returned
 | 
|---|
 | 150 | by the static member SCMatrixKit::default_matrixkit.
 | 
|---|
 | 151 | This file usually doesn't need to be included.
 | 
|---|
 | 152 | 
 | 
|---|
 | 153 | <dt><tt>dist.h</tt><dd>
 | 
|---|
 | 154 | This include file is the matrix implementation for distributed matrices.
 | 
|---|
 | 155 | These are suitable for use in a distributed memory multiprocessor which
 | 
|---|
 | 156 | does not have enough memory to hold all of the matrix elements on each
 | 
|---|
 | 157 | processor.  This file usually doesn't need to be included.
 | 
|---|
 | 158 | 
 | 
|---|
 | 159 | <dt><tt>repl.h</tt><dd>
 | 
|---|
 | 160 | This include file is the matrix implementation for replicated matrices.
 | 
|---|
 | 161 | These are suitable for use in a distributed memory multiprocessor which
 | 
|---|
 | 162 | does have enough memory to hold all of the matrix elements on each
 | 
|---|
 | 163 | processor.  This file usually doesn't need to be included.
 | 
|---|
 | 164 | 
 | 
|---|
 | 165 | <dt><tt>blocked.h</tt><dd>
 | 
|---|
 | 166 | This include file is the matrix implementation for blocked matrices.
 | 
|---|
 | 167 | Blocked matrices store a matrix as subblocks that are matrices from another
 | 
|---|
 | 168 | matrix specialization.  These are used to save storage and computation time
 | 
|---|
 | 169 | in quantum chemistry applications for molecules with other than \f$C_1\f$ point
 | 
|---|
 | 170 | group symmetry.
 | 
|---|
 | 171 | 
 | 
|---|
 | 172 | </dl>
 | 
|---|
 | 173 | 
 | 
|---|
 | 174 | \section scmatdim Matrix Dimensions
 | 
|---|
 | 175 | 
 | 
|---|
 | 176 | In addition to the simple integer dimension, objects of the SCDimension
 | 
|---|
 | 177 | class contain application specific blocking information.  This information
 | 
|---|
 | 178 | is held in an object of class SCBlockInfo.
 | 
|---|
 | 179 | 
 | 
|---|
 | 180 | \section scmatref Matrix Reference Classes
 | 
|---|
 | 181 | 
 | 
|---|
 | 182 | The easiest way to use SCMAT is through the smart pointer classes
 | 
|---|
 | 183 | RefSCMatrix, RefSymmSCMatrix, RefDiagSCMatrix, RefSCVector, RefSCDimension,
 | 
|---|
 | 184 | and Ref<SCMatrixKit>.  These are based on the Ref reference counting package
 | 
|---|
 | 185 | and automatically delete matrix objects when they are no longer needed.
 | 
|---|
 | 186 | These reference classes also have common operations defined as members for
 | 
|---|
 | 187 | convenience.  This makes it unnecessary to also use the sometimes awkward
 | 
|---|
 | 188 | syntax of operator->() to manipulate the contained objects.
 | 
|---|
 | 189 | 
 | 
|---|
 | 190 | \section scmatabstract Abstract Matrix Classes
 | 
|---|
 | 191 | 
 | 
|---|
 | 192 | This section documents the primary abstract classes: SCMatrix,
 | 
|---|
 | 193 | SymmSCMatrix, DiagSCMatrix, and SCVector, as well as the SCMatrixKit class
 | 
|---|
 | 194 | which allows the programmer to generate consistent specializations of
 | 
|---|
 | 195 | matrices.  These represent matrices, symmetric matrices, diagonal matrices,
 | 
|---|
 | 196 | and vectors, respectively.
 | 
|---|
 | 197 | 
 | 
|---|
 | 198 | This section is primarily for implementers of new specializations
 | 
|---|
 | 199 | of matrices.  Users of existing matrices will be most interested
 | 
|---|
 | 200 | in the matrix reference classes.
 | 
|---|
 | 201 | 
 | 
|---|
 | 202 | \section scmatstor Matrix Storage
 | 
|---|
 | 203 | 
 | 
|---|
 | 204 | All elements of matrices and vectors are kept in blocks.  The
 | 
|---|
 | 205 | choice of blocks and where they are keep is left up to each
 | 
|---|
 | 206 | matrix specialization.
 | 
|---|
 | 207 | 
 | 
|---|
 | 208 | \section scmatop Manipulating Matrix Elements with Element Operations
 | 
|---|
 | 209 | 
 | 
|---|
 | 210 | The SCElementOp, SCElementOp2, and SCElementOp3 classes can
 | 
|---|
 | 211 | be used to maniupulate matrix elements.
 | 
|---|
 | 212 | 
 | 
|---|
 | 213 | \section scmatopsp SCElementOp Specializations
 | 
|---|
 | 214 | 
 | 
|---|
 | 215 | Several commonly needed element operations are already coded up and
 | 
|---|
 | 216 | available by including math/scmat/elemop.h.  Below are descriptions
 | 
|---|
 | 217 | of these classes:
 | 
|---|
 | 218 | 
 | 
|---|
 | 219 | <dl>
 | 
|---|
 | 220 | <dt>SCElementScalarProduct<dd> This SCElementOp2 computes
 | 
|---|
 | 221 | the scalar product of two matrices or vectors.  The result is available
 | 
|---|
 | 222 | after the operation from the return value of the result() member.
 | 
|---|
 | 223 | <dt>SCDestructiveElementProduct<dd> This SCElementOp2
 | 
|---|
 | 224 | replaces the elements of the matrix or vector whose element_op
 | 
|---|
 | 225 | member is called.  The resulting values are the element by element products
 | 
|---|
 | 226 | of the two matrices or vectors.
 | 
|---|
 | 227 | <dt>SCElementScale<dd> This scales each element by an amount given
 | 
|---|
 | 228 | in the constructor.
 | 
|---|
 | 229 | <dt>SCElementRandomize<dd> This generates random elements.
 | 
|---|
 | 230 | <dt>SCElementAssign<dd> Assign to each element the value passed to
 | 
|---|
 | 231 | the constructor.
 | 
|---|
 | 232 | <dt>SCElementSquareRoot<dd> Replace each element with its square
 | 
|---|
 | 233 | root.
 | 
|---|
 | 234 | <dt>SCElementInvert<dd> Replace each element by its reciprocal.
 | 
|---|
 | 235 | <dt>SCElementScaleDiagonal<dd> Scales the diagonal elements of a
 | 
|---|
 | 236 | matrix by the argument passed to the constructor.  Use of this on a vector
 | 
|---|
 | 237 | is undefined.
 | 
|---|
 | 238 | <dt>SCElementShiftDiagonal<dd> Add the value passed to the
 | 
|---|
 | 239 | constructor to the diagonal elements of the matrix.  Use of this on a
 | 
|---|
 | 240 | vector is undefined.
 | 
|---|
 | 241 | <dt>SCElementMaxAbs<dd> Find the maximum absolute value element in a
 | 
|---|
 | 242 | matrix or vector.  The result is available as the return value of the
 | 
|---|
 | 243 | <tt>result()</tt> member.
 | 
|---|
 | 244 | <dt>SCElementDot<dd> The constructor for this class takes three
 | 
|---|
 | 245 | arguments: SCElementDot(double**a,
 | 
|---|
 | 246 | double**b, int length).  The length of each vector given by
 | 
|---|
 | 247 | a and b is given by length.  The number of vectors in
 | 
|---|
 | 248 | a is the number of rows in the matrix and the number in b is
 | 
|---|
 | 249 | the number of columns.  To each element in the matrix \f$m_{ij}\f$ the dot
 | 
|---|
 | 250 | product of the \f$a_i\f$ and \f$b_j\f$ is added.
 | 
|---|
 | 251 | <dt>SCElementAccumulateSCMatrix<dd>  This is obsolete---do not use it.
 | 
|---|
 | 252 | <dt>SCElementAccumulateSymmSCMatrix<dd> This is obsolete---do not
 | 
|---|
 | 253 | use it.
 | 
|---|
 | 254 | <dt>SCElementAccumulateDiagSCMatrix<dd> This is obsolete---do not
 | 
|---|
 | 255 | use it.
 | 
|---|
 | 256 | <dt>SCElementAccumulateSCVector<dd> This is obsolete---do not use
 | 
|---|
 | 257 | it.
 | 
|---|
 | 258 | </dl>
 | 
|---|
 | 259 | 
 | 
|---|
 | 260 | \section scmatlocal Local Matrices
 | 
|---|
 | 261 | 
 | 
|---|
 | 262 | Local matrices do no communication.  All elements reside on each node
 | 
|---|
 | 263 | and all computations are duplicated on each node.
 | 
|---|
 | 264 | 
 | 
|---|
 | 265 | \section scmatrepl Replicated Matrices
 | 
|---|
 | 266 | 
 | 
|---|
 | 267 | Replicated matrices hold all of the elements on each node, however
 | 
|---|
 | 268 | do some communications in order to reduce computation time.
 | 
|---|
 | 269 | 
 | 
|---|
 | 270 | \section scmatdist Distributed Matrices
 | 
|---|
 | 271 | 
 | 
|---|
 | 272 | Distributed matrices spread the elements across all the nodes and
 | 
|---|
 | 273 | thus require less storage than local matrices however these use
 | 
|---|
 | 274 | more communications than replicated matrices.
 | 
|---|
 | 275 | 
 | 
|---|
 | 276 | \section scmatblocked Blocked Matrices
 | 
|---|
 | 277 | 
 | 
|---|
 | 278 | Blocked matrices are used to implement point group symmetry.  Another
 | 
|---|
 | 279 | matrix specialization is used to hold the diagonal subblocks of a
 | 
|---|
 | 280 | matrix.  The offdiagonal subblocks are known to be zero and not stored.
 | 
|---|
 | 281 | This results in considerable savings in storage and computation for
 | 
|---|
 | 282 | those cases where it applies.
 | 
|---|
 | 283 | 
 | 
|---|
 | 284 | */
 | 
|---|