From 851e389dffdd6996ea32d70defb8906de80b9edc Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Mon, 14 Dec 2009 20:35:11 -0500 Subject: few small fixes of alignment tools, add new orthographic similarity feature for word aligner, final naming of directories, libraries in cdec --- src/array2d.h | 172 ---------------------------------------------------------- 1 file changed, 172 deletions(-) delete mode 100644 src/array2d.h (limited to 'src/array2d.h') diff --git a/src/array2d.h b/src/array2d.h deleted file mode 100644 index e63eda0d..00000000 --- a/src/array2d.h +++ /dev/null @@ -1,172 +0,0 @@ -#ifndef ARRAY2D_H_ -#define ARRAY2D_H_ - -#include -#include -#include -#include -#include - -template -class Array2D { - public: - typedef typename std::vector::reference reference; - typedef typename std::vector::const_reference const_reference; - typedef typename std::vector::iterator iterator; - typedef typename std::vector::const_iterator const_iterator; - Array2D() : width_(0), height_(0) {} - Array2D(int w, int h, const T& d = T()) : - width_(w), height_(h), data_(w*h, d) {} - Array2D(const Array2D& rhs) : - width_(rhs.width_), height_(rhs.height_), data_(rhs.data_) {} - bool empty() const { return data_.empty(); } - void resize(int w, int h, const T& d = T()) { - data_.resize(w * h, d); - width_ = w; - height_ = h; - } - const Array2D& operator=(const Array2D& rhs) { - data_ = rhs.data_; - width_ = rhs.width_; - height_ = rhs.height_; - return *this; - } - void fill(const T& v) { data_.assign(data_.size(), v); } - int width() const { return width_; } - int height() const { return height_; } - reference operator()(int i, int j) { - return data_[offset(i, j)]; - } - void clear() { data_.clear(); width_=0; height_=0; } - const_reference operator()(int i, int j) const { - return data_[offset(i, j)]; - } - iterator begin_col(int j) { - return data_.begin() + offset(0,j); - } - const_iterator begin_col(int j) const { - return data_.begin() + offset(0,j); - } - iterator end_col(int j) { - return data_.begin() + offset(0,j) + width_; - } - const_iterator end_col(int j) const { - return data_.begin() + offset(0,j) + width_; - } - iterator end() { return data_.end(); } - const_iterator end() const { return data_.end(); } - const Array2D& operator*=(const T& x) { - std::transform(data_.begin(), data_.end(), data_.begin(), - std::bind2nd(std::multiplies(), x)); - } - const Array2D& operator/=(const T& x) { - std::transform(data_.begin(), data_.end(), data_.begin(), - std::bind2nd(std::divides(), x)); - } - const Array2D& operator+=(const Array2D& m) { - std::transform(m.data_.begin(), m.data_.end(), data_.begin(), data_.begin(), std::plus()); - } - const Array2D& operator-=(const Array2D& m) { - std::transform(m.data_.begin(), m.data_.end(), data_.begin(), data_.begin(), std::minus()); - } - - private: - inline int offset(int i, int j) const { - assert(i data_; -}; - -template -Array2D operator*(const Array2D& l, const T& scalar) { - Array2D res(l); - res *= scalar; - return res; -} - -template -Array2D operator*(const T& scalar, const Array2D& l) { - Array2D res(l); - res *= scalar; - return res; -} - -template -Array2D operator/(const Array2D& l, const T& scalar) { - Array2D res(l); - res /= scalar; - return res; -} - -template -Array2D operator+(const Array2D& l, const Array2D& r) { - Array2D res(l); - res += r; - return res; -} - -template -Array2D operator-(const Array2D& l, const Array2D& r) { - Array2D res(l); - res -= r; - return res; -} - -template -inline std::ostream& operator<<(std::ostream& os, const Array2D& m) { - for (int i=0; i& m) { - os << ' '; - for (int j=0; j >& m) { - os << ' '; - for (int j=0; j& ar = m(i,j); - for (int k=0; k