factors with dynamic sized arguments #446
-
|
How do I create a factor that has an argument with an arbitrary length? I've looked through the README and tutorials, but so far all I'm seeing is fixed size matrices. For context, I'm interested in eventually implementing a spline camera distortion model, so as a toy problem, I'm doing a 1D function fit right now to see how it might work. It'd be nice to have a variable number of knots and coefficients, but it seems that might require new code generation every time the value changes? Am I going about it wrong using Matrix for the coefficients? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
|
You can't generate a function with arbitrary size, but you can actually create dynamic size factors, for example if you wanted to call a generated function N times, there are examples of dynamic size factors in One approach that might work for you is picking a maximum number of knots/coefficients, and setting any unused ones to zero? I'm not sure if what would cover what you need without knowing more about your setup. Otherwise the generated code is probably going to be specific to a fixed number of knots/coefficients, yeah |
Beta Was this translation helpful? Give feedback.
You can't generate a function with arbitrary size, but you can actually create dynamic size factors, for example if you wanted to call a generated function N times, there are examples of dynamic size factors in
symforce_factor_test.cc. I don't think this is what you want though, since I'm assuming you want to e.g. sample the spline, and compute other symbolic functions of the sampled point, and whatnot.One approach that might work for you is picking a maximum number of knots/coefficients, and setting any unused ones to zero? I'm not sure if what would cover what you need without knowing more about your setup. Otherwise the generated code is probably going to be specific to a fixed number…