matrix.h
//
// matrix.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_matrix_h
#define _math_scmat_matrix_h
#ifdef __GNUC__
#pragma interface
#endif
#include <iostream>
#include <math/scmat/abstract.h>
namespace sc {
class SCVectordouble;
class SCMatrixdouble;
class SymmSCMatrixdouble;
class DiagSCMatrixdouble;
class SCMatrixBlockIter;
class SCMatrixRectBlock;
class SCMatrixLTriBlock;
class SCMatrixDiagBlock;
class SCVectorSimpleBlock;
class RefSCMatrix;
class RefSymmSCMatrix;
class RefSCVector: public Ref<SCVector> {
// standard overrides
public:
RefSCVector();
RefSCVector(const RefSCVector& v);
RefSCVector(SCVector *v);
// don't allow automatic conversion from any reference to a
// described class
~RefSCVector();
RefSCVector& operator=(SCVector* v);
RefSCVector& operator=(const RefSCVector& v);
// vector specific members
public:
RefSCVector(const RefSCDimension& dim,const Ref<SCMatrixKit>&);
SCVectordouble operator()(int) const;
SCVectordouble operator[](int) const;
RefSCVector operator+(const RefSCVector&a) const;
RefSCVector operator-(const RefSCVector&a) const;
RefSCVector operator*(double) const;
RefSCMatrix outer_product(const RefSCVector& v) const;
RefSymmSCMatrix symmetric_outer_product() const;
void set_element(int i,double val) const;
void accumulate_element(int i,double val) const;
double get_element(int) const;
int n() const;
RefSCDimension dim() const;
Ref<SCMatrixKit> kit() const;
RefSCVector clone() const;
RefSCVector copy() const;
double maxabs() const;
double scalar_product(const RefSCVector&) const;
double dot(const RefSCVector&) const;
void normalize() const;
void randomize() const;
void assign(const RefSCVector& v) const;
void assign(double val) const;
void assign(const double* v) const;
void convert(double*) const;
void scale(double val) const;
void accumulate(const RefSCVector& v) const;
void accumulate_product(const RefSymmSCMatrix&, const RefSCVector&);
void accumulate_product(const RefSCMatrix&, const RefSCVector&);
void element_op(const Ref<SCElementOp>& op) const;
void element_op(const Ref<SCElementOp2>&,
const RefSCVector&) const;
void element_op(const Ref<SCElementOp3>&,
const RefSCVector&,
const RefSCVector&) const;
void print(std::ostream&out) const;
void print(const char*title=0,
std::ostream&out=ExEnv::out0(), int precision=10) const;
void save(StateOut&);
void restore(StateIn&);
};
RefSCVector operator*(double,const RefSCVector&);
class RefSymmSCMatrix;
class RefDiagSCMatrix;
class RefSCMatrix: public Ref<SCMatrix> {
// standard overrides
public:
RefSCMatrix();
RefSCMatrix(const RefSCMatrix& m);
RefSCMatrix(SCMatrix* m);
~RefSCMatrix();
RefSCMatrix& operator=(SCMatrix* m);
RefSCMatrix& operator=(const RefSCMatrix& m);
// matrix specific members
public:
RefSCMatrix(const RefSCDimension& d1,const RefSCDimension& d2,
const Ref<SCMatrixKit>&);
RefSCVector operator*(const RefSCVector&) const;
RefSCMatrix operator*(const RefSCMatrix&) const;
RefSCMatrix operator*(const RefSymmSCMatrix&) const;
RefSCMatrix operator*(const RefDiagSCMatrix&) const;
RefSCMatrix operator*(double) const;
RefSCMatrix operator+(const RefSCMatrix&) const;
RefSCMatrix operator-(const RefSCMatrix&) const;
RefSCMatrix t() const;
RefSCMatrix i() const;
RefSCMatrix gi() const;
RefSCMatrix clone() const;
RefSCMatrix copy() const;
RefSCMatrix get_subblock(int br, int er, int bc, int ec);
void assign_subblock(const RefSCMatrix&, int br, int er, int bc, int ec,
int source_br = 0, int source_bc = 0);
void accumulate_subblock(const RefSCMatrix&, int, int, int, int,
int source_br = 0, int source_bc = 0);
RefSCVector get_row(int) const;
RefSCVector get_column(int) const;
void assign_row(const RefSCVector&, int) const;
void assign_column(const RefSCVector&, int) const;
void accumulate_row(const RefSCVector&, int) const;
void accumulate_column(const RefSCVector&, int) const;
void accumulate_outer_product(const RefSCVector&,const RefSCVector&) const;
void accumulate_product(const RefSCMatrix&,const RefSCMatrix&) const;
void assign(const RefSCMatrix&) const;
void scale(double) const;
void randomize() const;
void assign(double) const;
void assign(const double*) const;
void assign(const double**) const;
void convert(double*) const;
void convert(double**) const;
void accumulate(const RefSCMatrix&) const;
void accumulate(const RefSymmSCMatrix&) const;
void accumulate(const RefDiagSCMatrix&) const;
void element_op(const Ref<SCElementOp>&) const;
void element_op(const Ref<SCElementOp2>&,
const RefSCMatrix&) const;
void element_op(const Ref<SCElementOp3>&,
const RefSCMatrix&,
const RefSCMatrix&) const;
int nrow() const;
int ncol() const;
RefSCDimension rowdim() const;
RefSCDimension coldim() const;
Ref<SCMatrixKit> kit() const;
void set_element(int,int,double) const;
void accumulate_element(int,int,double) const;
double get_element(int,int) const;
void print(std::ostream&) const;
void print(const char*title=0,
std::ostream&out=ExEnv::out0(), int =10) const;
double trace() const;
void save(StateOut&);
void restore(StateIn&);
void svd(const RefSCMatrix &U,
const RefDiagSCMatrix &sigma,
const RefSCMatrix &V);
double solve_lin(const RefSCVector& v) const;
double determ() const;
SCMatrixdouble operator()(int i,int j) const;
int nblock() const;
RefSCMatrix block(int i) const;
};
RefSCMatrix operator*(double,const RefSCMatrix&);
class RefSymmSCMatrix: public Ref<SymmSCMatrix> {
// standard overrides
public:
RefSymmSCMatrix();
RefSymmSCMatrix(const RefSymmSCMatrix& m);
RefSymmSCMatrix(SymmSCMatrix *m);
~RefSymmSCMatrix();
RefSymmSCMatrix& operator=(SymmSCMatrix* m);
RefSymmSCMatrix& operator=(const RefSymmSCMatrix& m);
// matrix specific members
public:
RefSymmSCMatrix(const RefSCDimension& d,const Ref<SCMatrixKit>&);
RefSCMatrix operator*(const RefSCMatrix&) const;
RefSCMatrix operator*(const RefSymmSCMatrix&) const;
RefSCVector operator*(const RefSCVector&a) const;
RefSymmSCMatrix operator*(double) const;
RefSymmSCMatrix operator+(const RefSymmSCMatrix&) const;
RefSymmSCMatrix operator-(const RefSymmSCMatrix&) const;
RefSymmSCMatrix i() const;
RefSymmSCMatrix gi() const;
RefSymmSCMatrix clone() const;
RefSymmSCMatrix copy() const;
void set_element(int,int,double) const;
void accumulate_element(int,int,double) const;
double get_element(int,int) const;
RefSCMatrix get_subblock(int br, int er, int bc, int ec);
RefSymmSCMatrix get_subblock(int br, int er);
void assign_subblock(const RefSCMatrix&, int br, int er, int bc, int ec);
void assign_subblock(const RefSymmSCMatrix&, int br, int er);
void accumulate_subblock(const RefSCMatrix&, int, int, int, int);
void accumulate_subblock(const RefSymmSCMatrix&, int, int);
RefSCVector get_row(int);
void assign_row(const RefSCVector&, int);
void accumulate_row(const RefSCVector&, int);
void accumulate_symmetric_outer_product(const RefSCVector&) const;
double scalar_product(const RefSCVector&) const;
void accumulate_symmetric_product(const RefSCMatrix&) const;
void accumulate_symmetric_sum(const RefSCMatrix&) const;
void accumulate_transform(const RefSCMatrix&a,const RefSymmSCMatrix&b,
SCMatrix::Transform = SCMatrix::NormalTransform) const;
void accumulate_transform(const RefSCMatrix&a,const RefDiagSCMatrix&b,
SCMatrix::Transform = SCMatrix::NormalTransform) const;
void accumulate_transform(const RefSymmSCMatrix&a,
const RefSymmSCMatrix&b) const;
void randomize() const;
void assign(const RefSymmSCMatrix&) const;
void scale(double) const;
void assign(double) const;
void assign(const double*) const;
void assign(const double**) const;
void convert(double*) const;
void convert(double**) const;
void accumulate(const RefSymmSCMatrix&) const;
void element_op(const Ref<SCElementOp>&) const;
void element_op(const Ref<SCElementOp2>&,
const RefSymmSCMatrix&) const;
void element_op(const Ref<SCElementOp3>&,
const RefSymmSCMatrix&,
const RefSymmSCMatrix&) const;
double trace() const;
int n() const;
RefSCDimension dim() const;
Ref<SCMatrixKit> kit() const;
void print(std::ostream&) const;
void print(const char*title=0,
std::ostream&out=ExEnv::out0(), int =10) const;
void save(StateOut&);
void restore(StateIn&);
double solve_lin(const RefSCVector&) const;
double determ() const;
RefDiagSCMatrix eigvals() const;
RefSCMatrix eigvecs() const;
void diagonalize(const RefDiagSCMatrix& eigvals,
const RefSCMatrix& eigvecs) const;
SymmSCMatrixdouble operator()(int i,int j) const;
int nblock() const;
RefSymmSCMatrix block(int i) const;
};
RefSymmSCMatrix operator*(double,const RefSymmSCMatrix&);
class RefDiagSCMatrix: public Ref<DiagSCMatrix> {
// standard overrides
public:
RefDiagSCMatrix();
RefDiagSCMatrix(const RefDiagSCMatrix& m);
RefDiagSCMatrix(DiagSCMatrix *m);
~RefDiagSCMatrix();
RefDiagSCMatrix& operator=(DiagSCMatrix* m);
RefDiagSCMatrix& operator=(const RefDiagSCMatrix & m);
// matrix specific members
public:
RefDiagSCMatrix(const RefSCDimension&,const Ref<SCMatrixKit>&);
RefSCMatrix operator*(const RefSCMatrix&) const;
RefDiagSCMatrix operator*(double) const;
RefDiagSCMatrix operator+(const RefDiagSCMatrix&) const;
RefDiagSCMatrix operator-(const RefDiagSCMatrix&) const;
RefDiagSCMatrix i() const;
RefDiagSCMatrix gi() const;
RefDiagSCMatrix clone() const;
RefDiagSCMatrix copy() const;
void set_element(int,double) const;
void accumulate_element(int,double) const;
double get_element(int) const;
void randomize() const;
void assign(const RefDiagSCMatrix&) const;
void scale(double) const;
void assign(double) const;
void assign(const double*) const;
void convert(double*) const;
void accumulate(const RefDiagSCMatrix&) const;
void element_op(const Ref<SCElementOp>&) const;
void element_op(const Ref<SCElementOp2>&,
const RefDiagSCMatrix&) const;
void element_op(const Ref<SCElementOp3>&,
const RefDiagSCMatrix&,
const RefDiagSCMatrix&) const;
int n() const;
RefSCDimension dim() const;
Ref<SCMatrixKit> kit() const;
double trace() const;
void print(std::ostream&) const;
void print(const char*title=0,
std::ostream&out=ExEnv::out0(), int =10) const;
void save(StateOut&);
void restore(StateIn&);
double determ() const;
DiagSCMatrixdouble operator()(int i) const;
int nblock() const;
RefDiagSCMatrix block(int i) const;
};
RefDiagSCMatrix operator*(double,const RefDiagSCMatrix&);
class SCVectordouble {
friend class RefSCVector;
private:
RefSCVector vector;
int i;
SCVectordouble(SCVector*,int);
public:
SCVectordouble(const SCVectordouble&);
~SCVectordouble();
double operator=(double a);
double operator=(const SCVectordouble&);
operator double();
double val() const;
};
class SCMatrixdouble {
friend class RefSCMatrix;
private:
RefSCMatrix matrix;
int i;
int j;
SCMatrixdouble(SCMatrix*,int,int);
public:
SCMatrixdouble(const SCMatrixdouble&);
~SCMatrixdouble();
double operator=(double a);
double operator=(const SCMatrixdouble&);
operator double();
double val() const;
};
class SymmSCMatrixdouble {
friend class RefSymmSCMatrix;
private:
RefSymmSCMatrix matrix;
int i;
int j;
SymmSCMatrixdouble(SymmSCMatrix*,int,int);
public:
SymmSCMatrixdouble(const SCMatrixdouble&);
~SymmSCMatrixdouble();
double operator=(double a);
double operator=(const SymmSCMatrixdouble&);
operator double();
double val() const;
};
class DiagSCMatrixdouble {
friend class RefDiagSCMatrix;
private:
RefDiagSCMatrix matrix;
int i;
int j;
DiagSCMatrixdouble(DiagSCMatrix*,int,int);
public:
DiagSCMatrixdouble(const SCMatrixdouble&);
~DiagSCMatrixdouble();
double operator=(double a);
double operator=(const DiagSCMatrixdouble&);
operator double();
double val() const;
};
}
#ifdef INLINE_FUNCTIONS
#include <math/scmat/matrix_i.h>
#endif
#endif
// Local Variables:
// mode: c++
// c-file-style: "CLJ"
// End: