#include <matrix.h>
Inheritance diagram for matvec::Matrix< T >:

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 |
| T | 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 |
|
|||||
|
|
|
|||||
|
|
|
|||||
|
|
|
|||||
|
|
|
|||||
|
|
|
|||||
|
|
|
|||||
|
|
|
|||||
|
|
|
|||||
|
|
|
|||||
|
Reimplemented in matvec::Matrixwbg< T >. Definition at line 44 of file matrix.h. Referenced by matvec::Matrix< unsigned >::Matrix(), and matvec::Matrix< unsigned >::operator[](). |
|
|||||
|
|
|
|||||
|
Definition at line 56 of file matrix.h.
|
|
||||||||||
|
Definition at line 58 of file matrix.h.
00058 {
00059 //std::cout <<"constructor 1\n";
00060 initialize(0,0,0); //Constructor 1
00061 }
|
|
||||||||||||||||
|
Definition at line 62 of file matrix.h.
00062 {
00063 //std::cout <<"constructor 2\n";
00064 initialize(m,n,0); //Constructor 2
00065 }
|
|
||||||||||||||||||||
|
Definition at line 66 of file matrix.h.
00066 {
00067 //std::cout <<"constructor 3\n";
00068 initialize(m,n,a); //Constructor 3
00069 }
|
|
||||||||||
|
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 }
|
|
||||||||||
|
Definition at line 78 of file matrix.h.
00078 {clear();} // Destructor
|
|
||||||||||
|
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().
|
|
||||||||||
|
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().
|
|
||||||||||||||||
|
Definition at line 623 of file matrix.h. References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||||||||
|
Definition at line 615 of file matrix.h. References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
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().
|
|
||||||||||
|
Definition at line 243 of file matrix.h. References matvec::Matrix< T >::ncol, matvec::Matrix< T >::nrow, and matvec::Matrix< T >::resize().
|
|
||||||||||
|
Definition at line 81 of file matrix.h. Referenced by matvec::Matrix< unsigned >::operator=().
00081 {copy(a); return *this;}
|
|
||||||||||||||||
|
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().
|
|
||||||||||
|
Definition at line 76 of file matrix.h.
00076 { return (const T**)me; }
|
|
||||||||||
|
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; }
|
|
||||||||||
|
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().
|
|
||||||||||
|
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 }
|
|
||||||||||
|
Definition at line 732 of file matrix.h. References matvec::Matrix< T >::me, min, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
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().
|
|
||||||||||
|
Definition at line 138 of file matrix.h.
|
|
||||||||||||||||||||
|
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 }
|
|
||||||||||||||||||||
|
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 }
|
|
||||||||||
|
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 }
|
|
||||||||||
|
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 }
|
|
||||||||||
|
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 }
|
|
||||||||||
|
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; }
|
|
||||||||||
|
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; }
|
|
||||||||||
|
Definition at line 540 of file matrix.h. References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
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().
|
|
||||||||||
|
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 }
|
|
||||||||||
|
Definition at line 370 of file matrix.h. References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
Definition at line 344 of file matrix.h. References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
Definition at line 561 of file matrix.h.
|
|
||||||||||
|
Definition at line 435 of file matrix.h. References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
Definition at line 427 of file matrix.h. References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||||||||
|
Definition at line 324 of file matrix.h. References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
Definition at line 117 of file matrix.h.
00117 { return *this; } //unary plus
|
|
||||||||||
|
Definition at line 526 of file matrix.h. References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
Definition at line 473 of file matrix.h. References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
Definition at line 358 of file matrix.h. References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
Definition at line 330 of file matrix.h. References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
Definition at line 554 of file matrix.h.
|
|
||||||||||
|
Definition at line 533 of file matrix.h. References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
Definition at line 481 of file matrix.h. References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
Definition at line 364 of file matrix.h. References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
Definition at line 337 of file matrix.h. References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
Definition at line 547 of file matrix.h. References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
Definition at line 517 of file matrix.h. References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
Definition at line 376 of file matrix.h. References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
Definition at line 351 of file matrix.h. References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
Definition at line 405 of file matrix.h. References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
Definition at line 397 of file matrix.h. References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
Definition at line 450 of file matrix.h. References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
Definition at line 442 of file matrix.h. References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
Definition at line 90 of file matrix.h.
00090 { return assign(x); }
|
|
||||||||||
|
Definition at line 89 of file matrix.h.
00089 { return assign(a); }
|
|
||||||||||
|
Definition at line 390 of file matrix.h. References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
Definition at line 382 of file matrix.h. References matvec::Matrix< T >::me, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
Definition at line 420 of file matrix.h. References matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
Definition at line 412 of file matrix.h. References matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
Definition at line 466 of file matrix.h. References matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
Definition at line 458 of file matrix.h. References matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
Definition at line 114 of file matrix.h.
00114 { return me[i]; }
|
|
||||||||||
|
Definition at line 113 of file matrix.h.
00113 { return me[i]; }
|
|
||||||||||
|
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().
|
|
||||||||||||||||
|
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 }
|
|
||||||||||||||||||||
|
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 }
|
|
||||||||||
|
Definition at line 86 of file matrix.h.
00086 {resize(a.ne); return *this;}
|
|
||||||||||||||||||||
|
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 }
|
|
||||||||||||||||||||
|
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 }
|
|
||||||||||||||||
|
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 }
|
|
||||||||||
|
Definition at line 161 of file matrix.h.
|
|
||||||||||||||||
|
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 }
|
|
||||||||||
|
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 }
|
|
||||||||||||||||||||||||
|
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 }
|
|
||||||||||
|
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 }
|
|
||||||||||
|
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 }
|
|
||||||||||
|
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.
|
|
||||||||||
|
Definition at line 601 of file matrix.h. References matvec::Matrix< T >::me, min, matvec::Matrix< T >::ncol, and matvec::Matrix< T >::nrow.
|
|
||||||||||
|
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().
|
|
||||||||||
|
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 }
|
|
|||||
|
|||||
|
|||||
1.2.16