Commit 39a41bb055a7c207d0732140c1b0b2d618cd3a2f

Authored by Brendan Klare
1 parent 31f14f92

Update parameters to const reference in eigen utils

openbr/core/eigenutils.cpp
... ... @@ -77,7 +77,7 @@ float eigStd(const Eigen::MatrixXf& x) {
77 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 81 MatrixXf Y(X.rows() - 1,X.cols() - 1);
82 82  
83 83 for (int i1 = 0, i2 = 0; i1 < X.rows(); i1++) {
... ... @@ -96,7 +96,7 @@ MatrixXf removeRowCol(MatrixXf X, int row, int col) {
96 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 100 MatrixXf P(points.size(), isAffine ? 3 : 2);
101 101 for (int i = 0; i < points.size(); i++) {
102 102 P(i, 0) = points[i].x();
... ... @@ -107,7 +107,7 @@ MatrixXf pointsToMatrix(QList&lt;QPointF&gt; points, bool isAffine) {
107 107 return P;
108 108 }
109 109  
110   -QList<QPointF> matrixToPoints(MatrixXf P) {
  110 +QList<QPointF> matrixToPoints(const Eigen::MatrixXf P) {
111 111 QList<QPointF> points;
112 112 for (int i = 0; i < P.rows(); i++)
113 113 points.append(QPointF(P(i, 0), P(i, 1)));
... ... @@ -115,7 +115,7 @@ QList&lt;QPointF&gt; matrixToPoints(MatrixXf P) {
115 115 }
116 116  
117 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 119 int n = vector.rows();
120 120 Eigen::MatrixXf matrix(n / 2, 2);
121 121 for (int i = 0; i < n / 2; i++) {
... ... @@ -126,7 +126,7 @@ Eigen::MatrixXf vectorToMatrix(Eigen::MatrixXf vector) {
126 126 return matrix;
127 127 }
128 128  
129   -Eigen::MatrixXf matrixToVector(Eigen::MatrixXf matrix) {
  129 +Eigen::MatrixXf matrixToVector(const Eigen::MatrixXf matrix) {
130 130 int n2 = matrix.rows();
131 131 Eigen::MatrixXf vector(n2 * 2, 1);
132 132 for (int i = 0; i < n2; i++) {
... ...
openbr/core/eigenutils.h
... ... @@ -30,15 +30,15 @@ void printEigen(Eigen::MatrixXf X);
30 30 void printSize(Eigen::MatrixXf X);
31 31  
32 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 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 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 43 template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
44 44 inline QDataStream &operator<<(QDataStream &stream, const Eigen::Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &mat)
... ...