16 typedef typename std::vector<T>::iterator
iterator;
20 typedef typename Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>
EMT;
36 assert(
sx*
sy == _sx*_sy);
53 for(iterator vi =
values.begin(); vi !=
values.end(); vi++)
59 for(iterator vi =
values.begin(); vi !=
values.end(); vi++, rhs++)
65 const_iterator ri = rhs.
values.begin();
66 for(iterator vi =
values.begin(); vi !=
values.end(); vi++, ri++)
71 const_iterator ri = rhs.
values.begin();
72 for(iterator vi =
values.begin(); vi !=
values.end(); vi++, ri++)
77 const_iterator ri = rhs.
values.begin();
78 for(iterator vi =
values.begin(); vi !=
values.end(); vi++, ri++)
83 const_iterator ri = rhs.
values.begin();
84 for(iterator vi =
values.begin(); vi !=
values.end(); vi++, ri++)
90 for(iterator vi =
values.begin(); vi !=
values.end(); vi++)
95 for(iterator vi =
values.begin(); vi !=
values.end(); vi++)
100 for(iterator vi =
values.begin(); vi !=
values.end(); vi++)
105 for(iterator vi =
values.begin(); vi !=
values.end(); vi++)
111 const_iterator ri = rhs.
values.begin();
112 for(iterator vi =
values.begin(); vi !=
values.end(); vi++, ri++)
113 if(*vi < *ri) *vi = *ri;
117 for(iterator vi =
values.begin(); vi !=
values.end(); vi++)
118 if(*vi < rhs) *vi = rhs;
122 assert(
sx>0 &&
sy>0);
125 for(const_iterator vi =
values.begin(); vi !=
values.end(); vi++)
126 if(*vi > val) val = *vi;
130 const_iterator ri = rhs.
values.begin();
131 for(iterator vi =
values.begin(); vi !=
values.end(); vi++, ri++)
132 if(*vi > *ri) *vi = *ri;
136 for(iterator vi =
values.begin(); vi !=
values.end(); vi++)
137 if(*vi > rhs) *vi = rhs;
141 assert(
sx>0 &&
sy>0);
144 for(const_iterator vi =
values.begin(); vi !=
values.end(); vi++)
145 if(*vi < val) val = *vi;
150 assert(rhs.
sy ==
sx);
151 MT res(rhs.
sx,
sy, T(0));
152 for(
dword rx=0; rx<rhs.
sx; rx++)
154 for(
dword ry=0; ry<rhs.
sy; ry++)
155 res.
at(rx, ly) +=
at(ry, ly)*rhs.
at(rx, ry);
165 iterator vi =
values.begin()+col;
166 for(const_iterator ri = vec.
getData().begin();
172 iterator vi =
values.begin()+col;
179 iterator vi =
values.begin()+(row*
sx);
180 for(const_iterator ri = vec.
getData().begin();
181 ri != vec.
getData().end(); ri++, vi++)
186 assert(ox<
sx && oy<
sy);
189 for(
dword y = 0; y<height; y++) {
191 const_iterator src = mat.
values.begin() + mat.
index(0,y);
192 for(
dword x=0; x<width; x++, src++, dst++)
198 assert(ox<
sx && oy<
sy);
201 for(
dword y = 0; y<height; y++) {
202 const_iterator src =
values.begin()+
index(ox,oy+y);
203 iterator dst = mat.
values.begin() + mat.
index(0,y);
204 for(
dword x=0; x<width; x++, src++, dst++)
210 iterator vi =
values.begin()+(row*
sx);
211 for(
dword i=0; i<
sx; i++, vi++)
216 int count = offset>=0 ?
sx-offset :
sy+offset;
217 assert( count <= vec.
getData().size() );
218 iterator vi =
values.begin() + ( offset>=0 ? offset : -offset*
sx);
219 for(const_iterator ri = vec.
getData().begin(); count>0;
220 count--, ri++, vi+=
sx+1)
225 int count = offset>=0 ?
sx-offset :
sy+offset;
226 iterator vi =
values.begin() + ( offset>=0 ? offset : -offset*
sx);
227 for(; count>0; count--, vi+=(
sx+1))
232 int count = offset>=0 ?
sx-offset :
sy+offset;
234 const_iterator vi =
values.begin()+( offset>=0 ? offset : -offset*
sx);
235 for(iterator ri = res.
getData().begin(); count>0;
236 count--, ri++, vi+=
sx+1)
243 for(iterator mi =
values.begin();
244 mi !=
values.end(); mi++, i++) {
245 if(i==
sx) { j++; i=0; }
246 if(i-j>=offset) *mi = val;
252 for(iterator mi =
values.begin();
253 mi !=
values.end(); mi++, i++) {
254 if(i==(
int)
sx) { j++; i=0; }
255 if(i-j<=offset) *mi = val;
268 T dummy = a; a = b; b = dummy;
270 else if(sx == 1 || sy == 1)
reshape(sy, sx);
277 at(i,j) = tmp.
at(j,i);
284 friend std::ostream& operator<<(std::ostream& os, const DMatrix<T>& rhs) {
285 os << rhs.sx <<
" " << rhs.sy;
287 for(const_iterator vi = rhs.values.begin();
288 vi != rhs.values.end(); vi++, cc--) {
289 if(!cc) { cc = rhs.sx; os << std::endl; }
297 is >> rhs.
sx; is >> rhs.
sy;
299 for(iterator vi = rhs.
values.begin();
300 vi != rhs.
values.end(); vi++)
MT & setUpper(const T &val=1, int offset=0)
MT & operator/=(const T &rhs)
MT & reshape(dword _sx, dword _sy)
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > EMT
MT & setCol(dword col, const T &val=1)
const std::vector< T > & getData() const
DMatrix< float > DMatrixf
MT & operator/=(const MT &rhs)
MT & operator-=(const MT &rhs)
MT & setDiag(const T &val=1, int offset=0)
DMatrix(dword _sx, dword _sy, const T *data)
MT & operator=(const T *rhs)
MT & operator*=(const MT &rhs)
MT & setDiag(MT &vec, int offset=0)
MT & operator=(const T &rhs)
MT & operator*=(const T &rhs)
MT & resize(dword _sx, dword _sy, const T &inival=T())
DMatrix< double > DMatrixd
MT mulLeft(const MT &rhs) const
std::vector< T >::const_iterator const_iterator
DMatrix(dword _sx=0, dword _sy=0, const T &inival=T())
MT & setRange(dword ox, dword oy, const MT &mat)
MT & setRow(dword row, const T &val=1)
dword index(dword x, dword y) const
std::vector< T >::iterator iterator
MT & setCol(dword col, MT &vec)
MT & setLower(const T &val=1, int offset=0)
MT & setRow(dword row, MT &vec)
MT & operator-=(const T &rhs)
MT & operator+=(const T &rhs)
const T & at(dword x, dword y) const
MT & operator+=(const MT &rhs)
MT & getRange(dword ox, dword oy, MT &mat) const
friend std::istream & operator>>(std::istream &is, DMatrix< T > &rhs)
std::vector< T > & getData()
MT mulRight(const MT &rhs) const