32 template<
class ScalarT>
34 Matrix(std::size_t num_rows, std::size_t num_cols, ScalarT val) :
35 matrix_(Eigen::
Matrix<ScalarT, Eigen::Dynamic, Eigen::Dynamic>::
Constant(num_rows, num_cols, val)) {}
37 template<
class ScalarT>
42 template<
class ScalarT>
45 matrix_(matrix.matrix_) {}
47 template<
class ScalarT>
51 matrix_ = matrix.matrix_;
54 template<
class ScalarT>
58 return matrix_(row, col);
61 template<
class ScalarT>
65 return matrix_(row, col);
68 template<
class ScalarT>
72 return matrix_.
data();
75 template<
class ScalarT>
79 return matrix_.
data();
82 template<
class ScalarT>
86 return static_cast<std::size_t
>(matrix_.rows());
89 template<
class ScalarT>
92 resize(std::size_t num_rows, std::size_t num_cols) {
93 matrix_.
resize(num_rows, num_cols);
96 template<
class ScalarT>
100 for (std::size_t row{0}; row < num_rows(); row++) {
101 for (std::size_t col{0}; col < num_cols(); col++) {
102 (*this)(row, col) = val;
107 template<
class ScalarT>
111 return static_cast<std::size_t
>(matrix_.cols());
114 template<
class ScalarT>
121 Eigen::Matrix<ScalarT, Eigen::Dynamic, Eigen::Dynamic> temp = Eigen::Matrix<ScalarT, Eigen::Dynamic, Eigen::Dynamic>::Ones(num_rows(), num_cols());
137 template<
class ScalarT>
144 template<
class ScalarT>
150 return transposed_matrix;
153 template<
class ScalarT>
157 std::swap(matrix_, rhs.matrix_);
160 template<
class ScalarT>
164 return matrix_.maxCoeff();
167 template<
class ScalarT>
171 return matrix_.minCoeff();
174 template<
class ScalarT>
182 template<
class ScalarT>
186 matrix_ += matrix.matrix_;
190 template<
class ScalarT>
194 matrix_ -= matrix.matrix_;
198 template<
class ScalarT>
203 new_matrix.matrix_ *= scalar;
207 template<
class ScalarT>
212 new_matrix.matrix_ += matrix.matrix_;
216 template<
class ScalarT>
221 new_matrix.matrix_ -= matrix.matrix_;
225 template<
class ScalarT>
226 Eigen::Matrix<ScalarT, Eigen::Dynamic, Eigen::Dynamic> &
232 template<
class ScalarT>
233 const Eigen::Matrix<ScalarT, Eigen::Dynamic, Eigen::Dynamic> &
239 template<
class ScalarT>
240 std::ostream & operator<<(std::ostream & os, const Matrix<ScalarT> & matrix) {
A matrix class with basic functionality.
void resize(std::size_t num_rows, std::size_t num_cols)
Resizes the matrix.
Matrix()
Constructs an empty cost matrix.
Eigen::Matrix< ScalarT, Eigen::Dynamic, Eigen::Dynamic > & matrix()
Returns reference to the internal Eigen matrix.
Global namespace for GEDLIB.
Implements constant edit cost functions.
void transpose()
Transposes the matrix.
ScalarT * data()
Provides access to internal data.