Is there a way to set a dynamic vector or matrix in Eigen library? If not, is there a way to still use the Eigen library in conjunction with another class like vector
?
For example let's say I have n*1
matrix called MatrixXd S(n,1);
Now for simplicity let n=3
and S = 4 2 6
. Pretend that the elements in S
are future stock prices and let K = 2
which will be the strike price. Don't worry you won't need to understand the terminology of an option. Now say I want to know at what positions of S
will we have S - K > 0
and say I want to store these positions in a vector call b
.
Clearly, depending on the elements of S
the vector b
will be of a different size. Thus, I need to have b
being of a dynamic variable. The only class I am familiar with that allows this is the vector class i.e., #include <vector>
.
My question is as follows: Is it okay to use the Eigen library and the #include <vector>
class together? Note that I will be performing operations of b
with the Eigen library vectors and matrices I have created.
If I am not making sense, or if my question is unclear please let me know and I will clarify as much as possible.
Eigen::VectorXd
or some other form of the vector template? Yes, Eigen does support dynamically sized matrices and vectors; you're already usingEigen::MatrixXd
, which is a dynamically-sized matrix ofdouble
s. – Jason R