@@ -93,7 +93,14 @@ def optimized_keys(self) -> T.List[str]:
93
93
for value in optimized_values
94
94
]
95
95
96
- def generate (self , output_dir : T .Openable , namespace : str , name : str ) -> None :
96
+ def generate (
97
+ self ,
98
+ output_dir : T .Openable ,
99
+ namespace : str ,
100
+ name : str ,
101
+ sparse_linearization : bool = False ,
102
+ config : codegen_config .CppConfig = None ,
103
+ ) -> None :
97
104
"""
98
105
Generate everything needed to optimize `problem` in C++. This currently assumes there is
99
106
only one factor generated for the optimization problem.
@@ -102,11 +109,21 @@ def generate(self, output_dir: T.Openable, namespace: str, name: str) -> None:
102
109
output_dir: Directory in which to output the generated files.
103
110
namespace: Namespace used in each generated file.
104
111
name: Name of the generated factor.
112
+ sparse_linearization: Whether the generated factors should use sparse jacobians/hessians
113
+ config: C++ code configuration used with the linearization functions generated for each
114
+ factor.
105
115
"""
106
- factors = self .make_symbolic_factors (name = name , config = codegen_config .CppConfig ())
116
+ if config is None :
117
+ config = codegen_config .CppConfig ()
118
+
119
+ # Generate the C++ code for the residual linearization function
120
+ factors = self .make_symbolic_factors (name = name , config = config )
107
121
for factor in factors :
108
122
output_data = factor .generate (
109
- optimized_keys = self .optimized_keys (), output_dir = output_dir , namespace = namespace
123
+ optimized_keys = self .optimized_keys (),
124
+ output_dir = output_dir ,
125
+ namespace = namespace ,
126
+ sparse_linearization = sparse_linearization ,
110
127
)
111
128
logger .info (
112
129
"Generated function `{}` in directory `{}`" .format (
0 commit comments