Hi !!!

I work on FMatrix to use the wonderful function 'svd' but it's a template whitch is : FMatrix < type, cinst int N, const int M> N and M are the dimensions of the matrix.

The problem is that i make a lot of calculs, I create a special vector and then I need to use my svd function on a FMatrix<float, vector.size(), vector.size()>

But size return a int and the template need a const int.

How to convert vector.size() to a const int N that i could use as my matrix dimensions as FMatrix <float, N, N>?

Thanks for help,

I work on FMatrix to use the wonderful function 'svd' but it's a template whitch is : FMatrix < type, cinst int N, const int M> N and M are the dimensions of the matrix.

The problem is that i make a lot of calculs, I create a special vector and then I need to use my svd function on a FMatrix<float, vector.size(), vector.size()>

But size return a int and the template need a const int.

How to convert vector.size() to a const int N that i could use as my matrix dimensions as FMatrix <float, N, N>?

Thanks for help,

Last edited on

Template parameters are compile-time constants. Either switch to a matrix library that allows defining matrix sizes at run time (I thought all of them did), or determine your size at compile time.

You cannot, simply. FMatrix needs a constant, known-at-compile-time, value. std::vector::size is not known at compile time, so it cannot be used with FMatrix.

If you have the source for the svd function, you can adapt it to be used with another matrix library.

If you have the source for the svd function, you can adapt it to be used with another matrix library.

FMatrix has no resize capability, so you can not expect it to resize with your vector.

The simple solution is to make a new FMatrix whenever needed.

As to get the constant int:

The simple solution is to make a new FMatrix whenever needed.

As to get the constant int:

`const` `int` sizeX = myFirstVector.size();

Last edited on

I do make a new FMatrix whenever i create a new vector writing :

const int sizeX = myFirstVector.size();

But when it compiles it doesn't know the size of the vector (whitch is calculate during the execution) so he can't create the FMatrix and send an error message.

I'll try to find the explicite library. Thanks for your time

const int sizeX = myFirstVector.size();

But when it compiles it doesn't know the size of the vector (whitch is calculate during the execution) so he can't create the FMatrix and send an error message.

I'll try to find the explicite library. Thanks for your time

Eigen has SVD: http://eigen.tuxfamily.org and in particular http://eigen.tuxfamily.org/dox/classEigen_1_1JacobiSVD.html

Last edited on

But when it compiles it doesn't know the size of the vector (whitch is calculate during the execution) so he can't create the FMatrix and send an error message. |

Then perhaps use pointers and

`new`

?
Topic archived. No new replies allowed.