Main Page Class Hierarchy Compound List File List Compound Members Related Pages

# local.h

    00001 //
    00002 // local.h
    00003 //
    00004 // Copyright (C) 1996 Limit Point Systems, Inc.
    00005 //
    00006 // Author: Curtis Janssen <cljanss@limitpt.com>
    00007 // Maintainer: LPS
    00008 //
    00009 // This file is part of the SC Toolkit.
    00010 //
    00011 // The SC Toolkit is free software; you can redistribute it and/or modify
    00012 // it under the terms of the GNU Library General Public License as published by
    00013 // the Free Software Foundation; either version 2, or (at your option)
    00014 // any later version.
    00015 //
    00016 // The SC Toolkit is distributed in the hope that it will be useful,
    00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00019 // GNU Library General Public License for more details.
    00020 //
    00021 // You should have received a copy of the GNU Library General Public License
    00022 // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
    00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
    00024 //
    00025 // The U.S. Government is granted a limited license as per AL 91-7.
    00026 //
    00027
    00028 #ifdef __GNUC__
    00029 #pragma interface
    00030 #endif
    00031
    00032 #ifndef _math_scmat_local_h
    00033 #define _math_scmat_local_h
    00034
    00035 #include <math/scmat/block.h>
    00036 #include <math/scmat/matrix.h>
    00037 #include <math/scmat/abstract.h>
    00038
    00039 namespace sc {
    00040
    00041 class LocalSCMatrixKit;
    00042 class LocalSCVector;
    00043 class LocalSCMatrix;
    00044 class LocalSymmSCMatrix;
    00045 class LocalDiagSCMatrix;
    00046
    00049 class LocalSCMatrixKit: public SCMatrixKit {
    00050   public:
    00051     LocalSCMatrixKit();
    00052     LocalSCMatrixKit(const Ref<KeyVal>&);
    00053     ~LocalSCMatrixKit();
    00054     SCMatrix* matrix(const RefSCDimension&,const RefSCDimension&);
    00055     SymmSCMatrix* symmmatrix(const RefSCDimension&);
    00056     DiagSCMatrix* diagmatrix(const RefSCDimension&);
    00057     SCVector* vector(const RefSCDimension&);
    00058 };
    00059
    00060 class LocalSCVector: public SCVector {
    00061     friend class LocalSCMatrix;
    00062     friend class LocalSymmSCMatrix;
    00063     friend class LocalDiagSCMatrix;
    00064   private:
    00065     Ref<SCVectorSimpleBlock> block;
    00066
    00067     void resize(int);
    00068   public:
    00069     LocalSCVector();
    00070     LocalSCVector(const RefSCDimension&,LocalSCMatrixKit*);
    00071     ~LocalSCVector();
    00072     void assign_val(double);
    00073     void assign_v(SCVector*);
    00074     void assign_p(const double*);
    00075
    00076     void set_element(int,double);
    00077     void accumulate_element(int,double);
    00078     double get_element(int) const;
    00079     void accumulate_product_sv(SymmSCMatrix*,SCVector*);
    00080     void accumulate_product_rv(SCMatrix*,SCVector*);
    00081     void accumulate(const SCVector*);
    00082     void accumulate(const SCMatrix*);
    00083     double scalar_product(SCVector*);
    00084     void element_op(const Ref<SCElementOp>&);
    00085     void element_op(const Ref<SCElementOp2>&,
    00086                     SCVector*);
    00087     void element_op(const Ref<SCElementOp3>&,
    00088                     SCVector*,SCVector*);
    00089     void vprint(const char* title=0,
    00090                 std::ostream& out=ExEnv::out0(), int =10) const;
    00091
    00092     // return a pointer to the data for fast access
    00093     double *get_data();
    00094
    00095     Ref<SCMatrixSubblockIter> local_blocks(SCMatrixSubblockIter::Access);
    00096     Ref<SCMatrixSubblockIter> all_blocks(SCMatrixSubblockIter::Access);
    00097 };
    00098
    00099 class LocalSCMatrix: public SCMatrix {
    00100     friend class LocalSymmSCMatrix;
    00101     friend class LocalDiagSCMatrix;
    00102     friend class LocalSCVector;
    00103   private:
    00104     Ref<SCMatrixRectBlock> block;
    00105     double** rows;
    00106   private:
    00107     // utility functions
    00108     int compute_offset(int,int) const;
    00109     void resize(int,int);
    00110   public:
    00111     LocalSCMatrix(const RefSCDimension&,const RefSCDimension&,
    00112                   LocalSCMatrixKit*);
    00113     ~LocalSCMatrix();
    00114
    00115     // implementations and overrides of virtual functions
    00116     void assign_val(double);
    00117     double get_element(int,int) const;
    00118     void set_element(int,int,double);
    00119     void accumulate_element(int,int,double);
    00120     SCMatrix * get_subblock(int,int,int,int);
    00121     void assign_subblock(SCMatrix*, int,int,int,int,int=0,int=0);
    00122     void accumulate_subblock(SCMatrix*, int,int,int,int,int=0,int=0);
    00123     SCVector * get_row(int i);
    00124     SCVector * get_column(int i);
    00125     void assign_row(SCVector *v, int i);
    00126     void assign_column(SCVector *v, int i);
    00127     void accumulate_row(SCVector *v, int i);
    00128     void accumulate_column(SCVector *v, int i);
    00129     void accumulate_outer_product(SCVector*,SCVector*);
    00130     void accumulate_product_rr(SCMatrix*,SCMatrix*);
    00131     void accumulate_product_rs(SCMatrix*,SymmSCMatrix*);
    00132     void accumulate_product_rd(SCMatrix*,DiagSCMatrix*);
    00133     void accumulate(const SCMatrix*);
    00134     void accumulate(const SymmSCMatrix*);
    00135     void accumulate(const DiagSCMatrix*);
    00136     void accumulate(const SCVector*);
    00137     void transpose_this();
    00138     double invert_this();
    00139     void svd_this(SCMatrix *U, DiagSCMatrix *sigma, SCMatrix *V);
    00140     double solve_this(SCVector*);
    00141     double determ_this();
    00142     double trace();
    00143     void schmidt_orthog(SymmSCMatrix*,int);
    00144     int schmidt_orthog_tol(SymmSCMatrix*, double tol, double *res=0);
    00145     void element_op(const Ref<SCElementOp>&);
    00146     void element_op(const Ref<SCElementOp2>&,
    00147                     SCMatrix*);
    00148     void element_op(const Ref<SCElementOp3>&,
    00149                     SCMatrix*,SCMatrix*);
    00150     void vprint(const char* title=0,
    00151                 std::ostream& out=ExEnv::out0(), int =10) const;
    00152
    00153     // return a pointer to the data for fast access
    00154     double *get_data();
    00155     double **get_rows();
    00156
    00157     Ref<SCMatrixSubblockIter> local_blocks(SCMatrixSubblockIter::Access);
    00158     Ref<SCMatrixSubblockIter> all_blocks(SCMatrixSubblockIter::Access);
    00159 };
    00160
    00161 class LocalSymmSCMatrix: public SymmSCMatrix {
    00162     friend class LocalSCMatrix;
    00163     friend class LocalDiagSCMatrix;
    00164     friend class LocalSCVector;
    00165   private:
    00166     Ref<SCMatrixLTriBlock> block;
    00167     double** rows;
    00168   private:
    00169     // utility functions
    00170     int compute_offset(int,int) const;
    00171     void resize(int n);
    00172   public:
    00173     LocalSymmSCMatrix(const RefSCDimension&, LocalSCMatrixKit*);
    00174     ~LocalSymmSCMatrix();
    00175
    00176     // implementations and overrides of virtual functions
    00177     double get_element(int,int) const;
    00178     void set_element(int,int,double);
    00179     void accumulate_element(int,int,double);
    00180
    00181     SCMatrix * get_subblock(int,int,int,int);
    00182     SymmSCMatrix * get_subblock(int,int);
    00183     void assign_subblock(SCMatrix*, int,int,int,int);
    00184     void assign_subblock(SymmSCMatrix*, int,int);
    00185     void accumulate_subblock(SCMatrix*, int,int,int,int);
    00186     void accumulate_subblock(SymmSCMatrix*, int,int);
    00187     SCVector * get_row(int i);
    00188     void assign_row(SCVector *v, int i);
    00189     void accumulate_row(SCVector *v, int i);
    00190
    00191     void accumulate_product_rr(SCMatrix*,SCMatrix*);
    00192     void accumulate(const SymmSCMatrix*);
    00193     double invert_this();
    00194     double solve_this(SCVector*);
    00195     double trace();
    00196     double determ_this();
    00197     void gen_invert_this();
    00198
    00199     double scalar_product(SCVector*);
    00200     void diagonalize(DiagSCMatrix*,SCMatrix*);
    00201     void accumulate_symmetric_outer_product(SCVector*);
    00202     void accumulate_symmetric_product(SCMatrix*);
    00203     void accumulate_symmetric_sum(SCMatrix*);
    00204     void accumulate_transform(SCMatrix*,SymmSCMatrix*,
    00205                               SCMatrix::Transform = SCMatrix::NormalTransform);
    00206     void accumulate_transform(SCMatrix*,DiagSCMatrix*,
    00207                               SCMatrix::Transform = SCMatrix::NormalTransform);
    00208     void accumulate_transform(SymmSCMatrix*,SymmSCMatrix*);
    00209     void element_op(const Ref<SCElementOp>&);
    00210     void element_op(const Ref<SCElementOp2>&,
    00211                     SymmSCMatrix*);
    00212     void element_op(const Ref<SCElementOp3>&,
    00213                     SymmSCMatrix*,SymmSCMatrix*);
    00214     void vprint(const char* title=0,
    00215                 std::ostream& out=ExEnv::out0(), int =10) const;
    00216
    00217     // return a pointer to the data for fast access
    00218     double *get_data();
    00219     double **get_rows();
    00220
    00221     Ref<SCMatrixSubblockIter> local_blocks(SCMatrixSubblockIter::Access);
    00222     Ref<SCMatrixSubblockIter> all_blocks(SCMatrixSubblockIter::Access);
    00223 };
    00224
    00225 class LocalDiagSCMatrix: public DiagSCMatrix {
    00226     friend class LocalSCMatrix;
    00227     friend class LocalSymmSCMatrix;
    00228     friend class LocalSCVector;
    00229   private:
    00230     Ref<SCMatrixDiagBlock> block;
    00231     void resize(int n);
    00232   public:
    00233     LocalDiagSCMatrix(const RefSCDimension&, LocalSCMatrixKit*);
    00234     ~LocalDiagSCMatrix();
    00235
    00236     // implementations and overrides of virtual functions
    00237     void save_data_state(StateOut&);
    00238     double get_element(int) const;
    00239     void set_element(int,double);
    00240     void accumulate_element(int,double);
    00241     void accumulate(const DiagSCMatrix*);
    00242     double invert_this();
    00243     double determ_this();
    00244     double trace();
    00245     void gen_invert_this();
    00246
    00247     void element_op(const Ref<SCElementOp>&);
    00248     void element_op(const Ref<SCElementOp2>&,
    00249                     DiagSCMatrix*);
    00250     void element_op(const Ref<SCElementOp3>&,
    00251                     DiagSCMatrix*,DiagSCMatrix*);
    00252     void vprint(const char* title=0,
    00253                 std::ostream& out=ExEnv::out0(), int =10) const;
    00254
    00255     // return a pointer to the data for fast access
    00256     double *get_data();
    00257
    00258     Ref<SCMatrixSubblockIter> local_blocks(SCMatrixSubblockIter::Access);
    00259     Ref<SCMatrixSubblockIter> all_blocks(SCMatrixSubblockIter::Access);
    00260 };
    00261
    00262 }
    00263
    00264 #endif
    00265
    00266 // Local Variables:
    00267 // mode: c++
    00268 // c-file-style: "CLJ"
    00269 // End: