Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

matvec::Matrix< T > Class Template Reference

#include <matrix.h>

Inheritance diagram for matvec::Matrix< T >:

matvec::Matrixwbg< T > List of all members.

Detailed Description

template<class T>
class matvec::Matrix< T >

A vector is a on-dimensional array with double precision.

See also:
Matrix

Definition at line 41 of file matrix.h.

Public Types

typedef int size_type
typedef T value_type
typedef T element_type
typedef T * pointer
typedef T * iterator
typedef T & reference
typedef const T * const_iterator
typedef const T * const_pointer
typedef const T & const_reference
typedef std::reverse_iterator<
iterator
reverse_iterator
typedef std::reverse_iterator<
const_iterator
const_reverse_iterator
enum  orientation { ROW, COLUMN }

Public Methods

 Matrix (void)
 Matrix (const size_type m, const size_type n)
 Matrix (const size_type m, const size_type n, const T **a)
 Matrix (const Matrix &a)
T ** begin (void)
const T ** begin (void) const
virtual ~Matrix (void)
void copy (const Matrix &a)
Matrix & assign (const Matrix &a)
Matrix & assign (const T &x)
Matrix & resize (const size_type n, const size_type m, const T &val=T())
Matrix & resize (const size_type n, const size_type m, const T *a)
Matrix & resize (const Matrix &a)
Matrix & reserve (const size_type n, const size_type m)
Matrix & operator= (const Matrix &a)
Matrix & operator= (const T &x)
Matrix operator+ (const Matrix &a) const
Matrix operator- (const Matrix &a) const
Matrix operator * (const Matrix &a) const
Matrix operator/ (const Matrix &a) const
Vector< T > operator * (const Vector< T > &a) const
Matrix operator+ (const T &x) const
Matrix operator- (const T &x) const
Matrix operator * (const T &x) const
Matrix operator/ (const T &x) const
Matrix & operator+= (const Matrix &a)
Matrix & operator-= (const Matrix &a)
Matrix & operator *= (const Matrix &a)
Matrix & operator/= (const Matrix &a)
Matrix & operator+= (const T &x)
Matrix & operator-= (const T &x)
Matrix & operator *= (const T &x)
Matrix & operator/= (const T &x)
T * operator[] (const size_type i)
const T * operator[] (const size_type i) const
T & operator() (const size_type i, const size_type j)
Matrix operator- (void) const
Matrix & operator+ (void)
Matrix< bool > operator! (void) const
Matrix< bool > operator== (const Matrix &a) const
Matrix< bool > operator< (const Matrix &a) const
Matrix< bool > operator> (const Matrix &a) const
Matrix< bool > operator!= (const Matrix &a) const
Matrix< bool > operator<= (const Matrix &a) const
Matrix< bool > operator>= (const Matrix &a) const
Matrix< bool > operator== (const T &x) const
Matrix< bool > operator< (const T &x) const
Matrix< bool > operator> (const T &x) const
Matrix< bool > operator!= (const T &x) const
Matrix< bool > operator<= (const T &x) const
Matrix< bool > operator>= (const T &x) const
bool all (void) const
bool any (void) const
bool symmetric (void) const
bool empty (void) const
bool save (const std::string &fname, const int io_mode=std::ios::out) const
Matrix apply (T(*f)(T)) const
Matrix apply (T(*f)(T, T), const Matrix &b) const
Matrix apply (T(*f)(T, T), const T &b) const
Matrix submat (const size_type idx1, const size_type idx2, const int len1=0, const int len2=0) const
Matrix submat (const Matrix< bool > &a) const
Matrix transpose (void) const
Matrix kron (const Matrix &b) const
Matrix reshape (const size_type m, const size_type n, orientation orient=COLUMN) const
Matrix diag (void) const
Vector< T > diag (const size_type k) const
Vector< T > vec (orientation orient=COLUMN) const
Vector< T > sum (orientation orient=COLUMN) const
Vector< T > sumsq (orientation orient=COLUMN) const
Vector< T > max (orientation orient=COLUMN) const
Vector< T > min (orientation orient=COLUMN) const
virtual std::ostream & print (std::ostream &os=std::cout) const
trace (T init=T()) const
T & at (const size_type i, const size_type j)
Matrix & sortby (orientation orient, const size_type k)
int size (void) const
int num_rows (void) const
int num_cols (void) const
void clear (void)
void input (const std::string &fname, const size_type m, const size_type n)
void initialize (const size_type m, const size_type n, const T **a)

Public Attributes

T ** me
int nrow
int ncol


Member Typedef Documentation

template<class T>
typedef const T* matvec::Matrix< T >::const_iterator
 

Definition at line 50 of file matrix.h.

template<class T>
typedef const T* matvec::Matrix< T >::const_pointer
 

Definition at line 51 of file matrix.h.

template<class T>
typedef const T& matvec::Matrix< T >::const_reference
 

Definition at line 52 of file matrix.h.

template<class T>
typedef std::reverse_iterator<const_iterator> matvec::Matrix< T >::const_reverse_iterator
 

Definition at line 54 of file matrix.h.

template<class T>
typedef T matvec::Matrix< T >::element_type
 

Definition at line 46 of file matrix.h.

template<class T>
typedef T* matvec::Matrix< T >::iterator
 

Definition at line 48 of file matrix.h.

template<class T>
typedef T* matvec::Matrix< T >::pointer
 

Definition at line 47 of file matrix.h.

template<class T>
typedef T& matvec::Matrix< T >::reference
 

Definition at line 49 of file matrix.h.

template<class T>
typedef std::reverse_iterator<iterator> matvec::Matrix< T >::reverse_iterator
 

Definition at line 53 of file matrix.h.

template<class T>
typedef int matvec::Matrix< T >::size_type
 

Reimplemented in matvec::Matrixwbg< T >.

Definition at line 44 of file matrix.h.

Referenced by matvec::Matrix< unsigned >::Matrix(), and matvec::Matrix< unsigned >::operator[]().

template<class T>
typedef T matvec::Matrix< T >::value_type
 

Definition at line 45 of file matrix.h.


Member Enumeration Documentation

template<class T>
enum matvec::Matrix::orientation
 

Enumeration values:
ROW 
COLUMN 

Definition at line 56 of file matrix.h.

00056 {ROW,COLUMN};


Constructor & Destructor Documentation

template<class T>
matvec::Matrix< T >::Matrix void    [inline]
 

Definition at line 58 of file matrix.h.

00058                 { 
00059      //std::cout <<"constructor 1\n";
00060      initialize(0,0,0);  //Constructor 1
00061    } 

template<class T>
matvec::Matrix< T >::Matrix const size_type    m,
const size_type    n
[inline]
 

Definition at line 62 of file matrix.h.

00062                                                { 
00063      //std::cout <<"constructor 2\n";
00064      initialize(m,n,0);   //Constructor 2
00065    }

template<class T>
matvec::Matrix< T >::Matrix const size_type    m,
const size_type    n,
const T **    a
[inline]
 

Definition at line 66 of file matrix.h.

00066                                                            { 
00067      //std::cout <<"constructor 3\n";
00068      initialize(m,n,a);   //Constructor 3
00069    }

template<class T>
matvec::Matrix< T >::Matrix const Matrix< T > &    a [inline]
 

Definition at line 70 of file matrix.h.

00070                           { 
00071      //std::cout <<"constructor 4\n";
00072      initialize(a.nrow,a.ncol,(const T**)a.me);   //Constructor 4
00073    }

template<class T>
virtual matvec::Matrix< T >::~Matrix void    [inline, virtual]
 

Definition at line 78 of file matrix.h.

00078 {clear();}                                  // Destructor


Member Function Documentation

template<class T>
bool matvec::Matrix< T >::all void    const [inline]
 

Definition at line 568 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

Referenced by matvec::all().

00569 {
00570    if (!me) return false;
00571    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) if (me[i][j] == false) return false;
00572    return true;
00573 }

template<class T>
bool matvec::Matrix< T >::any void    const [inline]
 

Definition at line 575 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

Referenced by matvec::any().

00576 {
00577    if (!me) return false;
00578    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) if (me[i][j] == true) return true;
00579    return false;
00580 }

template<class T>
Matrix< T > matvec::Matrix< T >::apply T(*    f)(T, T),
const T &    b
const [inline]
 

Definition at line 623 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00624 {
00625    Matrix<T> temp(nrow,ncol);
00626    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) temp[i][j] = (*f)(me[i][j],b);
00627    return temp;
00628 }

template<class T>
Matrix< T > matvec::Matrix< T >::apply T(*    f)(T, T),
const Matrix< T > &    b
const [inline]
 

Definition at line 615 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00616 {
00617    if (nrow != b.nrow || ncol != b.ncol) throw exception("Matrix<T>::apply(): size not conformable");
00618    Matrix<T> temp(nrow,ncol);
00619    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) temp[i][j] = (*f)(me[i][j],b[i][j]);
00620    return temp;
00621 }

template<class T>
Matrix< T > matvec::Matrix< T >::apply T(*    f)(T) const [inline]
 

Definition at line 608 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

Referenced by matvec::abs(), matvec::acos(), matvec::asin(), matvec::atan(), matvec::ceil(), matvec::cos(), matvec::erf(), matvec::erfc(), matvec::exp(), matvec::floor(), matvec::log(), matvec::log10(), matvec::sin(), matvec::sqrt(), and matvec::tan().

00609 {
00610    Matrix<T> temp(nrow,ncol);
00611    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) temp[i][j] = (*f)(me[i][j]);
00612    return temp;
00613 }

template<class T>
Matrix< T > & matvec::Matrix< T >::assign const T &    x [inline]
 

Definition at line 243 of file matrix.h.

References matvec::Matrix< T >::ncol, matvec::Matrix< T >::nrow, and matvec::Matrix< T >::resize().

00244 {
00245    if (me) {
00246       resize(nrow,ncol,a);
00247    } else {
00248      resize(1,1,a);
00249    }
00250    return *this;
00251 }

template<class T>
Matrix& matvec::Matrix< T >::assign const Matrix< T > &    a [inline]
 

Definition at line 81 of file matrix.h.

Referenced by matvec::Matrix< unsigned >::operator=().

00081 {copy(a); return *this;}

template<class T>
T & matvec::Matrix< T >::at const size_type    i,
const size_type    j
[inline]
 

Definition at line 197 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

Referenced by matvec::Model::setup_ww().

00198 {
00199    if (i < 0 || i >= nrow || j < 0 || j >= ncol) throw exception("Matrix<T>::at(): out of range");
00200    return me[i][j];
00201 }

template<class T>
const T** matvec::Matrix< T >::begin void    const [inline]
 

Definition at line 76 of file matrix.h.

00076 { return (const T**)me; }

template<class T>
T** matvec::Matrix< T >::begin void    [inline]
 

Definition at line 75 of file matrix.h.

Referenced by matvec::Model::add_Ag(), matvec::GLMM::add_Ag(), matvec::Model::add_Ag_diag(), matvec::GLMM::add_Ag_old(), matvec::GLMM::add_AgSand(), matvec::Model::add_G_1_single_trait(), matvec::Population::add_Ga_inv(), matvec::Model::add_Ig(), matvec::Model::add_Ig_diag(), matvec::GLMM::add_IgSand(), matvec::Pedigree::ainv(), matvec::GLMM::ainv(), matvec::doubleMatrix::cond(), matvec::Population::cond_genotype_config(), matvec::Model::contrast(), matvec::GLMM::contrast(), matvec::doubleMatrix::eigen(), matvec::Model::estimate(), matvec::Population::gibbs_iterate(), matvec::doubleMatrix::ginv0(), matvec::doubleMatrix::logdet(), matvec::BGMatrix::logdet(), matvec::doubleMatrix::norm(), matvec::operator *(), matvec::Minimizer::praxis(), and matvec::doubleMatrix::rank().

00075 { return me; }

template<class T>
void matvec::Matrix< T >::clear void    [inline]
 

Definition at line 203 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

Referenced by matvec::Matrix< T >::reserve(), matvec::Matrix< T >::resize(), and matvec::Matrix< unsigned >::~Matrix().

00204 {
00205    if (me) {
00206       for (int i=0; i<nrow; ++i) delete [] me[i];
00207       delete [] me;
00208       me = 0;
00209    }
00210    nrow = 0;
00211    ncol = 0;
00212 }

template<class T>
void matvec::Matrix< T >::copy const Matrix< T > &    a [inline]
 

Definition at line 229 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, matvec::Matrix< T >::nrow, and matvec::Matrix< T >::reserve().

Referenced by matvec::Matrix< unsigned >::assign().

00230 {
00231    if (this == &a) return;
00232    reserve(a.nrow,a.ncol);
00233 /*    for (int i=0; i<nrow; ++i) memcpy(me[i],a.me[i],sizeof(T)*ncol);  */
00234 /*    memcopy does not work correctly for complex objects RLF */
00235    for (int i=0; i<nrow; ++i) {
00236      for (int j=0; j<ncol; j++){
00237        me[i][j] = a.me[i][j];
00238      }
00239    }
00240    return;
00241 }

template<class T>
Vector< T > matvec::Matrix< T >::diag const size_type    k const [inline]
 

Definition at line 732 of file matrix.h.

References matvec::Matrix< T >::me, min, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00733 {
00734    int i,n = std::min(nrow,ncol) - std::abs(k);
00735    Vector<T> temp(n);
00736    if (k >= 0) {
00737       for (i=0; i<n; i++) temp[i] = me[i][i+k];
00738    } else {
00739       for (i=0; i<n; i++) temp[i] = me[i-k][i];
00740    }
00741    return temp;
00742 }

template<class T>
Matrix< T > matvec::Matrix< T >::diag void    const [inline]
 

Definition at line 724 of file matrix.h.

References matvec::Matrix< T >::me, min, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

Referenced by matvec::diag().

00725 {
00726    int n = std::min(nrow,ncol);
00727    Matrix<T> temp(n,n);
00728    for (int i=0; i<n; ++i) temp[i][i] = me[i][i];
00729    return temp;
00730 }

template<class T>
bool matvec::Matrix< T >::empty void    const [inline]
 

Definition at line 138 of file matrix.h.

00138 { return (nrow == 0 || ncol == 0); }

template<class T>
void matvec::Matrix< T >::initialize const size_type    m,
const size_type    n,
const T **    a
[inline]
 

Definition at line 176 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

Referenced by matvec::Matrix< unsigned >::Matrix(), and matvec::Matrixwbg< T >::Matrixwbg().

00177 {
00178    if (m == 0 || n == 0) {
00179       nrow = 0; ncol = 0; me = 0;
00180    } else {
00181       nrow = m; ncol = n;
00182       me = new T* [nrow];
00183       assert( me != 0 );
00184       for (int j,i=0; i<nrow; ++i) {
00185          me[i] = new T [ncol];
00186          assert( me[i] != 0 );
00187          if (a) {
00188             for (j=0; j<ncol; ++j) me[i][j] = a[i][j];
00189          } else {
00190             for (j=0; j<ncol; ++j) me[i][j] = T();
00191          }
00192       }
00193    }
00194    return;
00195 }

template<class T>
void matvec::Matrix< T >::input const std::string &    fname,
const size_type    m,
const size_type    n
[inline]
 

Definition at line 214 of file matrix.h.

References matvec::Matrix< T >::me, and matvec::Matrix< T >::resize().

00217 {
00218    resize(m,n);
00219    std::ifstream infile(fname.c_str(),std::ios::in);//SDK | std::ios::nocreate);
00220    if (!infile) {
00221       std::cerr << fname << ": cannot open\n";
00222    } else {
00223       for (int j,i=0; i<m; ++i) for (j=0; j<n; ++j) infile >> me[i][j];
00224       infile.close();
00225    }
00226    return;
00227 }

template<class T>
Matrix< T > matvec::Matrix< T >::kron const Matrix< T > &    b const [inline]
 

Definition at line 676 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00677 {
00678    Matrix<T> temp(nrow*b.nrow,ncol*b.ncol);
00679    int i,j,k,t,ii,iii,jj,jjj;
00680    for (i=0; i<nrow; ++i) {
00681       ii = i*b.nrow;
00682       for (j=0; j<ncol; ++j) {
00683          jj = j*b.ncol;
00684          iii = ii;
00685          for (k=0; k<b.nrow; ++k) {
00686             jjj = jj;
00687             for (t=0; t<b.ncol; ++t) temp[iii][jjj++] = me[i][j]*b[k][t];
00688             iii++;
00689          }
00690       }
00691    }
00692    return temp;
00693 }

template<class T>
Vector< T > matvec::Matrix< T >::max orientation    orient = COLUMN const [inline]
 

Definition at line 815 of file matrix.h.

References matvec::Matrix< T >::COLUMN, matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, matvec::Matrix< T >::nrow, matvec::Vector< T >::reserve(), and matvec::Matrix< T >::ROW.

00816 {
00817    Vector<T> temp;
00818    if (!me) return temp;
00819    int i,j;
00820    if (orient == ROW) {
00821       temp.reserve(nrow);
00822       for (i=0; i<nrow; ++i) {
00823          temp[i] = me[i][0];
00824          for (j=0; j<ncol; ++j) if (me[i][j] > temp[i]) temp[i] = me[i][j];
00825       }
00826    } else if (orient == COLUMN)  {
00827       temp.reserve(ncol);
00828       for (j=0; j<ncol; ++j) {
00829          temp[j] = me[0][j];
00830          for (i=0; i<nrow; ++i) if (me[i][j] > temp[j]) temp[j] = me[i][j];
00831       }
00832    } else {
00833       std::cerr << "unknow orientation\n";
00834       exit(1);
00835    }
00836    return temp;
00837 }

template<class T>
Vector< T > matvec::Matrix< T >::min orientation    orient = COLUMN const [inline]
 

Definition at line 839 of file matrix.h.

References matvec::Matrix< T >::COLUMN, matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, matvec::Matrix< T >::nrow, matvec::Vector< T >::reserve(), and matvec::Matrix< T >::ROW.

00840 {
00841    Vector<T> temp;
00842    if (!me) return temp;
00843    int i,j;
00844    if (orient == ROW) {
00845       temp.reserve(nrow);
00846       for (i=0; i<nrow; ++i) {
00847          temp[i] = me[i][0];
00848          for (j=1; j<ncol; ++j) if (me[i][j] < temp[i]) temp[i] = me[i][j];
00849       }
00850    } else if (orient == COLUMN)  {
00851       temp.reserve(ncol);
00852       for (j=0; j<ncol; ++j) {
00853          temp[j] = me[0][j];
00854          for (i=1; i<nrow; ++i) if (me[i][j] < temp[j]) temp[j] = me[i][j];
00855       }
00856    } else {
00857       std::cerr << "unknow orientation\n";
00858       exit(1);
00859    }
00860    return temp;
00861 }

template<class T>
int matvec::Matrix< T >::num_cols void    const [inline]
 

Definition at line 163 of file matrix.h.

Referenced by matvec::hadjoin(), matvec::operator *(), matvec::operator/(), matvec::doubleMatrix::operator=(), matvec::BGMatrix::operator=(), and matvec::vadjoin().

00163 { return ncol; }

template<class T>
int matvec::Matrix< T >::num_rows void    const [inline]
 

Definition at line 162 of file matrix.h.

Referenced by matvec::hadjoin(), matvec::operator *(), matvec::operator/(), matvec::doubleMatrix::operator=(), matvec::BGMatrix::operator=(), and matvec::vadjoin().

00162 { return nrow; }

template<class T>
Matrix< T > matvec::Matrix< T >::operator * const T &    x const [inline]
 

Definition at line 540 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00541 {
00542    Matrix<T> temp(nrow,ncol);
00543    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) temp[i][j] = me[i][j] * a;
00544    return temp;
00545 }

template<class T>
Vector< T > matvec::Matrix< T >::operator * const Vector< T > &    a const [inline]
 

Definition at line 504 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, matvec::Matrix< T >::nrow, and matvec::Vector< T >::size().

