Skip to content

Move free functions definitions to GncOptimizer.cpp#2461

Merged
varunagrawal merged 8 commits intodevelopfrom
fix-gnc
Mar 12, 2026
Merged

Move free functions definitions to GncOptimizer.cpp#2461
varunagrawal merged 8 commits intodevelopfrom
fix-gnc

Conversation

@varunagrawal
Copy link
Copy Markdown
Contributor

Added a new file called GncOptimizer.cpp so that I could move the free function definitions to it. These were originally added and defined erroneously in #2410.

This resolves the duplicate symbol error reported in #2460.

@varunagrawal varunagrawal requested a review from dellaert March 12, 2026 03:36
@varunagrawal varunagrawal self-assigned this Mar 12, 2026
Comment thread gtsam/nonlinear/GncOptimizer.cpp Outdated
namespace gtsam {

/* ************************************************************************* */
bool isNullType(Type type) { return type == Type::NullPointer; }
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dellaert I believe Type is too generic an enum name, and it should instead be GncFactorType to better describe its purpose. Should I add that change to this PR?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Could we make it an internal enum so it's GncOptimizer::Type?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would involve providing the template parameters, making the type name quite verbose, e.g. GncOptimizer<GncParams<LevenbergMarquardtParams>>::FactorType.
I am using FactorType since GncOptimizer::Type reads like it is a type variant of GncOptimizer and not the factors under consideration.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, all the functions would now have to be templated. Would you prefer we move them inside the GncOptimizer class definition instead of keeping them as free functions?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay making the internal namespace is a significant refactor which I would prefer to do after a design review. I'll change the name to GncFactorType and we can revisit this in the future.

@varunagrawal varunagrawal linked an issue Mar 12, 2026 that may be closed by this pull request
Copy link
Copy Markdown
Member

@dellaert dellaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This solution is fine with me.

@varunagrawal varunagrawal merged commit a163b3b into develop Mar 12, 2026
31 of 32 checks passed
@varunagrawal varunagrawal deleted the fix-gnc branch March 12, 2026 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Including GncOptimizer causes duplicate symbol error

2 participants