git-svn-id: svn://db.shs.com.ru/pip@664 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -212,6 +212,9 @@ public:
|
|||||||
assert(0);
|
assert(0);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
inline void _copyRaw(T * dst, const T * src, size_t size) {
|
||||||
|
newT(dst, src, size);
|
||||||
|
}
|
||||||
|
|
||||||
inline PIVector<T> & reserve(size_t new_size) {
|
inline PIVector<T> & reserve(size_t new_size) {
|
||||||
if (new_size <= piv_rsize) return *this;
|
if (new_size <= piv_rsize) return *this;
|
||||||
|
|||||||
@@ -85,12 +85,12 @@ public:
|
|||||||
inline Row & operator =(const Row & other) {
|
inline Row & operator =(const Row & other) {
|
||||||
if (p_ == other.p_ && st_ == other.st_) return *this;
|
if (p_ == other.p_ && st_ == other.st_) return *this;
|
||||||
size_t sz = piMin<size_t>(sz_, other.sz_);
|
size_t sz = piMin<size_t>(sz_, other.sz_);
|
||||||
copyRow(st_, other.data(), sz, p_);
|
p_->_copyRaw(p_->data(st_), other.data(), sz);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
inline Row & operator =(const PIVector<T> & other) {
|
inline Row & operator =(const PIVector<T> & other) {
|
||||||
size_t sz = piMin<size_t>(sz, other.size());
|
size_t sz = piMin<size_t>(sz, other.size());
|
||||||
copyRow(st_, other.data(), sz, p_);
|
p_->_copyRaw(p_->data(st_), other.data(), sz);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
inline PIVector<T> toVector() const {return PIVector<T>(p_->data(st_), sz_);}
|
inline PIVector<T> toVector() const {return PIVector<T>(p_->data(st_), sz_);}
|
||||||
@@ -153,7 +153,7 @@ public:
|
|||||||
inline PIVector<T> toVector() const {
|
inline PIVector<T> toVector() const {
|
||||||
PIVector<T> ret;
|
PIVector<T> ret;
|
||||||
ret.reserve(sz_);
|
ret.reserve(sz_);
|
||||||
for (int i=0; i<rows_; i++) ret << (*p_)[i * step_ + row_];
|
for (int i=0; i<size(); i++) ret << (*p_)[i * step_ + row_];
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -171,12 +171,12 @@ public:
|
|||||||
inline ColConst col(size_t index) const {return ColConst(this, index);}
|
inline ColConst col(size_t index) const {return ColConst(this, index);}
|
||||||
inline PIVector2D<T> & setRow(size_t row, const Row & other) {
|
inline PIVector2D<T> & setRow(size_t row, const Row & other) {
|
||||||
size_t sz = piMin<size_t>(cols_, other.p_->cols_);
|
size_t sz = piMin<size_t>(cols_, other.p_->cols_);
|
||||||
copyRow(cols_ * row, other.data(), sz, &mat);
|
mat._copyRaw(mat.data(cols_ * row), other.data(), sz);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
inline PIVector2D<T> & setRow(size_t row, const PIVector<T> & other) {
|
inline PIVector2D<T> & setRow(size_t row, const PIVector<T> & other) {
|
||||||
size_t sz = piMin<size_t>(cols_, other.size());
|
size_t sz = piMin<size_t>(cols_, other.size());
|
||||||
copyRow(cols_ * row, other.data(), sz, &mat);
|
mat._copyRaw(mat.data(cols_ * row), other.data(), sz);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,11 +203,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
inline void copyRow(size_t start, const T * data, size_t size, PIVector<T> * dst) {
|
|
||||||
for (size_t i = 0; i < size; i++)
|
|
||||||
(*dst)[start + i] = data[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t rows_, cols_;
|
size_t rows_, cols_;
|
||||||
PIVector<T> mat;
|
PIVector<T> mat;
|
||||||
};
|
};
|
||||||
@@ -233,7 +228,6 @@ inline PICout operator <<(PICout s, const PIVector2D<T> & v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define __PIVECTOR2D_SIMPLE_TYPE__(T) \
|
#define __PIVECTOR2D_SIMPLE_TYPE__(T) \
|
||||||
template<> inline void PIVector2D<T>::copyRow(size_t start, const T * data, size_t size, PIVector<T> * dst) {memcpy(dst->data(start), data, size * sizeof(T));} \
|
|
||||||
template<> inline PIVector2D<T> & PIVector2D<T>::_resizeRaw(size_t r, size_t c) {rows_ = r; cols_ = c; mat._resizeRaw(r*c); return *this;}
|
template<> inline PIVector2D<T> & PIVector2D<T>::_resizeRaw(size_t r, size_t c) {rows_ = r; cols_ = c; mat._resizeRaw(r*c); return *this;}
|
||||||
|
|
||||||
__PIVECTOR2D_SIMPLE_TYPE__(bool)
|
__PIVECTOR2D_SIMPLE_TYPE__(bool)
|
||||||
|
|||||||
Reference in New Issue
Block a user