Commit 39a41bb055a7c207d0732140c1b0b2d618cd3a2f
1 parent
31f14f92
Update parameters to const reference in eigen utils
Showing
2 changed files
with
10 additions
and
10 deletions
openbr/core/eigenutils.cpp
| @@ -77,7 +77,7 @@ float eigStd(const Eigen::MatrixXf& x) { | @@ -77,7 +77,7 @@ float eigStd(const Eigen::MatrixXf& x) { | ||
| 77 | return sqrt((x.array() - mean).pow(2).sum() / (x.cols() * x.rows())); | 77 | return sqrt((x.array() - mean).pow(2).sum() / (x.cols() * x.rows())); |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | -MatrixXf removeRowCol(MatrixXf X, int row, int col) { | 80 | +MatrixXf removeRowCol(const MatrixXf X, int row, int col) { |
| 81 | MatrixXf Y(X.rows() - 1,X.cols() - 1); | 81 | MatrixXf Y(X.rows() - 1,X.cols() - 1); |
| 82 | 82 | ||
| 83 | for (int i1 = 0, i2 = 0; i1 < X.rows(); i1++) { | 83 | for (int i1 = 0, i2 = 0; i1 < X.rows(); i1++) { |
| @@ -96,7 +96,7 @@ MatrixXf removeRowCol(MatrixXf X, int row, int col) { | @@ -96,7 +96,7 @@ MatrixXf removeRowCol(MatrixXf X, int row, int col) { | ||
| 96 | return Y; | 96 | return Y; |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | -MatrixXf pointsToMatrix(QList<QPointF> points, bool isAffine) { | 99 | +MatrixXf pointsToMatrix(const QList<QPointF> points, bool isAffine) { |
| 100 | MatrixXf P(points.size(), isAffine ? 3 : 2); | 100 | MatrixXf P(points.size(), isAffine ? 3 : 2); |
| 101 | for (int i = 0; i < points.size(); i++) { | 101 | for (int i = 0; i < points.size(); i++) { |
| 102 | P(i, 0) = points[i].x(); | 102 | P(i, 0) = points[i].x(); |
| @@ -107,7 +107,7 @@ MatrixXf pointsToMatrix(QList<QPointF> points, bool isAffine) { | @@ -107,7 +107,7 @@ MatrixXf pointsToMatrix(QList<QPointF> points, bool isAffine) { | ||
| 107 | return P; | 107 | return P; |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | -QList<QPointF> matrixToPoints(MatrixXf P) { | 110 | +QList<QPointF> matrixToPoints(const Eigen::MatrixXf P) { |
| 111 | QList<QPointF> points; | 111 | QList<QPointF> points; |
| 112 | for (int i = 0; i < P.rows(); i++) | 112 | for (int i = 0; i < P.rows(); i++) |
| 113 | points.append(QPointF(P(i, 0), P(i, 1))); | 113 | points.append(QPointF(P(i, 0), P(i, 1))); |
| @@ -115,7 +115,7 @@ QList<QPointF> matrixToPoints(MatrixXf P) { | @@ -115,7 +115,7 @@ QList<QPointF> matrixToPoints(MatrixXf P) { | ||
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | //Converts x y points in a single vector to two column matrix | 117 | //Converts x y points in a single vector to two column matrix |
| 118 | -Eigen::MatrixXf vectorToMatrix(Eigen::MatrixXf vector) { | 118 | +Eigen::MatrixXf vectorToMatrix(const Eigen::MatrixXf vector) { |
| 119 | int n = vector.rows(); | 119 | int n = vector.rows(); |
| 120 | Eigen::MatrixXf matrix(n / 2, 2); | 120 | Eigen::MatrixXf matrix(n / 2, 2); |
| 121 | for (int i = 0; i < n / 2; i++) { | 121 | for (int i = 0; i < n / 2; i++) { |
| @@ -126,7 +126,7 @@ Eigen::MatrixXf vectorToMatrix(Eigen::MatrixXf vector) { | @@ -126,7 +126,7 @@ Eigen::MatrixXf vectorToMatrix(Eigen::MatrixXf vector) { | ||
| 126 | return matrix; | 126 | return matrix; |
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | -Eigen::MatrixXf matrixToVector(Eigen::MatrixXf matrix) { | 129 | +Eigen::MatrixXf matrixToVector(const Eigen::MatrixXf matrix) { |
| 130 | int n2 = matrix.rows(); | 130 | int n2 = matrix.rows(); |
| 131 | Eigen::MatrixXf vector(n2 * 2, 1); | 131 | Eigen::MatrixXf vector(n2 * 2, 1); |
| 132 | for (int i = 0; i < n2; i++) { | 132 | for (int i = 0; i < n2; i++) { |
openbr/core/eigenutils.h
| @@ -30,15 +30,15 @@ void printEigen(Eigen::MatrixXf X); | @@ -30,15 +30,15 @@ void printEigen(Eigen::MatrixXf X); | ||
| 30 | void printSize(Eigen::MatrixXf X); | 30 | void printSize(Eigen::MatrixXf X); |
| 31 | 31 | ||
| 32 | //Converts x y points in a single vector to two column matrix | 32 | //Converts x y points in a single vector to two column matrix |
| 33 | -Eigen::MatrixXf vectorToMatrix(Eigen::MatrixXf vector); | ||
| 34 | -Eigen::MatrixXf matrixToVector(Eigen::MatrixXf matrix); | 33 | +Eigen::MatrixXf vectorToMatrix(const Eigen::MatrixXf vector); |
| 34 | +Eigen::MatrixXf matrixToVector(const Eigen::MatrixXf matrix); | ||
| 35 | 35 | ||
| 36 | //Remove row and column from the matrix: | 36 | //Remove row and column from the matrix: |
| 37 | -Eigen::MatrixXf removeRowCol(Eigen::MatrixXf X, int row, int col); | 37 | +Eigen::MatrixXf removeRowCol(const Eigen::MatrixXf X, int row, int col); |
| 38 | 38 | ||
| 39 | //Convert a point list into a matrix: | 39 | //Convert a point list into a matrix: |
| 40 | -Eigen::MatrixXf pointsToMatrix(QList<QPointF> points, bool isAffine=false); | ||
| 41 | -QList<QPointF> matrixToPoints(Eigen::MatrixXf P); | 40 | +Eigen::MatrixXf pointsToMatrix(const QList<QPointF> points, bool isAffine=false); |
| 41 | +QList<QPointF> matrixToPoints(const Eigen::MatrixXf P); | ||
| 42 | 42 | ||
| 43 | template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols> | 43 | template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols> |
| 44 | inline QDataStream &operator<<(QDataStream &stream, const Eigen::Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &mat) | 44 | inline QDataStream &operator<<(QDataStream &stream, const Eigen::Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &mat) |