made a code in matlab which includes functions like rand, eig, cov and many more. I want to convert the same to HDL, but cannot due to those functions.

3 ビュー (過去 30 日間)
hello, Can anyone tell me how to find out eigen values and eigen vectors of large matrix of order 10x10 or more, without using the function 'eig', so that it becomes convertible to HDL using HDL converter?

採用された回答

John D'Errico
John D'Errico 2016 年 9 月 16 日
編集済み: John D'Errico 2016 年 9 月 16 日
10x10 is not a large problem. :) In fact, 10 is pretty small. That does not mean it is trivial for any general matrix, and the simplest solution may depend on some characteristics of your matrix. Is it real and symmetric for example? Is it positive definite?
You can reduce an eigenvalue computation into one of finding the roots of a polynomial. Or you can use the power method on some matrices. (Be careful if an eigenvalue has degree greater than 1, etc.)
And tools like cov are easily written as not much more than subtracting a mean followed by a matrix multiplication.
  1 件のコメント
Sukhmani Kaur Thethi
Sukhmani Kaur Thethi 2016 年 9 月 16 日
the matrix is a random matrix, so no particular characteristic fits into the scenario?

サインインしてコメントする。

その他の回答 (2 件)

Tim McBrayer
Tim McBrayer 2016 年 9 月 16 日
You will need to decompose the computation of eigenvectors to more basic operations and organize these in a way that meets your hardware requirements for size and speed. There are a huge number of ways to accomplish this, which is one reason why eig() is not directly supported by HDL Coder.

Walter Roberson
Walter Roberson 2016 年 9 月 17 日
It is possible to generate the characteristic polynomial of the 10 x 10 matrix in a symbolic form. It would be quite large, but it is possible.
You would then be left trying to find the roots of that 10 degree polynomial. There is no algebraic solution for finding the roots of a general polynomial of degree 5 or higher. You could resort to using roots() on that long polynomial, but roots() invokes eig...
So, you are pretty much going to need to work numerically using some algorithm or other. https://www.mathworks.com/moler/eigs.pdf
  2 件のコメント
Sukhmani Kaur Thethi
Sukhmani Kaur Thethi 2016 年 9 月 17 日
sir, actually this is the minimum matrix dimension. I need to work on bigger matrix dimensions. will the QR method work then? will I get all the eigen values and eigen vectors using that method?
Walter Roberson
Walter Roberson 2016 年 9 月 17 日
It looks to me as if SVD might make more sense then QR for you.
However, an important question here is whether those random matrices you are producing are symmetric or not. If they are not, then complex eigenvalues are to be expected, which complicates the algorithm and the generated HDL.
Checking, I see that code generation is supported for eig(), at least at the MATLAB level.
What is it that you are doing, that eigenvalues of random matrices makes sense?

サインインしてコメントする。

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by