Merge pull request #1969 from calcmogul/remove-operator-from-matrix-and-subgraph-preconditioner

Remove operator^ from Matrix and SubgraphPreconditioner
release/4.3a0
Frank Dellaert 2025-01-11 14:51:20 -05:00 committed by GitHub
commit 49c67d3819
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 3 additions and 20 deletions

View File

@ -126,17 +126,6 @@ bool linear_dependent(const Matrix& A, const Matrix& B, double tol) {
} }
/* ************************************************************************* */ /* ************************************************************************* */
Vector operator^(const Matrix& A, const Vector & v) {
if (A.rows()!=v.size()) {
throw std::invalid_argument("Matrix operator^ : A.m(" + std::to_string(A.rows()) + ")!=v.size(" +
std::to_string(v.size()) + ")");
}
// Vector vt = v.transpose();
// Vector vtA = vt * A;
// return vtA.transpose();
return A.transpose() * v;
}
const Eigen::IOFormat& matlabFormat() { const Eigen::IOFormat& matlabFormat() {
static const Eigen::IOFormat matlab( static const Eigen::IOFormat matlab(
Eigen::StreamPrecision, // precision Eigen::StreamPrecision, // precision

View File

@ -132,12 +132,6 @@ GTSAM_EXPORT bool linear_independent(const Matrix& A, const Matrix& B, double to
*/ */
GTSAM_EXPORT bool linear_dependent(const Matrix& A, const Matrix& B, double tol = 1e-9); GTSAM_EXPORT bool linear_dependent(const Matrix& A, const Matrix& B, double tol = 1e-9);
/**
* overload ^ for trans(A)*v
* We transpose the vectors for speed.
*/
GTSAM_EXPORT Vector operator^(const Matrix& A, const Vector & v);
/** products using old-style format to improve compatibility */ /** products using old-style format to improve compatibility */
template<class MATRIX> template<class MATRIX>
inline MATRIX prod(const MATRIX& A, const MATRIX&B) { inline MATRIX prod(const MATRIX& A, const MATRIX&B) {

View File

@ -567,7 +567,7 @@ TEST(Matrix, matrix_vector_multiplication )
Vector AtAv = Vector3(142., 188., 234.); Vector AtAv = Vector3(142., 188., 234.);
EQUALITY(A*v,Av); EQUALITY(A*v,Av);
EQUALITY(A^Av,AtAv); EQUALITY(A.transpose() * Av,AtAv);
} }
/* ************************************************************************* */ /* ************************************************************************* */

View File

@ -61,7 +61,7 @@ namespace gtsam {
/** Apply operator A'*e */ /** Apply operator A'*e */
Vector operator^(const Vector& e) const { Vector operator^(const Vector& e) const {
return A_ ^ e; return A_.transpose() * e;
} }
/** /**
@ -71,7 +71,7 @@ namespace gtsam {
/** gradient of objective function 0.5*|Ax-b_|^2 at x = A_'*(Ax-b_) */ /** gradient of objective function 0.5*|Ax-b_|^2 at x = A_'*(Ax-b_) */
Vector gradient(const Vector& x) const { Vector gradient(const Vector& x) const {
return A() ^ (A() * x - b()); return A().transpose() * (A() * x - b());
} }
/** Apply operator A */ /** Apply operator A */