00505 {
00506    if (ncol != a.size()) throw exception("Matrix<T>::operator*: size not conformable");
00507    Vector<T> temp(nrow);
00508    T x;
00509    for (int j,i=0; i<nrow; ++i) {
00510       x = T();
00511       for (j=0; j<ncol; ++j)  x += me[i][j]*a[j];
00512       temp[i] = x;
00513    }
00514    return temp;
00515 }

template<class T>
Matrix< T > matvec::Matrix< T >::operator * const Matrix< T > &    a const [inline]
 

Definition at line 489 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00490 {
00491    if (ncol != a.nrow) throw exception("Matrix<T>::operator*: size not conformable");
00492    Matrix<T> temp(nrow,a.ncol);
00493    T x;
00494    for (int t,j,i=0; i<nrow; ++i) {
00495       for (j=0; j<a.ncol; ++j) {
00496          x = T();
00497          for (t=0; t<ncol; ++t) x += me[i][t]*a[t][j];
00498          temp[i][j] = x;
00499       }
00500    }
00501    return temp;
00502 }

template<class T>
Matrix< T > & matvec::Matrix< T >::operator *= const T &    x [inline]
 

Definition at line 370 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00371 {
00372    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) me[i][j] *= s;
00373    return *this;
00374 }

template<class T>
Matrix< T > & matvec::Matrix< T >::operator *= const Matrix< T > &    a [inline]
 

Definition at line 344 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00345 {
00346    if (nrow != a.nrow || ncol != a.ncol) throw exception("Matrix<T>::operator*=: size not conformable");
00347    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) me[i][j] *= a[i][j];
00348    return *this;
00349 }

template<class T>
Matrix< bool > matvec::Matrix< T >::operator! void    const [inline]
 

Definition at line 561 of file matrix.h.

00562 {
00563    Matrix<bool> temp(nrow,ncol);
00564    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) temp[i][j] = ! me[i][j];
00565    return temp;
00566 }

template<class T>
Matrix< bool > matvec::Matrix< T >::operator!= const T &    x const [inline]
 

Definition at line 435 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00436 {
00437    Matrix<bool> temp(nrow,ncol);
00438    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) temp[i][j] = (me[i][j] != x);
00439    return temp;
00440 }

template<class T>
Matrix< bool > matvec::Matrix< T >::operator!= const Matrix< T > &    a const [inline]
 

Definition at line 427 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00428 {
00429    if (nrow != a.nrow || ncol != a.ncol) throw exception("Matrix<T>::operator!=: size not conformable");
00430    Matrix<bool> temp(nrow,ncol);
00431    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) temp[i][j] = (me[i][j] != a[i][j]);
00432    return temp;
00433 }

template<class T>
T & matvec::Matrix< T >::operator() const size_type    i,
const size_type    j
[inline]
 

Definition at line 324 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00325 {
00326    if (i < 1 || i > nrow || j < 1 || j > ncol) throw exception("Matrix<T>::operator(): out of range");
00327    return me[i-1][j-1];
00328 }

template<class T>
Matrix& matvec::Matrix< T >::operator+ void    [inline]
 

Definition at line 117 of file matrix.h.

00117 { return *this; }      //unary plus

template<class T>
Matrix< T > matvec::Matrix< T >::operator+ const T &    x const [inline]
 

Definition at line 526 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00527 {
00528    Matrix<T> temp(nrow,ncol);
00529    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) temp[i][j] = me[i][j] + a;
00530    return temp;
00531 }

template<class T>
Matrix< T > matvec::Matrix< T >::operator+ const Matrix< T > &    a const [inline]
 

Definition at line 473 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00474 {
00475    if (nrow != a.nrow || ncol != a.ncol) throw exception("Matrix<T>::operator+: size not conformable");
00476    Matrix<T> temp(nrow,ncol);
00477    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) temp[i][j] = me[i][j] + a.me[i][j];
00478    return temp;
00479 }

template<class T>
Matrix< T > & matvec::Matrix< T >::operator+= const T &    x [inline]
 

Definition at line 358 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00359 {
00360    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) me[i][j] += s;
00361    return *this;
00362 }

template<class T>
Matrix< T > & matvec::Matrix< T >::operator+= const Matrix< T > &    a [inline]
 

Definition at line 330 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00331 {
00332    if (nrow != a.nrow || ncol != a.ncol) throw exception("Matrix<T>::operator+=: size not conformable");
00333    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) me[i][j] += a[i][j];
00334    return *this;
00335 }

template<class T>
Matrix< T > matvec::Matrix< T >::operator- void    const [inline]
 

Definition at line 554 of file matrix.h.

00555 {
00556    Matrix<T> temp(nrow,ncol);
00557    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) temp[i][j] = - me[i][j];
00558    return temp;
00559 }

template<class T>
Matrix< T > matvec::Matrix< T >::operator- const T &    x const [inline]
 

Definition at line 533 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00534 {
00535    Matrix<T> temp(nrow,ncol);
00536    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) temp[i][j] = me[i][j] - a;
00537    return temp;
00538 }

template<class T>
Matrix< T > matvec::Matrix< T >::operator- const Matrix< T > &    a const [inline]
 

Definition at line 481 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00482 {
00483    if (nrow != a.nrow || ncol != a.ncol) throw exception("Matrix<T>::operator-: size not conformable");
00484    Matrix<T> temp(nrow,ncol);
00485    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) temp[i][j] = me[i][j] - a.me[i][j];
00486    return temp;
00487 }

template<class T>
Matrix< T > & matvec::Matrix< T >::operator-= const T &    x [inline]
 

Definition at line 364 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00365 {
00366    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) me[i][j] -= s;
00367    return *this;
00368 }

template<class T>
Matrix< T > & matvec::Matrix< T >::operator-= const Matrix< T > &    a [inline]
 

Definition at line 337 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00338 {
00339    if ( nrow != a.nrow || ncol != a.ncol ) throw exception("Matrix<T>::operator-=: size not conformable");
00340    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) me[i][j] -= a[i][j];
00341    return *this;
00342 }

template<class T>
Matrix< T > matvec::Matrix< T >::operator/ const T &    x const [inline]
 

Definition at line 547 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00548 {
00549    Matrix<T> temp(nrow,ncol);
00550    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) temp[i][j] = me[i][j] / a;
00551    return temp;
00552 }

template<class T>
Matrix< T > matvec::Matrix< T >::operator/ const Matrix< T > &    a const [inline]
 

Definition at line 517 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00518 {
00519    if (nrow != a.nrow || ncol != a.ncol) throw exception("Matrix<T>::operator/: size not conformable");
00520    Matrix<T> temp(nrow,ncol);
00521    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) temp[i][j] = me[i][j] / a.me[i][j];
00522    return temp;
00523 }

