I have a matrix of derived quantities inside my model which do not (explicitly) depend on parameter values.
I would like to round these to the nearest integer, stash that output separately, and use the result to index within a different matrix. I currently have a static, externally-generated lookup table but would like to use the "live" values for accuracy.
So far I have tried:
int temp_ind = int(matrix_of_doubles(x,y,z));
return_val = other_table(temp_ind); // must be an integer
And received error: invalid cast from type 'CppAD::AD<double>' to type 'int'. If I substitute a raw double for
matrix_of_doubles(x,y,z) (e.g. 3.14159) this error doesn't come up. I suspect TMB is thinking that matrix_of_doubles is deeply related to differentiated parameters, and therefore shouldn't be rounded?
For what it's worth, I'm trying to use the predicted lengths-at-age to look up selectivity values associated with that length bin. In my model, the predicted lengths in question are deterministic (no estimation of growth parameters).
Is there a way to store the rounded value of a derived double, with no intention of modifying the original quantity?
Thanks
MK