⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abstract.h

📁 大型并行量子化学软件;支持密度泛函(DFT)。可以进行各种量子化学计算。支持CHARMM并行计算。非常具有应用价值。
💻 H
📖 第 1 页 / 共 2 页
字号:
//// abstract.h//// Copyright (C) 1996 Limit Point Systems, Inc.//// Author: Curtis Janssen <cljanss@limitpt.com>// Maintainer: LPS//// This file is part of the SC Toolkit.//// The SC Toolkit is free software; you can redistribute it and/or modify// it under the terms of the GNU Library General Public License as published by// the Free Software Foundation; either version 2, or (at your option)// any later version.//// The SC Toolkit is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the// GNU Library General Public License for more details.//// You should have received a copy of the GNU Library General Public License// along with the SC Toolkit; see the file COPYING.LIB.  If not, write to// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.//// The U.S. Government is granted a limited license as per AL 91-7.//#ifndef _math_scmat_abstract_h#define _math_scmat_abstract_h#ifdef __GNUC__#pragma interface#endif#include <util/group/message.h>#include <util/state/state.h>#include <math/scmat/dim.h>#include <math/scmat/block.h>#include <iostream>namespace sc {class SCMatrix;class SymmSCMatrix;class DiagSCMatrix;class SCVector;class SCElementOp;class SCElementOp2;class SCElementOp3;class RefSCDimension;/** The SCMatrixKit abstract class acts as a factory for producingmatrices.  By using one of these, the program makes sure that all of thematrices are consistent.  */class SCMatrixKit: public DescribedClass {  protected:    Ref<MessageGrp> grp_;      public:    SCMatrixKit();    SCMatrixKit(const Ref<KeyVal>&);    ~SCMatrixKit();    // these members are default in local.cc    /** This returns a LocalSCMatrixKit, unless the        default has been changed with set_default_matrixkit. */    static SCMatrixKit* default_matrixkit();    static void set_default_matrixkit(const Ref<SCMatrixKit> &);    Ref<MessageGrp> messagegrp() const;    /// Given the dimensions, create matrices or vectors.    virtual SCMatrix* matrix(const RefSCDimension&,const RefSCDimension&) = 0;    virtual SymmSCMatrix* symmmatrix(const RefSCDimension&) = 0;    virtual DiagSCMatrix* diagmatrix(const RefSCDimension&) = 0;    virtual SCVector* vector(const RefSCDimension&) = 0;    /** Given the dimensions and a StateIn object,        restore matrices or vectors. */    SCMatrix* restore_matrix(StateIn&,                             const RefSCDimension&,                             const RefSCDimension&);    SymmSCMatrix* restore_symmmatrix(StateIn&,                                     const RefSCDimension&);    DiagSCMatrix* restore_diagmatrix(StateIn&,                                                  const RefSCDimension&);    SCVector* restore_vector(StateIn&,                             const RefSCDimension&);};/** The SCVector class is the abstract base class for    double valued vectors. */class SCVector: public DescribedClass {  protected:    RefSCDimension d;    Ref<SCMatrixKit> kit_;  public:    SCVector(const RefSCDimension&, SCMatrixKit *);    /// Save and restore this in an implementation independent way.    virtual void save(StateOut&);    virtual void restore(StateIn&);    /// Return the SCMatrixKit used to create this object.    Ref<SCMatrixKit> kit() const { return kit_; }    // concrete functions (some can be overridden)    /// Return a vector with the same dimension and same elements.    virtual SCVector* copy();    /// Return a vector with the same dimension but uninitialized memory.    virtual SCVector* clone();    virtual ~SCVector();    /// Return the length of the vector.    int n() const { return d->n(); }    /// Return the maximum absolute value element of this vector.    virtual double maxabs() const;    /// Normalize this.    virtual void normalize();    /// Assign each element to a random number between -1 and 1    virtual void randomize();    /// Assign all elements of this to val.    void assign(double val) { assign_val(val); }    /// Assign element i to v[i] for all i.    void assign(const double* v) { assign_p(v); }    /** Make this have the same elements as v.  The dimensions must        match. */    void assign(SCVector* v) { assign_v(v); }    /// Overridden to implement the assign functions.    virtual void assign_val(double val);    virtual void assign_p(const double* v);    virtual void assign_v(SCVector *v);    /// Assign v[i] to element i for all i.    virtual void convert(double* v) const;    /** Convert an SCVector of a different specialization        to this specialization and possibly accumulate the data. */    virtual void convert(SCVector*);    virtual void convert_accumulate(SCVector*);    /// Multiply each element by val.    virtual void scale(double val);    /// Return the RefSCDimension corresponding to this vector.    RefSCDimension dim() const { return d; }    /// Set element i to val.    virtual void set_element(int i,double val) = 0;    /// Add val to element i.    virtual void accumulate_element(int,double) = 0;    /// Return the value of element i.    virtual double get_element(int i) const = 0;    /// Sum the result of m times v into this.    void accumulate_product(SymmSCMatrix* m, SCVector* v)        { accumulate_product_sv(m,v); }    void accumulate_product(SCMatrix* m, SCVector* v)        {  accumulate_product_rv(m,v); }    virtual void accumulate_product_sv(SymmSCMatrix* m, SCVector* v);    virtual void accumulate_product_rv(SCMatrix* m, SCVector* v) = 0;    /// Sum v into this.    virtual void accumulate(const SCVector*v) = 0;    /// Sum m into this.  One of m's dimensions must be 1.    virtual void accumulate(const SCMatrix*m) = 0;    /// Return the dot product.    virtual double scalar_product(SCVector*) = 0;    /// Perform the element operation op on each element of this.    virtual void element_op(const Ref<SCElementOp>&) = 0;    virtual void element_op(const Ref<SCElementOp2>&,                            SCVector*) = 0;    virtual void element_op(const Ref<SCElementOp3>&,                            SCVector*,SCVector*) = 0;    /// Print out the vector.    void print(std::ostream&o=ExEnv::out0()) const;    void print(const char* title=0,std::ostream&out=ExEnv::out0(),int=10) const;    virtual void vprint(const char*title=0,std::ostream&out=ExEnv::out0(),                        int=10) const = 0;    /// Returns the message group used by the matrix kit    Ref<MessageGrp> messagegrp() const;        /** Returns iterators for the local (rapidly accessible) blocks used in        this vector.  Only one iterator is allowed for a matrix is it has        Accum or Write access is allowed.  Multiple Read iterators are        permitted. */    virtual Ref<SCMatrixSubblockIter> local_blocks(        SCMatrixSubblockIter::Access) = 0;    /// Returns iterators for the all blocks used in this vector.    virtual Ref<SCMatrixSubblockIter> all_blocks(SCMatrixSubblockIter::Access) = 0;};/** The SCMatrix class is the abstract base class for general double valued    n by m matrices.  For symmetric matrices use SymmSCMatrix and for    diagonal matrices use DiagSCMatrix. */class SCMatrix: public DescribedClass {  protected:    RefSCDimension d1,d2;    Ref<SCMatrixKit> kit_;  public:    // used to control transformations    enum Transform { NormalTransform = 0, TransposeTransform = 1 };        // concrete functions (some can be overridden)    SCMatrix(const RefSCDimension&, const RefSCDimension&, SCMatrixKit *);    virtual ~SCMatrix();    /// Save and restore this in an implementation independent way.    virtual void save(StateOut&);    virtual void restore(StateIn&);    /// Return the SCMatrixKit used to create this object.    Ref<SCMatrixKit> kit() const { return kit_; }    /// Return the number of rows.    int nrow() const { return d1->n(); }    /// Return the number of columns.    int ncol() const { return d2->n(); }    /// Return the maximum absolute value element.    virtual double maxabs() const;    /// Assign each element to a random number between -1 and 1    virtual void randomize();    /// Set all elements to val.    void assign(double val) { assign_val(val); }    /// Assign element i, j to m[ir*nrow()+j].    void assign(const double* m) { assign_p(m); }    /// Assign element i, j to m[i][j].    void assign(const double** m) { assign_pp(m); }    /// Make this have the same elements as m. The dimensions must match.    void assign(SCMatrix* m) { assign_r(m); }    /// Overridden to implement to assign members.    virtual void assign_val(double val);    virtual void assign_p(const double* m);    virtual void assign_pp(const double** m);    virtual void assign_r(SCMatrix* m);    /** Like the assign members, but these write values to the        arguments. */    virtual void convert(double*) const;    virtual void convert(double**) const;    /** Convert an SCMatrix of a different specialization to this        specialization and possibly accumulate the data. */    virtual void convert(SCMatrix*);    virtual void convert_accumulate(SCMatrix*);    /// Multiply all elements by val.    virtual void scale(double val);    /// Scale the diagonal elements by val.    virtual void scale_diagonal(double val);    /// Shift the diagonal elements by val.    virtual void shift_diagonal(double val);    /// Make this equal to the unit matrix.    virtual void unit();    /// Return a matrix with the same dimension and same elements.    virtual SCMatrix* copy();    /// Return a matrix with the same dimension but uninitialized memory.    virtual SCMatrix* clone();    // pure virtual functions    /// Return the row or column dimension.    RefSCDimension rowdim() const { return d1; }    RefSCDimension coldim() const { return d2; }    /// Return or modify an element.    virtual double get_element(int,int) const = 0;    virtual void set_element(int,int,double) = 0;    virtual void accumulate_element(int,int,double) = 0;        /** Return a subblock of this.  The subblock is defined as        the rows starting at br and ending at er, and the        columns beginning at bc and ending at ec. */    virtual SCMatrix * get_subblock(int br, int er, int bc, int ec) =0;    /// Assign m to a subblock of this.    virtual void assign_subblock(SCMatrix *m, int, int, int, int, int=0, int=0) =0;    /// Sum m into a subblock of this.    virtual void accumulate_subblock(SCMatrix *m, int, int, int, int, int=0,int=0) =0;        /// Return a row or column of this.    virtual SCVector * get_row(int i) =0;    virtual SCVector * get_column(int i) =0;    /// Assign v to a row or column of this.    virtual void assign_row(SCVector *v, int i) =0;    virtual void assign_column(SCVector *v, int i) =0;        /// Sum v to a row or column of this.    virtual void accumulate_row(SCVector *v, int i) =0;    virtual void accumulate_column(SCVector *v, int i) =0;        /// Sum m into this.    virtual void accumulate(const SCMatrix* m) = 0;    virtual void accumulate(const SymmSCMatrix* m) = 0;    virtual void accumulate(const DiagSCMatrix* m) = 0;    virtual void accumulate(const SCVector*) = 0;    /// Sum into this the products of various vectors or matrices.    virtual void accumulate_outer_product(SCVector*,SCVector*) = 0;    void accumulate_product(SCMatrix*m1,SCMatrix*m2)        { accumulate_product_rr(m1,m2); }    void accumulate_product(SCMatrix*m1,SymmSCMatrix*m2)        { accumulate_product_rs(m1,m2); }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -