Skip to content

Commit

Permalink
Remove operator^ abuse
Browse files Browse the repository at this point in the history
  • Loading branch information
mcm001 committed Dec 29, 2024
1 parent 846c29f commit f7aecd8
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 40 deletions.
11 changes: 0 additions & 11 deletions gtsam/base/Matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
static const Eigen::IOFormat matlab(
Eigen::StreamPrecision, // precision
Expand Down
6 changes: 0 additions & 6 deletions gtsam/base/Matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/**
* 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 */
template<class MATRIX>
inline MATRIX prod(const MATRIX& A, const MATRIX&B) {
Expand Down
14 changes: 0 additions & 14 deletions gtsam/linear/SubgraphPreconditioner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,20 +149,6 @@ void SubgraphPreconditioner::multiplyInPlace(const VectorValues& y, Errors& e) c
Ab2_.multiplyInPlace(x, ei); // use iterator version
}

/* ************************************************************************* */
// Apply operator A', A'*e = [I inv(R1')*A2']*e = e1 + inv(R1')*A2'*e2
VectorValues SubgraphPreconditioner::operator^(const Errors& e) const {

Errors::const_iterator it = e.begin();
VectorValues y = zero();
for(auto& key_value: y) {
key_value.second = *it;
++it;
}
transposeMultiplyAdd2(1.0, it, e.end(), y);
return y;
}

/* ************************************************************************* */
// y += alpha*A'*e
void SubgraphPreconditioner::transposeMultiplyAdd
Expand Down
3 changes: 0 additions & 3 deletions gtsam/linear/SubgraphPreconditioner.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ namespace gtsam {
/** Apply operator A in place: needs e allocated already */
void multiplyInPlace(const VectorValues& y, Errors& e) const;

/** Apply operator A' */
VectorValues operator^(const Errors& e) const;

/**
* Add A'*e to y
* y += alpha*A'*[e1;e2] = [alpha*e1; alpha*inv(R1')*A2'*e2]
Expand Down
7 changes: 1 addition & 6 deletions gtsam/linear/iterative.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,14 @@ namespace gtsam {
/** Access b vector */
const Vector& b() const { return b_; }

/** Apply operator A'*e */
Vector operator^(const Vector& e) const {
return A_ ^ e;
}

/**
* Print with optional string
*/
void print (const std::string& s = "System") const;

/** gradient of objective function 0.5*|Ax-b_|^2 at x = A_'*(Ax-b_) */
Vector gradient(const Vector& x) const {
return A() ^ (A() * x - b());
return A().transpose() * (A() * x - b());
}

/** Apply operator A */
Expand Down

0 comments on commit f7aecd8

Please sign in to comment.