template<class T>
Matrix< T > & matvec::Matrix< T >::operator/= const T &    x [inline]
 

Definition at line 376 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00377 {
00378    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) me[i][j] /= s;
00379    return *this;
00380 }

template<class T>
Matrix< T > & matvec::Matrix< T >::operator/= const Matrix< T > &    a [inline]
 

Definition at line 351 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00352 {
00353    if (nrow != a.nrow || ncol != a.ncol) throw exception("Matrix<T>::operator/=: size not conformable");
00354    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) me[i][j] /= a[i][j];
00355    return *this;
00356 }

template<class T>
Matrix< bool > matvec::Matrix< T >::operator< const T &    x const [inline]
 

Definition at line 405 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00406 {
00407    Matrix<bool> temp(nrow,ncol);
00408    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) temp[i][j] = (me[i][j] < x);
00409    return temp;
00410 }

template<class T>
Matrix< bool > matvec::Matrix< T >::operator< const Matrix< T > &    a const [inline]
 

Definition at line 397 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00398 {
00399    if (nrow != a.nrow || ncol != a.ncol) throw exception("Matrix<T>::operator<: size not conformable");
00400    Matrix<bool> temp(nrow,ncol);
00401    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) temp[i][j] = (me[i][j] < a[i][j]);
00402    return temp;
00403 }

template<class T>
Matrix< bool > matvec::Matrix< T >::operator<= const T &    x const [inline]
 

Definition at line 450 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00451 {
00452    Matrix<bool> temp(nrow,ncol);
00453    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) temp[i][j] = (me[i][j] <= x);
00454    return temp;
00455 }

template<class T>
Matrix< bool > matvec::Matrix< T >::operator<= const Matrix< T > &    a const [inline]
 

Definition at line 442 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00443 {
00444    if (nrow != a.nrow || ncol != a.ncol) throw exception("Matrix<T>::operator<=: size not conformable");
00445    Matrix<bool> temp(nrow,ncol);
00446    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) temp[i][j] = (me[i][j] <= a[i][j]);
00447    return temp;
00448 }

template<class T>
Matrix& matvec::Matrix< T >::operator= const T &    x [inline]
 

Definition at line 90 of file matrix.h.

00090 { return assign(x); }

template<class T>
Matrix& matvec::Matrix< T >::operator= const Matrix< T > &    a [inline]
 

Definition at line 89 of file matrix.h.

00089 { return assign(a); }

template<class T>
Matrix< bool > matvec::Matrix< T >::operator== const T &    x const [inline]
 

Definition at line 390 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00391 {
00392    Matrix<bool> temp(nrow,ncol);
00393    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) temp[i][j] = (me[i][j] == x);
00394    return temp;
00395 }

template<class T>
Matrix< bool > matvec::Matrix< T >::operator== const Matrix< T > &    a const [inline]
 

Definition at line 382 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00383 {
00384    if (nrow != a.nrow || ncol != a.ncol)  throw exception("Matrix<T>::operator==: size not conformable");
00385    Matrix<bool> temp(nrow,ncol);
00386    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) temp[i][j] = (me[i][j] == a[i][j]);
00387    return temp;
00388 }

template<class T>
Matrix< bool > matvec::Matrix< T >::operator> const T &    x const [inline]
 

Definition at line 420 of file matrix.h.

References matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00421 {
00422    Matrix<bool> temp(nrow,ncol);
00423    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) temp[i][j] = (me[i][j] > x);
00424    return temp;
00425 }

template<class T>
Matrix< bool > matvec::Matrix< T >::operator> const Matrix< T > &    a const [inline]
 

Definition at line 412 of file matrix.h.

References matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00413 {
00414    if (nrow != a.nrow || ncol != a.ncol) throw exception("Matrix<T>::operator>: size not conformable");
00415    Matrix<bool> temp(nrow,ncol);
00416    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) temp[i][j] = (me[i][j] > a[i][j]);
00417    return temp;
00418 }

template<class T>
Matrix< bool > matvec::Matrix< T >::operator>= const T &    x const [inline]
 

Definition at line 466 of file matrix.h.

References matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00467 {
00468    Matrix<bool> temp(nrow,ncol);
00469    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) temp[i][j] = (me[i][j] >= x);
00470    return temp;
00471 }

template<class T>
Matrix< bool > matvec::Matrix< T >::operator>= const Matrix< T > &    a const [inline]
 

Definition at line 458 of file matrix.h.

References matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00459 {
00460    if (nrow != a.nrow || ncol != a.ncol) throw exception("Matrix<T>::operator>=: size not conformable");
00461    Matrix<bool> temp(nrow,ncol);
00462    for (int j,i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) temp[i][j] = (me[i][j] >= a[i][j]);
00463    return temp;
00464 }

template<class T>
const T* matvec::Matrix< T >::operator[] const size_type    i const [inline]
 

Definition at line 114 of file matrix.h.

00114 { return me[i]; }

template<class T>
T* matvec::Matrix< T >::operator[] const size_type    i [inline]
 

Definition at line 113 of file matrix.h.

00113 { return me[i]; }

template<class T>
std::ostream & matvec::Matrix< T >::print std::ostream &    os = std::cout const [inline, virtual]
 

Definition at line 863 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, matvec::Matrix< T >::nrow, matvec::Session::output_precision, and matvec::SESSION.

Referenced by matvec::Minimizer::praxis(), and matvec::Matrix< T >::save().

00864 {
00865    int i,j;
00866    for (i=0; i<nrow; ++i) {
00867      for (j=0; j<ncol; ++j)  {
00868         os << ' ' ;
00869         os.width(8) ;
00870         os.precision(SESSION.output_precision) ;
00871         os << me[i][j];
00872      }
00873       os <<  "\n";
00874    }
00875    return os;
00876 }

template<class T>
Matrix< T > & matvec::Matrix< T >::reserve const size_type    n,
const size_type    m
[inline]
 

Definition at line 253 of file matrix.h.

References matvec::Matrix< T >::clear(), matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

Referenced by matvec::Matrix< T >::copy(), matvec::doubleMatrix::eigen(), matvec::doubleMatrix::ginv0(), matvec::doubleMatrix::inv(), matvec::BGMatrix::inv(), and matvec::doubleMatrix::norm().

00254 {
00255    if (m != nrow || n != ncol) {
00256       clear();
00257       nrow = m;
00258       ncol = n;
00259       if(nrow>0){
00260         me = new T* [nrow];
00261       }
00262       else {
00263         me = 0;
00264         return *this;
00265       }
00266       assert( me != 0 );
00267       for (int i=0; i<nrow; ++i) {
00268         if(ncol>0){
00269           me[i] = new T [ncol];
00270         }
00271         else {
00272           me[i] = 0;
00273         }
00274          assert( me[i] != 0 );
00275       }
00276    }
00277    return *this;
00278 }

template<class T>
Matrix< T > matvec::Matrix< T >::reshape const size_type    m,
const size_type    n,
orientation    orient = COLUMN
const [inline]
 

Definition at line 695 of file matrix.h.

References matvec::Matrix< T >::COLUMN, matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, matvec::Matrix< T >::nrow, and matvec::Matrix< T >::ROW.

00696 {
00697    Matrix<T> temp(m,n);
00698    int i,j,t,k;
00699    if (orient == ROW) {
00700       for (t=0,k=0,i=0; i<m; ++i) for (j=0; j<n; ++j) {
00701          if (k >= ncol) {
00702             t++;
00703             if (t >= nrow) return temp;
00704             k = 0;
00705          }
00706          temp[i][j] = me[t][k++];
00707       }
00708    } else if (orient == COLUMN) {
00709       for (t=0,k=0,i=0; i<m; ++i) for (j=0; j<n; ++j) {
00710          if (t >= nrow) {
00711             k++;
00712             if (k >= ncol) return temp;
00713             t = 0;
00714          }
00715          temp[i][j] = me[t++][k];
00716       }
00717    } else {
00718       std::cerr << "unknow orientation\n";
00719       exit(1);
00720    }
00721    return temp;
00722 }

template<class T>
Matrix& matvec::Matrix< T >::resize const Matrix< T > &    a [inline]
 

Definition at line 86 of file matrix.h.

00086 {resize(a.ne); return *this;}

template<class T>
Matrix< T > & matvec::Matrix< T >::resize const size_type    n,
const size_type    m,
const T *    a
[inline]
 

Definition at line 302 of file matrix.h.

References matvec::Matrix< T >::clear(), matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00303 {
00304    if (m == 0 || n == 0) {
00305       clear();
00306    } else {
00307       int i,j;
00308       if (m != nrow || n != ncol) {
00309          clear();
00310          nrow = m;
00311          ncol = n;
00312          me = new T* [nrow];
00313          assert( me != 0 );
00314          for (i=0; i<nrow; ++i) {
00315             me[i] = new T [ncol];
00316             assert( me[i] != 0 );
00317          }
00318       }
00319       for (i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) me[i][j] = *a++;
00320    }
00321    return *this;
00322 }

template<class T>
Matrix< T > & matvec::Matrix< T >::resize const size_type    n,
const size_type    m,
const T &    val = T()
[inline]
 

Definition at line 280 of file matrix.h.

References matvec::Matrix< T >::clear(), matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

Referenced by matvec::Matrix< T >::assign(), matvec::Model::getIBDMatrix(), matvec::Matrix< T >::input(), matvec::Matrix< unsigned >::resize(), matvec::Model::RSamplerGibbs(), matvec::Model::RSamplerGibbsMH(), and matvec::Model::RSamplerMH().

00281 {
00282    if (m == 0 || n == 0) {
00283       clear();
00284    } else {
00285       int i,j;
00286       if (m != nrow || n != ncol) {
00287          clear();
00288          nrow = m;
00289          ncol = n;
00290          me = new T* [nrow];
00291          assert( me != 0 );
00292          for (i=0; i<nrow; ++i) {
00293             me[i] = new T [ncol];
00294             assert( me[i] != 0 );
00295          }
00296       }
00297       for (i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) me[i][j] = val;
00298    }
00299    return *this;
00300 }

template<class T>
bool matvec::Matrix< T >::save const std::string &    fname,
const int    io_mode = std::ios::out
const [inline]
 

Definition at line 589 of file matrix.h.

References matvec::Matrix< T >::print().

00590 {
00591    std::ofstream ofs(fname.c_str(),(OpenModeType)io_mode);
00592    if (ofs) {
00593       print(ofs);
00594       ofs.close();
00595    } else {
00596       std::cerr << fname << ": cannot open\n";
00597    }
00598    return true;
00599 }

template<class T>
int matvec::Matrix< T >::size void    const [inline]
 

Definition at line 161 of file matrix.h.

00161 { return nrow*ncol; }

template<class T>
Matrix< T > & matvec::Matrix< T >::sortby orientation    orient,
const size_type    k
[inline]
 

Definition at line 878 of file matrix.h.

References matvec::Matrix< T >::COLUMN, matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, matvec::Matrix< T >::nrow, and matvec::Matrix< T >::ROW.

00879 {
00880     int n = 1;
00881     Vector<int> by(n);
00882     by[0] = t;
00883 
00884     int nstack = 100;
00885     int l,r,i,j,k,j1;
00886     T a1,a2;
00887     Vector<T> x(n);                         // allocating for x
00888     Matrix<int> stack(2,nstack);              // allocating for stack
00889     int s = 0;
00890     stack[s][s] = 0;
00891 
00892    if (orient == COLUMN) {
00893       stack[1][0] = nrow-1;
00894       do {
00895          l = stack[0][s]; r = stack[1][s]; s -= 1;
00896          do {
00897             i = l; j = r; j1 = (l+r)/2;
00898             for (k=0; k<n; k++)  x[k] = me[j1][by[k]];
00899             do {
00900                k = 0;
00901                while (k < n) {
00902                   a1 = me[i][by[k]]; a2 = x[k];
00903                   if (a1 < a2) {
00904                      i += 1; k = 0;
00905                   }
00906                   else if (a1 == a2) {
00907                      k += 1;
00908                   }
00909                   else if (a1 > a2) break;
00910                }
00911                k = 0;
00912                while (k < n) {
00913                   a1 = me[j][by[k]]; a2 = x[k];
00914                   if (a1 > a2) {
00915                      j -= 1; k = 0;
00916                   }
00917                   else if (a1 == a2) {
00918                      k += 1;
00919                   }
00920                   else if (a1 < a2) break;
00921                }
00922 
00923                if (i <= j) {
00924                   for (k=0; k<ncol; k++) {
00925                      a1 = me[i][k];
00926                      me[i][k] = me[j][k];
00927                      me[j][k] = a1;
00928                   }
00929                   i += 1;  j -= 1;
00930                }
00931             } while (i <= j);
00932             if (i < r) {
00933                s += 1;
00934                if (s >= nstack-1) {
00935                   std::cerr << " NSTACK " << nstack << " too small in SORTQR\n";
00936                   s = -1;
00937                   break;
00938                }
00939                stack[0][s] = i;  stack[1][s] = r;
00940             }
00941             r = j;
00942          } while (l < r);
00943       } while (s >= 0);
00944    } else if (orient == ROW) {
00945       stack[1][0] = ncol - 1;
00946       do {
00947          l = stack[0][s]; r = stack[1][s]; s -= 1;
00948          do {
00949             i = l; j = r; j1 = (l+r)/2;
00950             for (k=0; k<n; k++)  x[k] = me[by[k]][j1];
00951             do {
00952                k = 0;
00953                while (k < n) {
00954                   a1 = me[by[k]][i]; a2 = x[k];
00955                   if (a1 < a2) {
00956                      i += 1; k = 0;
00957                   }
00958                   else if (a1 == a2) {
00959                      k += 1;
00960                   }
00961                   else if (a1 > a2) break;
00962                }
00963                k = 0;
00964                while (k < n) {
00965                   a1 = me[by[k]][j]; a2 = x[k];
00966                   if (a1 > a2) {
00967                      j -= 1; k = 0;
00968                   }
00969                   else if (a1 == a2) {
00970                      k += 1;
00971                   }
00972                   else if (a1 < a2) break;
00973                }
00974                if (i <= j) {
00975                   for (k=0; k<nrow; k++) {
00976                      a1 = me[k][i];
00977                      me[k][i] = me[k][j];
00978                      me[k][j] = a1;
00979                   }
00980                   i += 1;  j -= 1;
00981                }
00982             } while (i <= j);
00983             if (i < r) {
00984                s += 1;
00985                if (s >= nstack-1) {
00986                   std::cerr << " NSTACK " << nstack << " too small in SORTQR\n";
00987                   s = -1;
00988                   break;
00989                }
00990                stack[0][s] = i;  stack[1][s] = r;
00991             }
00992             r = j;
00993          } while (l < r);
00994       } while (s >= 0);
00995    } else {
00996       std::cerr << "unknow orientation\n";
00997       exit(1);
00998    }
00999    return *this;
01000 }

template<class T>
Matrix< T > matvec::Matrix< T >::submat const Matrix< bool > &    a const [inline]
 

Definition at line 654 of file matrix.h.

00655 {
00656    int n = 0;
00657 //   int m = v.size();
00658 //   bool *ve_pt = v.ve;
00659 //   int i;
00660 //   for (i=0; i<m; i++) if (*ve_pt++) n++;
00661 //
00662    Matrix<T> temp(n);
00663 //   T *t_pt = temp.begin();
00664 //   ve_pt = v.ve;
00665 //   for (i=0; i<m; i++) if (*ve_pt++) *t_pt++ = ve[i];
00666    return temp;
00667 }

template<class T>
Matrix< T > matvec::Matrix< T >::submat const size_type    idx1,
const size_type    idx2,
const int    len1 = 0,
const int    len2 = 0
const [inline]
 

Definition at line 630 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00631 {
00632    int ir,ic,i,j,t,k;
00633    if (len1 == 0) {
00634       ir = nrow - 1;
00635    } else {
00636       ir = idx1 + len1 - 1;
00637    }
00638    if (len2 == 0) {
00639       ic = ncol - 1;
00640    } else {
00641       ic = idx2 + len2 - 1;
00642    }
00643    Matrix<T> temp(len1,len2);
00644    for (i=idx1; i<= ir; ++i) {
00645       t = i - idx1;
00646       for (j=idx2; j<=ic; ++j) {
00647          k = j - idx2;
00648          temp[t][k] = me[i][j];
00649       }
00650    }
00651    return temp;
00652 }

template<class T>
Vector< T > matvec::Matrix< T >::sum orientation    orient = COLUMN const [inline]
 

Definition at line 761 of file matrix.h.

References matvec::Matrix< T >::COLUMN, matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, matvec::Matrix< T >::nrow, matvec::Vector< T >::reserve(), and matvec::Matrix< T >::ROW.

00762 {
00763    Vector<T> temp;
00764    if (!me) return temp;
00765    int i,j;
00766    T init;
00767    if (orient == ROW) {
00768       temp.reserve(nrow);
00769       for (i=0; i<nrow; ++i) {
00770          init = T();
00771          for (j=0; j<ncol; ++j) init += me[i][j];
00772          temp[i] = init;
00773       }
00774    } else if (orient == COLUMN)  {
00775       temp.reserve(ncol);
00776       for (j=0; j<ncol; ++j) {
00777          init = T();
00778          for (i=0; i<nrow; ++i) init += me[i][j];
00779          temp[j] = init;
00780       }
00781    } else {
00782       std::cerr << "unknow orientation\n";
00783       exit(1);
00784    }
00785    return temp;
00786 }

template<class T>
Vector< T > matvec::Matrix< T >::sumsq orientation    orient = COLUMN const [inline]
 

Definition at line 788 of file matrix.h.

References matvec::Matrix< T >::COLUMN, matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, matvec::Matrix< T >::nrow, matvec::Vector< T >::reserve(), and matvec::Matrix< T >::ROW.

00789 {
00790    Vector<T> temp;
00791    if (!me) return temp;
00792    int i,j;
00793    T init;
00794    if (orient == ROW) {
00795       temp.reserve(nrow);
00796       for (i=0; i<nrow; ++i) {
00797          init = T();
00798          for (j=0; j<ncol; ++j) init += me[i][j]*me[i][j];
00799          temp[i] = init;
00800       }
00801    } else if (orient == COLUMN)  {
00802       temp.reserve(ncol);
00803       for (j=0; j<ncol; ++j) {
00804          init = T();
00805          for (i=0; i<nrow; ++i) init += me[i][j]*me[i][j];
00806          temp[j] = init;
00807       }
00808    } else {
00809       std::cerr << "unknow orientation\n";
00810       exit(1);
00811    }
00812    return temp;
00813 }

template<class T>
bool matvec::Matrix< T >::symmetric void    const [inline]
 

Reimplemented in matvec::BGMatrix, and matvec::doubleMatrix.

Definition at line 582 of file matrix.h.

References matvec::Matrix< T >::me, and matvec::Matrix< T >::nrow.

00583 {
00584    if (!me) return false;
00585    for (int j,i=1; i<nrow; ++i) for (j=0; j<i; ++j) if (me[i][j] != me[j][i]) return false;
00586    return true;
00587 }

template<class T>
T matvec::Matrix< T >::trace   init = T() const [inline]
 

Definition at line 601 of file matrix.h.

References matvec::Matrix< T >::me, min, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

00602 {
00603    int n = std::min(nrow,ncol);
00604    for (int i=0; i<n; ++i) init += me[i][i];
00605    return init;
00606 }

template<class T>
Matrix< T > matvec::Matrix< T >::transpose void    const [inline]
 

Definition at line 669 of file matrix.h.

References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.

Referenced by matvec::Model::getIBDMatrix().

00670 {
00671    Matrix<T> temp(ncol,nrow);
00672    for (int j,i=0; i<ncol; ++i) for (j=0; j<nrow; ++j) temp[i][j] = me[j][i];
00673    return temp;
00674 }

template<class T>
Vector< T > matvec::Matrix< T >::vec orientation    orient = COLUMN const [inline]
 

Definition at line 744 of file matrix.h.

References matvec::Matrix< T >::COLUMN, matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, matvec::Matrix< T >::nrow, matvec::Vector< T >::reserve(), and matvec::Matrix< T >::ROW.

00745 {
00746    Vector<T> temp;
00747    if (!me) return temp;
00748    temp.reserve(nrow*ncol);
00749    int i,j,t=0;
00750    if (orient == ROW) {
00751       for (i=0; i<nrow; ++i) for (j=0; j<ncol; ++j) temp[t++] = me[i][j];
00752    } else if (orient == COLUMN)  {
00753       for (j=0; j<ncol; ++j) for (i=0; i<nrow; ++i) temp[t++] = me[i][j];
00754    } else {
00755       std::cerr << "unknow orientation\n";
00756       exit(1);
00757    }
00758    return temp;
00759 }


Member Data Documentation

template<class T>
T** matvec::Matrix< T >::me
 

Definition at line 170 of file matrix.h.

Referenced by matvec::Matrix< T >::all(), matvec::Matrix< T >::any(), matvec::Matrix< T >::apply(), matvec::Matrix< T >::at(), matvec::Matrix< unsigned >::begin(), matvec::Matrix< T >::clear(), matvec::Matrix< T >::copy(), matvec::Matrix< T >::diag(), matvec::Matrix< T >::initialize(), matvec::Matrix< T >::input(), matvec::Matrix< T >::kron(), matvec::Matrix< unsigned >::Matrix(), matvec::Matrixwbg< T >::Matrixwbg(), matvec::Matrix< T >::max(), matvec::Matrix< T >::min(), matvec::Matrix< T >::operator *(), matvec::Matrix< T >::operator *=(), matvec::Matrix< T >::operator!=(), matvec::Matrix< T >::operator()(), matvec::Matrix< T >::operator+(), matvec::Matrix< T >::operator+=(), matvec::Matrix< T >::operator-(), matvec::Matrix< T >::operator-=(), matvec::Matrix< T >::operator/(), matvec::Matrix< T >::operator/=(), matvec::Matrix< T >::operator<(), matvec::Matrix< T >::operator<=(), matvec::Matrix< T >::operator==(), matvec::Matrix< unsigned >::operator[](), matvec::Matrix< T >::print(), matvec::Matrix< T >::reserve(), matvec::Matrix< T >::reshape(), matvec::Matrix< T >::resize(), matvec::Matrix< T >::sortby(), matvec::Matrix< T >::submat(), matvec::Matrix< T >::sum(), matvec::Matrix< T >::sumsq(), matvec::Matrix< T >::symmetric(), matvec::Matrix< T >::trace(), matvec::Matrix< T >::transpose(), and matvec::Matrix< T >::vec().

template<class T>
int matvec::Matrix< T >::ncol
 

Definition at line 171 of file matrix.h.

Referenced by matvec::Matrix< T >::all(), matvec::Matrix< T >::any(), matvec::Matrix< T >::apply(), matvec::Matrix< T >::assign(), matvec::Matrix< T >::at(), matvec::Matrix< T >::clear(), matvec::Matrix< T >::copy(), matvec::Matrix< T >::diag(), matvec::Matrix< unsigned >::empty(), matvec::Matrix< T >::initialize(), matvec::Matrix< T >::kron(), matvec::Matrix< unsigned >::Matrix(), matvec::Matrixwbg< T >::Matrixwbg(), matvec::Matrix< T >::max(), matvec::Matrix< T >::min(), matvec::Matrix< unsigned >::num_cols(), matvec::Matrix< T >::operator *(), matvec::Matrix< T >::operator *=(), matvec::Matrix< T >::operator!=(), matvec::Matrix< T >::operator()(), matvec::Matrix< T >::operator+(), matvec::Matrix< T >::operator+=(), matvec::Matrix< T >::operator-(), matvec::Matrix< T >::operator-=(), matvec::Matrix< T >::operator/(), matvec::Matrix< T >::operator/=(), matvec::Matrix< T >::operator<(), matvec::Matrix< T >::operator<=(), matvec::Matrix< T >::operator==(), matvec::Matrix< T >::operator>(), matvec::Matrix< T >::operator>=(), matvec::Matrix< T >::print(), matvec::Matrix< T >::reserve(), matvec::Matrix< T >::reshape(), matvec::Matrix< T >::resize(), matvec::Matrix< unsigned >::size(), matvec::Matrix< T >::sortby(), matvec::Matrix< T >::submat(), matvec::Matrix< T >::sum(), matvec::Matrix< T >::sumsq(), matvec::Matrix< T >::trace(), matvec::Matrix< T >::transpose(), and matvec::Matrix< T >::vec().

template<class T>
int matvec::Matrix< T >::nrow
 

Definition at line 171 of file matrix.h.

Referenced by matvec::Matrix< T >::all(), matvec::Matrix< T >::any(), matvec::Matrix< T >::apply(), matvec::Matrix< T >::assign(), matvec::Matrix< T >::at(), matvec::Matrix< T >::clear(), matvec::Matrix< T >::copy(), matvec::Matrix< T >::diag(), matvec::Matrix< unsigned >::empty(), matvec::Matrix< T >::initialize(), matvec::Matrix< T >::kron(), matvec::Matrix< unsigned >::Matrix(), matvec::Matrixwbg< T >::Matrixwbg(), matvec::Matrix< T >::max(), matvec::Matrix< T >::min(), matvec::Matrix< unsigned >::num_rows(), matvec::Matrix< T >::operator *(), matvec::Matrix< T >::operator *=(), matvec::Matrix< T >::operator!=(), matvec::Matrix< T >::operator()(), matvec::Matrix< T >::operator+(), matvec::Matrix< T >::operator+=(), matvec::Matrix< T >::operator-(), matvec::Matrix< T >::operator-=(), matvec::Matrix< T >::operator/(), matvec::Matrix< T >::operator/=(), matvec::Matrix< T >::operator<(), matvec::Matrix< T >::operator<=(), matvec::Matrix< T >::operator==(), matvec::Matrix< T >::operator>(), matvec::Matrix< T >::operator>=(), matvec::Matrix< T >::print(), matvec::Matrix< T >::reserve(), matvec::Matrix< T >::reshape(), matvec::Matrix< T >::resize(), matvec::Matrix< unsigned >::size(), matvec::Matrix< T >::sortby(), matvec::Matrix< T >::submat(), matvec::Matrix< T >::sum(), matvec::Matrix< T >::sumsq(), matvec::Matrix< T >::symmetric(), matvec::Matrix< T >::trace(), matvec::Matrix< T >::transpose(), and matvec::Matrix< T >::vec().


The documentation for this class was generated from the following file:
Generated on Thu Jun 16 17:14:35 2005 for Matvec by doxygen1.2.16