00001
00002
00003 #ifndef CH_MATRIX_CLASSES__INDEXMAT_HXX
00004 #define CH_MATRIX_CLASSES__INDEXMAT_HXX
00005
00015 #include <iostream>
00016 #include <iomanip>
00017 #include <vector>
00018 #include <math.h>
00019 #ifndef CH_MATRIX_CLASSES__MEMARRAY_HXX
00020 #include "memarray.hxx"
00021 #endif
00022 #ifndef CH_MATRIX_CLASSES__MYMATH_HXX
00023 #include "mymath.hxx"
00024 #endif
00025
00026
00027 namespace CH_Matrix_Classes {
00028
00029
00030
00031
00032
00033
00034
00035
00039
00040
00041
00042
00043
00044
00045
00047 class Range
00048 {
00049 public:
00051 Integer from;
00053 Integer to;
00055 Integer step;
00056
00058 Range(Integer _from,Integer _to,Integer _step=1):from(_from),to(_to),step(_step){}
00060 ~Range(){}
00061 };
00062
00064
00065
00066
00067
00068
00069
00070
00071 class Matrix;
00072 class Symmatrix;
00073 class Sparsemat;
00074 class Sparsesym;
00075
00079
00092 class Indexmatrix: protected Memarrayuser
00093 {
00094 friend class Matrix;
00095 friend class Symmatrix;
00096 friend class Sparsemat;
00097 friend class Sparsesym;
00098
00099
00100 private:
00101 static const Mtype mtype;
00102 Integer mem_dim;
00103 Integer nr,
00104 nc;
00105 Integer *m;
00106
00107 bool is_init;
00108
00110 inline void init_to_zero();
00111
00112 public:
00113
00114
00115
00116
00117
00121
00123 inline Indexmatrix();
00124
00126 inline Indexmatrix(const Indexmatrix& A,Integer d=1);
00127
00129 inline Indexmatrix(const Range&);
00130
00137 inline Indexmatrix(Integer nr,Integer nc);
00138
00140 inline Indexmatrix(Integer nr,Integer nc,Integer d);
00141
00143 inline Indexmatrix(Integer nr,Integer nc,const Integer* dp,Integer incr=1);
00144
00146 inline Indexmatrix(const std::vector<Integer>& vec);
00147
00149 ~Indexmatrix(){memarray->free(m);}
00150
00151 #if (CONICBUNDLE_DEBUG>=1)
00153 void set_init(bool i){is_init=i;}
00155 bool get_init() const {return is_init;}
00156 #else
00158 void set_init(bool ){}
00160 bool get_init() const {return true;}
00161 #endif
00162
00164 inline Indexmatrix& init(const Indexmatrix &A,Integer d=1);
00165
00167 Indexmatrix& init(const Range&);
00168
00170 inline Indexmatrix& init(Integer nr,Integer nc,Integer d);
00171
00173 inline Indexmatrix& init(Integer nr,Integer nc,const Integer *dp,Integer incr=1);
00174
00176 inline Indexmatrix& init(const std::vector<Integer>& vec);
00177
00184 void newsize(Integer nr,Integer nc);
00185
00187
00191
00193 Indexmatrix(const Matrix&);
00195 Indexmatrix(const Symmatrix&);
00197 Indexmatrix(const Sparsemat&);
00199 Indexmatrix(const Sparsesym&);
00200
00202
00203
00204
00205
00206
00210
00212 void dim(Integer& _nr, Integer& _nc) const {_nr=nr; _nc=nc;}
00213
00215 Integer dim() const {return nr*nc;}
00216
00218 Integer rowdim() const {return nr;}
00219
00221 Integer coldim() const {return nc;}
00222
00224 Mtype get_mtype() const {return mtype;}
00225
00227
00228
00229
00230
00231
00232
00236
00238 inline Integer& operator()(Integer i,Integer j);
00239
00241 inline Integer& operator()(Integer i);
00242
00244 inline Integer operator()(Integer i,Integer j) const;
00245
00247 inline Integer operator()(Integer i) const;
00248
00250 Indexmatrix operator()(const Indexmatrix& vecrow,const Indexmatrix& veccol) const;
00251
00253 Indexmatrix operator()(const Indexmatrix& A) const;
00254
00255
00256
00258 inline Integer& operator[](Integer i);
00259
00261 inline Integer operator[](Integer i) const;
00262
00264 Indexmatrix col(Integer i) const;
00266 Indexmatrix row(Integer i) const;
00268 Indexmatrix cols(const Indexmatrix &vec) const;
00269
00271 Indexmatrix rows(const Indexmatrix &vec) const;
00272
00273
00275 Indexmatrix& triu(Integer d=0);
00276
00278 Indexmatrix& tril(Integer d=0);
00279
00281 Indexmatrix& subassign(const Indexmatrix& vecrow,const Indexmatrix& veccol,
00282 const Indexmatrix& A);
00283
00284
00286 Indexmatrix& subassign(const Indexmatrix& vec,const Indexmatrix& A);
00287
00289 Indexmatrix& delete_rows(const Indexmatrix& ind);
00291 Indexmatrix& delete_cols(const Indexmatrix& ind);
00292
00294 Indexmatrix& insert_row(Integer i,const Indexmatrix& v);
00296 Indexmatrix& insert_col(Integer i,const Indexmatrix& v);
00297
00299 inline Indexmatrix& reduce_length(Integer n);
00300
00302 Indexmatrix& concat_right(const Indexmatrix& A);
00304 Indexmatrix& concat_below(const Indexmatrix& A);
00306 Indexmatrix& concat_below(Integer d);
00308 Indexmatrix& concat_right(Integer d);
00309
00310
00312 Integer* get_store() {return m;}
00314 const Integer* get_store() const {return m;}
00315
00317
00318
00322
00323
00325 friend Indexmatrix diag(const Indexmatrix& A);
00326
00328 friend inline Indexmatrix triu(const Indexmatrix& A,Integer d=0);
00329
00331 friend inline Indexmatrix tril(const Indexmatrix& A,Integer d=0);
00332
00334 friend inline Indexmatrix concat_right(const Indexmatrix& A,const Indexmatrix& B);
00336 friend inline Indexmatrix concat_below(const Indexmatrix& A,const Indexmatrix& B);
00337
00339 friend void swap(Indexmatrix &A,Indexmatrix &B);
00340
00342
00343
00344
00345
00346
00347
00351
00353 Indexmatrix& xeya(const Indexmatrix& A,Integer d=1);
00355 Indexmatrix& xpeya(const Indexmatrix& A,Integer d=1);
00356
00358
00362
00364 friend Indexmatrix& xbpeya(Indexmatrix& x,const Indexmatrix& y,Integer alpha=1,Integer beta=0,int ytrans=0);
00365
00367 friend Indexmatrix& xeyapzb(Indexmatrix& x,const Indexmatrix& y,const Indexmatrix& z,Integer alpha=1,Integer beta=1);
00368
00370 friend Indexmatrix& genmult(const Indexmatrix& A,const Indexmatrix& B,Indexmatrix& C,
00371 Integer alpha=1,Integer beta=0,int atrans=0,int btrans=0);
00372
00374
00375
00376
00377
00378
00379
00383
00385 inline Indexmatrix& operator=(const Indexmatrix &A);
00387 inline Indexmatrix& operator*=(const Indexmatrix &s);
00389 inline Indexmatrix& operator+=(const Indexmatrix &v);
00391 inline Indexmatrix& operator-=(const Indexmatrix &v);
00393 inline Indexmatrix& operator%=(const Indexmatrix &A);
00395 inline Indexmatrix operator-() const;
00396
00398 inline Indexmatrix& operator*=(Integer d);
00400 inline Indexmatrix& operator/=(Integer d);
00402 inline Indexmatrix& operator%=(Integer d);
00404 inline Indexmatrix& operator+=(Integer d);
00406 inline Indexmatrix& operator-=(Integer d);
00407
00409 Indexmatrix& transpose();
00410
00412
00416
00418 friend inline Indexmatrix operator*(const Indexmatrix &A,const Indexmatrix& B);
00420 friend inline Indexmatrix operator+(const Indexmatrix &A,const Indexmatrix& B);
00422 friend inline Indexmatrix operator-(const Indexmatrix &A,const Indexmatrix& B);
00424 friend inline Indexmatrix operator%(const Indexmatrix &A,const Indexmatrix& B);
00426 friend inline Indexmatrix operator*(const Indexmatrix &A,Integer d);
00428 friend inline Indexmatrix operator*(Integer d,const Indexmatrix &A);
00430 friend inline Indexmatrix operator/(const Indexmatrix& A,Integer d);
00432 friend inline Indexmatrix operator%(const Indexmatrix& A,Integer d);
00433
00435 friend inline Indexmatrix operator+(const Indexmatrix& A,Integer d);
00437 friend inline Indexmatrix operator+(Integer d,const Indexmatrix& A);
00439 friend inline Indexmatrix operator-(const Indexmatrix& A,Integer d);
00441 friend inline Indexmatrix operator-(Integer d,const Indexmatrix& A);
00442
00444 friend Indexmatrix transpose(const Indexmatrix& A);
00445
00447
00448
00449
00450
00451
00455
00457 friend inline std::vector<int>& assign(std::vector<int>& vec,
00458 const Indexmatrix& A);
00460 friend inline std::vector<long>& assign(std::vector<long>& vec,
00461 const Indexmatrix& A);
00462
00464
00465
00466
00467
00468
00469
00473
00475 Indexmatrix& rand(Integer nr,Integer nc,Integer lowerb,Integer upperb,CH_Tools::GB_rand* random_generator=0);
00477 Indexmatrix& shuffle(CH_Tools::GB_rand* random_generator=0);
00479 Indexmatrix& sign(void);
00481 Indexmatrix& abs(void);
00482
00484
00488
00490 friend inline Indexmatrix rand(Integer nr,Integer nc,Integer lb,Integer ub,CH_Tools::GB_rand* random_generator=0);
00492 friend inline Indexmatrix sign(const Indexmatrix& A);
00493 friend Indexmatrix abs(const Indexmatrix& A);
00494
00496
00497
00498
00499
00500
00504
00506 Indexmatrix& scale_rows(const Indexmatrix& vec);
00508 Indexmatrix& scale_cols(const Indexmatrix& vec);
00509
00511
00515
00517 friend Integer trace(const Indexmatrix& A);
00519 friend inline Integer ip(const Indexmatrix& A, const Indexmatrix& B);
00521 friend inline Real norm2(const Indexmatrix& A);
00522
00523
00525 friend Indexmatrix sumrows(const Indexmatrix& A);
00527 friend Indexmatrix sumcols(const Indexmatrix& A);
00529 friend Integer sum(const Indexmatrix& A);
00530
00532
00533
00534
00535
00536
00537
00541
00543 Indexmatrix find() const;
00545 Indexmatrix find_number(Integer num=0) const;
00546
00548
00552
00554 friend Indexmatrix operator<(const Indexmatrix &A,const Indexmatrix &B);
00556 friend inline Indexmatrix operator>(const Indexmatrix &A,const Indexmatrix &B);
00558 friend Indexmatrix operator<=(const Indexmatrix &A,const Indexmatrix &B);
00560 friend inline Indexmatrix operator>=(const Indexmatrix &A,const Indexmatrix &B);
00562 friend Indexmatrix operator==(const Indexmatrix &A,const Indexmatrix &B);
00564 friend Indexmatrix operator!=(const Indexmatrix &A,const Indexmatrix &B);
00566 friend Indexmatrix operator<(const Indexmatrix &A,Integer d);
00568 friend Indexmatrix operator>(const Indexmatrix &A,Integer d);
00570 friend Indexmatrix operator<=(const Indexmatrix &A,Integer d);
00572 friend Indexmatrix operator>=(const Indexmatrix &A,Integer d);
00574 friend Indexmatrix operator==(const Indexmatrix &A,Integer d);
00576 friend Indexmatrix operator!=(const Indexmatrix &A,Integer d);
00578 friend inline Indexmatrix operator<(Integer d,const Indexmatrix &A);
00580 friend inline Indexmatrix operator>(Integer d,const Indexmatrix &A);
00582 friend inline Indexmatrix operator<=(Integer d,const Indexmatrix &A);
00584 friend inline Indexmatrix operator>=(Integer d,const Indexmatrix &A);
00586 friend inline Indexmatrix operator==(Integer d,const Indexmatrix &A);
00588 friend inline Indexmatrix operator!=(Integer d,const Indexmatrix &A);
00589
00591 friend Indexmatrix minrows(const Indexmatrix& A);
00593 friend Indexmatrix mincols(const Indexmatrix& A);
00595 friend Integer min(const Indexmatrix& A,Integer *iindex=0,Integer *jindex=0);
00597 friend Indexmatrix maxrows(const Indexmatrix& A);
00599 friend Indexmatrix maxcols(const Indexmatrix& A);
00601 friend Integer max(const Indexmatrix& A,Integer *iindex=0,Integer *jindex=0);
00602
00604 friend inline Indexmatrix sortindex(const Indexmatrix& vec);
00606 friend void sortindex(const Indexmatrix& vec,Indexmatrix &ind);
00607
00609 friend inline Indexmatrix find(const Indexmatrix& A);
00611 friend inline Indexmatrix find_number(const Indexmatrix& A,Integer num=0);
00612
00614
00615
00616
00617
00618
00622
00625 void display(std::ostream& out,
00626 int precision=0,
00627 int width=0,
00628 int screenwidth=0
00629 ) const;
00630
00632
00636
00638 friend std::ostream& operator<<(std::ostream& o,const Indexmatrix &A);
00640 friend std::istream& operator>>(std::istream& i,Indexmatrix &A);
00641
00643
00644 };
00645
00647
00648
00649
00650
00651
00652 Indexmatrix diag(const Indexmatrix& A);
00653 void swap(Indexmatrix &A,Indexmatrix &B);
00654 Indexmatrix& xbpeya(Indexmatrix& x,const Indexmatrix& y,Integer alpha,Integer beta,int ytrans);
00655 Indexmatrix& xeyapzb(Indexmatrix& x,const Indexmatrix& y,const Indexmatrix& z,Integer alpha,Integer beta);
00656 Indexmatrix& genmult(const Indexmatrix& A,const Indexmatrix& B,Indexmatrix& C,
00657 Integer alpha,Integer beta,int atrans,int btrans);
00658 Indexmatrix transpose(const Indexmatrix& A);
00659 Indexmatrix abs(const Indexmatrix& A);
00660 Integer trace(const Indexmatrix& A);
00661 Indexmatrix sumrows(const Indexmatrix& A);
00662 Indexmatrix sumcols(const Indexmatrix& A);
00663 Integer sum(const Indexmatrix& A);
00664 Indexmatrix operator<(const Indexmatrix &A,const Indexmatrix &B);
00665 Indexmatrix operator<=(const Indexmatrix &A,const Indexmatrix &B);
00666 Indexmatrix operator==(const Indexmatrix &A,const Indexmatrix &B);
00667 Indexmatrix operator!=(const Indexmatrix &A,const Indexmatrix &B);
00668 Indexmatrix operator<(const Indexmatrix &A,Integer d);
00669 Indexmatrix operator>(const Indexmatrix &A,Integer d);
00670 Indexmatrix operator<=(const Indexmatrix &A,Integer d);
00671 Indexmatrix operator>=(const Indexmatrix &A,Integer d);
00672 Indexmatrix operator==(const Indexmatrix &A,Integer d);
00673 Indexmatrix operator!=(const Indexmatrix &A,Integer d);
00674 Indexmatrix minrows(const Indexmatrix& A);
00675 Indexmatrix mincols(const Indexmatrix& A);
00676 Integer min(const Indexmatrix& A,Integer *iindex,Integer *jindex);
00677 Indexmatrix maxrows(const Indexmatrix& A);
00678 Indexmatrix maxcols(const Indexmatrix& A);
00679 Integer max(const Indexmatrix& A,Integer *iindex,Integer *jindex);
00680 Indexmatrix sortindex(const Indexmatrix& vec);
00681 void sortindex(const Indexmatrix& vec,Indexmatrix &ind);
00682 std::ostream& operator<<(std::ostream& o,const Indexmatrix &v);
00683 std::istream& operator>>(std::istream& i,Indexmatrix &v);
00684
00685
00686
00687
00688
00689
00690
00691
00692 inline void Indexmatrix::init_to_zero()
00693 {
00694 nr=nc=0;mem_dim=0;m=0;
00695 chk_set_init(*this,1);
00696 }
00697
00698 inline Indexmatrix& Indexmatrix::init(Integer inr,Integer inc,Integer d)
00699 {
00700 newsize(inr,inc);
00701 mat_xea(nr*nc,m,d);
00702 chk_set_init(*this,1);
00703 return *this;
00704 }
00705
00706 inline Indexmatrix& Indexmatrix::init(Integer inr,Integer inc,const Integer* d,Integer incr)
00707 {
00708 newsize(inr,inc);
00709 if (incr==1) mat_xey(nr*nc,m,d);
00710 else mat_xey(nr*nc,m,Integer(1),d,incr);
00711 chk_set_init(*this,1);
00712 return *this;
00713 }
00714
00715 inline Indexmatrix& Indexmatrix::init(const Indexmatrix& A,Integer d)
00716 {
00717 return xeya(A,d);
00718 }
00719
00720 inline Indexmatrix& Indexmatrix::init(const std::vector<Integer>& vec)
00721 {
00722 newsize(Integer(vec.size()),1); chk_set_init(*this,1);
00723 for(Integer i=0;i<nr;i++) m[i]=vec[i];
00724 return *this;
00725 }
00726
00727 inline Indexmatrix::Indexmatrix()
00728 {
00729 init_to_zero();
00730 }
00731
00732 inline Indexmatrix::Indexmatrix(const Indexmatrix &A,Integer d):Memarrayuser()
00733 {
00734 init_to_zero();
00735 xeya(A,d);
00736 }
00737
00738 inline Indexmatrix::Indexmatrix(Integer inr,Integer inc)
00739 {
00740 init_to_zero();
00741 newsize(inr,inc);
00742 }
00743
00744 inline Indexmatrix::Indexmatrix(const Range& range)
00745 {
00746 init_to_zero();
00747 init(range);
00748 }
00749
00750 inline Indexmatrix::Indexmatrix(Integer inr,Integer inc,Integer d)
00751 {
00752 init_to_zero();
00753 init(inr,inc,d);
00754 }
00755
00756 inline Indexmatrix::Indexmatrix(Integer inr,Integer inc,const Integer *d,Integer incr)
00757 {
00758 init_to_zero();
00759 init(inr,inc,d,incr);
00760 }
00761
00762 inline Indexmatrix::Indexmatrix(const std::vector<Integer>& vec)
00763 {
00764 init_to_zero();
00765 init(vec);
00766 }
00767
00768 inline Integer& Indexmatrix::operator()(Integer i,Integer j)
00769 {
00770 chk_range(i,j,nr,nc);
00771 return m[j*nr+i];
00772 }
00773
00774 inline Integer& Indexmatrix::operator()(Integer i)
00775 {
00776 chk_range(i,0,nr*nc,1);
00777 return m[i];
00778 }
00779
00780 inline Integer Indexmatrix::operator()(Integer i,Integer j) const
00781 {
00782 chk_range(i,j,nr,nc);
00783 return m[j*nr+i];
00784 }
00785
00786 inline Integer Indexmatrix::operator()(Integer i) const
00787 {
00788 chk_range(i,0,nr*nc,1);
00789 return m[i];
00790 }
00791
00792 inline Integer& Indexmatrix::operator[](Integer i)
00793 {return (*this)(i);}
00794
00795 inline Integer Indexmatrix::operator[](Integer i) const
00796 {return (*this)(i);}
00797
00798 inline Indexmatrix& Indexmatrix::reduce_length(Integer n)
00799 { nr=min(nr*nc,max(Integer(0),n)); nc=1; return *this;}
00800
00801
00802 inline Integer ip(const Indexmatrix& A, const Indexmatrix& B)
00803 {
00804 chk_add(A,B);
00805 return mat_ip(A.nc*A.nr,A.m,B.m);
00806 }
00807
00808 inline Real norm2(const Indexmatrix& A)
00809 {
00810 chk_init(A);
00811 return ::sqrt(double(mat_ip(A.nc*A.nr,A.m,A.m)));
00812 }
00813
00814 inline Indexmatrix& Indexmatrix::operator=(const Indexmatrix &A)
00815 { return xeya(A);}
00816
00817 inline Indexmatrix& Indexmatrix::operator*=(const Indexmatrix &A)
00818 { Indexmatrix C; return xeya(genmult(*this,A,C));}
00819
00820 inline Indexmatrix& Indexmatrix::operator+=(const Indexmatrix &A)
00821 { return xpeya(A); }
00822
00823 inline Indexmatrix& Indexmatrix::operator-=(const Indexmatrix &A)
00824 { return xpeya(A,-1); }
00825
00826 inline Indexmatrix& Indexmatrix::operator%=(const Indexmatrix &A)
00827 { chk_add(*this,A); mat_xhadey(nr*nc,m,A.m); return *this; }
00828
00829 inline Indexmatrix Indexmatrix::operator-() const
00830 { return Indexmatrix(*this,-1); }
00831
00832 inline Indexmatrix& Indexmatrix::operator*=(register Integer d)
00833 { chk_init(*this); mat_xmultea(nr*nc,m,d); return *this; }
00834
00835 inline Indexmatrix& Indexmatrix::operator/=(register Integer d)
00836 { chk_init(*this); mat_xdivea(nr*nc,m,d); return *this; }
00837
00838 inline Indexmatrix& Indexmatrix::operator%=(register Integer d)
00839 { chk_init(*this); mat_xmodea(nr*nc,m,d); return *this; }
00840
00841 inline Indexmatrix& Indexmatrix::operator+=(register Integer d)
00842 { chk_init(*this); mat_xpea(nr*nc,m,d); return *this; }
00843
00844 inline Indexmatrix& Indexmatrix::operator-=(register Integer d)
00845 { chk_init(*this); mat_xpea(nr*nc,m,-d); return *this; }
00846
00847
00848 inline Indexmatrix operator*(const Indexmatrix &A,const Indexmatrix &B)
00849 {Indexmatrix C; return genmult(A,B,C);}
00850 inline Indexmatrix operator+(const Indexmatrix &A,const Indexmatrix &B)
00851 {Indexmatrix C; return xeyapzb(C,A,B,1,1);}
00852 inline Indexmatrix operator-(const Indexmatrix &A,const Indexmatrix &B)
00853 {Indexmatrix C; return xeyapzb(C,A,B,1,-1);}
00854 inline Indexmatrix operator%(const Indexmatrix &A,const Indexmatrix &B)
00855 {Indexmatrix C(A); return C%=B;}
00856 inline Indexmatrix operator*(const Indexmatrix &A,Integer d)
00857 {return Indexmatrix(A,d);}
00858 inline Indexmatrix operator*(Integer d,const Indexmatrix &A)
00859 {return Indexmatrix(A,d);}
00860 inline Indexmatrix operator/(const Indexmatrix &A,Integer d)
00861 {Indexmatrix B(A); return B/=d;}
00862 inline Indexmatrix operator%(const Indexmatrix &A,Integer d)
00863 {Indexmatrix B(A); return B%=d;}
00864 inline Indexmatrix operator+(const Indexmatrix &A,Integer d)
00865 {Indexmatrix B(A); return B+=d;}
00866 inline Indexmatrix operator+(Integer d,const Indexmatrix &A)
00867 {Indexmatrix B(A); return B+=d;}
00868 inline Indexmatrix operator-(const Indexmatrix &A,Integer d)
00869 {Indexmatrix B(A); return B-=d;}
00870 inline Indexmatrix operator-(Integer d,const Indexmatrix &A)
00871 {Indexmatrix B(A,-1); return B+=d;}
00872
00873 inline Indexmatrix triu(const Indexmatrix& A,Integer i)
00874 {Indexmatrix B(A); B.triu(i); return B;}
00875 inline Indexmatrix tril(const Indexmatrix& A,Integer i)
00876 {Indexmatrix B(A); B.tril(i); return B;}
00877
00878 inline Indexmatrix concat_right(const Indexmatrix& A,const Indexmatrix& B)
00879 {Indexmatrix C(A.dim()+B.dim(),1);C=A;C.concat_right(B);return C;}
00880 inline Indexmatrix concat_below(const Indexmatrix& A,const Indexmatrix& B)
00881 {Indexmatrix C(A.dim()+B.dim(),1);C=A;C.concat_below(B);return C;}
00882
00883 inline void swap(Indexmatrix &A,Indexmatrix &B)
00884 {
00885 Integer *hm=A.m;A.m=B.m;B.m=hm;
00886 Integer hi=A.nr;A.nr=B.nr;B.nr=hi;
00887 hi=A.nc;A.nc=B.nc;B.nc=hi;
00888 hi=A.mem_dim;A.mem_dim=B.mem_dim;B.mem_dim=hi;
00889 #if (CONICBUNDLE_DEBUG>=1)
00890 hi=A.is_init;A.is_init=B.is_init;B.is_init=hi;
00891 #endif
00892 }
00893
00894 inline Indexmatrix rand(Integer rows,Integer cols,Integer lb,Integer ub,CH_Tools::GB_rand* random_generator)
00895 {Indexmatrix A; return A.rand(rows,cols,lb,ub,random_generator);}
00896 inline Indexmatrix sign(const Indexmatrix& A)
00897 {Indexmatrix B(A); return B.sign();}
00898
00899 inline Indexmatrix operator>(const Indexmatrix &A,const Indexmatrix &B)
00900 {return B<A;}
00901 inline Indexmatrix operator>=(const Indexmatrix &A,const Indexmatrix &B)
00902 {return B<=A;}
00903 inline Indexmatrix operator<(Integer d,const Indexmatrix &A)
00904 {return A>d;}
00905 inline Indexmatrix operator>(Integer d,const Indexmatrix &A)
00906 {return A<d;}
00907 inline Indexmatrix operator<=(Integer d,const Indexmatrix &A)
00908 {return A>=d;}
00909 inline Indexmatrix operator>=(Integer d,const Indexmatrix &A)
00910 {return A<=d;}
00911 inline Indexmatrix operator==(Integer d,const Indexmatrix &A)
00912 {return A==d;}
00913 inline Indexmatrix operator!=(Integer d,const Indexmatrix &A)
00914 {return A!=d;}
00915
00916 inline Indexmatrix sortindex(const Indexmatrix& vec)
00917 {Indexmatrix ind;sortindex(vec,ind);return ind;}
00918
00919 inline Indexmatrix find(const Indexmatrix& A)
00920 {return A.find();}
00921 inline Indexmatrix find_number(const Indexmatrix& A,Integer num)
00922 {return A.find_number(num);}
00923
00924 inline std::vector<int>& assign(std::vector<int>& vec,const Indexmatrix& A)
00925 {
00926 chk_init(A);
00927 vec.resize(A.dim());
00928 for(Integer i=0;i<A.dim();i++) vec[i]=int(A(i));
00929 return vec;
00930 }
00931
00932 inline std::vector<long>& assign(std::vector<long>& vec,const Indexmatrix& A)
00933 {
00934 chk_init(A);
00935 vec.resize(A.dim());
00936 for(Integer i=0;i<A.dim();i++) vec[i]=long(A(i));
00937 return vec;
00938 }
00939
00940 }
00941
00942
00943 #ifndef CH_MATRIX_CLASSES__MATRIX_HXX
00944 #include "matrix.hxx"
00945 #endif
00946
00947
00948 #endif