📄 scmat.dox
字号:
/** \page scmat The Matrix LibraryThe scientific computing matrix library (SCMAT) is designed around a set ofmatrix abstractions that permit very general matrix implementations. Thisflexibility is needed to support diverse computing environments. Forexample, this library must support, at a minimum: simple matrices thatprovide efficient matrix computations in a uniprocessor environment,clusters of processors with enough memory to store all matrices connectedby a relatively slow network (workstations on an LAN), clusters ofprocessors with enough memory to store all matrices and a fast interconnectnetwork (a massively parallel machine such as the Intel Paragon), andclusters of machines that don't have enough memory to hold entire matrices.<ul> <li> \ref scmatover <li> \ref scmatdim <li> \ref scmatref <li> \ref scmatabstract <li> \ref scmatstor <li> \ref scmatop <li> \ref scmatopsp <li> \ref scmatlocal <li> \ref scmatrepl <li> \ref scmatdist <li> \ref scmatblocked</ul>\section scmatover OverviewThe design of SCMAT differs from other object-oriented matrix packages intwo important ways. First, the matrix classes are abstract base classes.No storage layout is defined and virtual function calls must be used toaccess individual matrix elements. This would have a negative performanceimpact if users needed to frequently access matrix elements. The interfaceto the matrix classes is hopefully rich enough to avoid individual matrixelement access for any computationally significant task. The second majordifference is that symmetric matrices do not inherit from matrices, etc.The SCMAT user must know whether a matrix is symmetric at all places it isused if any performance gain, by virtue of symmetry, is expected.Dimension information is contained objects of the SCDimension type. Inaddition to the simple integer dimension, application specific blockinginformation can be provided. For example, in a quantum chemistryapplication, the dimension corresponding to the atomic orbital basis setwill have block sizes that correspond to the shells. Dimensions are usedto create new matrix or vector objects.The primary abstract classes are SCMatrix, SymmSCMatrix, DiagSCMatrix, andSCVector. These represent matrices, symmetric matrices, diagonal matrices,and vectors, respectively. These abstract classes are specialized intogroups of classes. For example, the locally stored matrix implementationspecializes the abstract classes to LocalSCMatrix, LocalSymmSCMatrix,LocalDiagSCMatrix, LocalSCVector, LocalSCDimension, and LocalSCMatrixKit.These specializations are all designed to work with each other. However, agiven specialization is incompatible with other matrix specializations. Anattempt to multiply a local matrix by a distributed matrix would generatean error at runtime.Since the different groups of classes do not interoperate, some mechanismof creating consistent specializations is needed. This is done withSCMatrixKit objects. SCMatrixKit is an abstract base type which hasspecializations that correspond to each group of the matrixspecializations. It is used to create matrices and vectors from thatgroup. For example, the DistSCMatrixKit is used to create objects of typeDistSCMatrix, DistSymmSCMatrix, DistDiagSCMatrix, and DistSCVector.The abstract matrix classes and their derivations are usually not directlyused by SCMAT users. The most convenient classes to use are the smartpointer classes RefSCMatrix, RefSymmSCMatrix, RefDiagSCMatrix,and RefSCDimension.These classes respectively inherit from Ref<SCMatrix>, Ref<SymmSCMatrix>,Ref<DiagSCMatrix>, and Ref<SCDimension>, providing automatic memorymanagement through reference counting.The smart pointer classes also have matrixoperations such as operator *(), operator -(), and operator +() defined asmembers for convenience. These forward the operations to the containedmatrix object. The smart pointer classes also simplify creation ofmatrices by providing constructors that take as arguments one or moreRefSCDimension's and a Ref<SCMatrixKit>. These initialize the smart pointerto contain a new matrix with a specialization corresponding to that of theRef<SCMatrixKit>. Matrix operations not provided by the smart pointerclasses but present as member in the abstract classes can be accessed withoperator->().If a needed matrix operation is missing, mechanisms exist to add moregeneral operations. Operations which only depend on individual elements ofmatrices can be provided by specializations of the SCElementOp class.Sometimes we need operations on matrices with identical dimensions thatexamine each element in one matrix along with the corresponding elementfrom the other matrix. This is accomplished with SCElementOp2 for twomatrices and with SCElementOp3 for three.Other features of SCMAT include run-time type facilities and persistence.Castdown operations (type conversions from less to more derived objects)and other run-time type information are provided by the DescribedClass baseclass. Persistence is not provided by inheriting from SavableState baseclase as is the case with many other classes in the SC class hierarchies,because it is necessary to save objects in an implementation independentmanner. If a calculation checkpoints a matrix on a single processormachine and later is restarted on a multiprocessor machine the matrix wouldneed to be restored as a different matrix specialization. This is handledby saving and restoring matrices' and vectors' data without reference tothe specialization.The following include files are provided by the matrix library:<dl><dt><tt>matrix.h</tt><dd>Usually, this is the only include file needed by users of matrices. Itdeclares reference counting pointers to abstract matrices.If kit for a matrix must be created, or a member specific to animplementation is needed, then that implementation's header file must beincluded.<dt><tt>elemop.h</tt><dd>This is the next most useful include file. It defines usefulSCElementOp, SCElementOp2, and SCElementOp3specializations.<dt><tt>abstract.h</tt><dd>This include file contains the declarations for abstract classes thatusers do not usually need to see. These include SCDimension,SCMatrix, SymmSCMatrix, DiagSCMatrix,SCMatrixKit. This file is currently included bymatrix.h.<dt><tt>block.h</tt><dd>This file declares SCMatrixBlock and specializations. Itonly need be include by users implementing new SCElementOpspecializations.<dt><tt>blkiter.h</tt><dd>This include file declares the implementations ofSCMatrixBlockIter. It only need be include by users implementingnew SCElementOp specializations.<dt><tt>vector3.h</tt><dd>This declares SCVector3, a lightweight vector of length three.<dt><tt>matrix3.h</tt><dd>This declares SCMatrix3, a lightweight matrix of dimension three bythree. It includes vector3.h.<dt><tt>local.h</tt><dd>This include file is the matrix implementation for locally storedmatrices. These are suitable for use in a uniprocessor environment. TheLocalSCMatrixKit is the default matrix implementation returnedby the static member SCMatrixKit::default_matrixkit.This file usually doesn't need to be included.<dt><tt>dist.h</tt><dd>This include file is the matrix implementation for distributed matrices.These are suitable for use in a distributed memory multiprocessor whichdoes not have enough memory to hold all of the matrix elements on eachprocessor. This file usually doesn't need to be included.<dt><tt>repl.h</tt><dd>This include file is the matrix implementation for replicated matrices.These are suitable for use in a distributed memory multiprocessor whichdoes have enough memory to hold all of the matrix elements on eachprocessor. This file usually doesn't need to be included.<dt><tt>blocked.h</tt><dd>This include file is the matrix implementation for blocked matrices.Blocked matrices store a matrix as subblocks that are matrices from anothermatrix specialization. These are used to save storage and computation timein quantum chemistry applications for molecules with other than \f$C_1\f$ pointgroup symmetry.</dl>\section scmatdim Matrix DimensionsIn addition to the simple integer dimension, objects of the SCDimensionclass contain application specific blocking information. This informationis held in an object of class SCBlockInfo.\section scmatref Matrix Reference ClassesThe easiest way to use SCMAT is through the smart pointer classesRefSCMatrix, RefSymmSCMatrix, RefDiagSCMatrix, RefSCVector, RefSCDimension,and Ref<SCMatrixKit>. These are based on the Ref reference counting packageand automatically delete matrix objects when they are no longer needed.These reference classes also have common operations defined as members forconvenience. This makes it unnecessary to also use the sometimes awkwardsyntax of operator->() to manipulate the contained objects.\section scmatabstract Abstract Matrix ClassesThis section documents the primary abstract classes: SCMatrix,SymmSCMatrix, DiagSCMatrix, and SCVector, as well as the SCMatrixKit classwhich allows the programmer to generate consistent specializations ofmatrices. These represent matrices, symmetric matrices, diagonal matrices,and vectors, respectively.This section is primarily for implementers of new specializationsof matrices. Users of existing matrices will be most interestedin the matrix reference classes.\section scmatstor Matrix StorageAll elements of matrices and vectors are kept in blocks. Thechoice of blocks and where they are keep is left up to eachmatrix specialization.\section scmatop Manipulating Matrix Elements with Element OperationsThe SCElementOp, SCElementOp2, and SCElementOp3 classes canbe used to maniupulate matrix elements.\section scmatopsp SCElementOp SpecializationsSeveral commonly needed element operations are already coded up andavailable by including math/scmat/elemop.h. Below are descriptionsof these classes:<dl><dt>SCElementScalarProduct<dd> This SCElementOp2 computesthe scalar product of two matrices or vectors. The result is availableafter the operation from the return value of the result() member.<dt>SCDestructiveElementProduct<dd> This SCElementOp2replaces the elements of the matrix or vector whose element_opmember is called. The resulting values are the element by element productsof the two matrices or vectors.<dt>SCElementScale<dd> This scales each element by an amount givenin the constructor.<dt>SCElementRandomize<dd> This generates random elements.<dt>SCElementAssign<dd> Assign to each element the value passed tothe constructor.<dt>SCElementSquareRoot<dd> Replace each element with its squareroot.<dt>SCElementInvert<dd> Replace each element by its reciprocal.<dt>SCElementScaleDiagonal<dd> Scales the diagonal elements of amatrix by the argument passed to the constructor. Use of this on a vectoris undefined.<dt>SCElementShiftDiagonal<dd> Add the value passed to theconstructor to the diagonal elements of the matrix. Use of this on avector is undefined.<dt>SCElementMaxAbs<dd> Find the maximum absolute value element in amatrix or vector. The result is available as the return value of the<tt>result()</tt> member.<dt>SCElementDot<dd> The constructor for this class takes threearguments: SCElementDot(double**a,double**b, int length). The length of each vector given bya and b is given by length. The number of vectors ina is the number of rows in the matrix and the number in b isthe number of columns. To each element in the matrix \f$m_{ij}\f$ the dotproduct of the \f$a_i\f$ and \f$b_j\f$ is added.<dt>SCElementAccumulateSCMatrix<dd> This is obsolete---do not use it.<dt>SCElementAccumulateSymmSCMatrix<dd> This is obsolete---do notuse it.<dt>SCElementAccumulateDiagSCMatrix<dd> This is obsolete---do notuse it.<dt>SCElementAccumulateSCVector<dd> This is obsolete---do not useit.</dl>\section scmatlocal Local MatricesLocal matrices do no communication. All elements reside on each nodeand all computations are duplicated on each node.\section scmatrepl Replicated MatricesReplicated matrices hold all of the elements on each node, howeverdo some communications in order to reduce computation time.\section scmatdist Distributed MatricesDistributed matrices spread the elements across all the nodes andthus require less storage than local matrices however these usemore communications than replicated matrices.\section scmatblocked Blocked MatricesBlocked matrices are used to implement point group symmetry. Anothermatrix specialization is used to hold the diagonal subblocks of amatrix. The offdiagonal subblocks are known to be zero and not stored.This results in considerable savings in storage and computation forthose cases where it applies.*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -