LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Determinant of a matrix with variables in FPGA

Greetings, 

 

Short story: I would like to find the determinant of a 2x2 matrix with variables on an FPGA in LabVIEW. I see how I could do this with a matrix that looks like [[2,1],[1,2]] but how could I do this with a matrix that looks like [[2-x,1],[1,2-x]]? The issue I see is how to treat the "x" in the FPGA space?

 

Long story: What I really want to do is find the eigenvalues of a generalized eigenvalue problem A*Phi=B*Phi*Lambda. A dream goal would be to do this on an FPGA but I think that may be a stretch. For the time being, I am trying to work my way through some of the math to find the eigenvalues of a 2x2 matrix and finding the determinant of a matrix is the first issue I have.  

0 Kudos
Message 1 of 13
(3,216 Views)

Hi Austin-Downey,

 

Have you seen either of these articles? They do not specifically address taking the determinate of a matrix with variables. However, they may have some information that would help you get started.

 

  1. "Matrix*Vector Express VI" http://zone.ni.com/reference/en-XX/help/371599L-01/lvfpga/matrixvector/
  2. "Linear Algebra Matrix Multiply Function" https://zone.ni.com/reference/en-XX/help/371599P-01/lvfpga/la_matrixmultiply/
Kendal C.
Technical Support Engineer
National Instruments
0 Kudos
Message 2 of 13
(3,169 Views)

KendalC, 

 

Thanks, after a week of reading and trial and error I have discovered this is a much harder problem than just finding some code. I am still working on it but I wanted to let others know that in case they are wanting to do this the best way seems to be to find an algorithm that will work for your size of matrix and implement this in LabVIEW code. 

 

 

0 Kudos
Message 3 of 13
(3,145 Views)

After looking around the forums, examples, and internet I have come to the conclusion that there is not a good resource/example for how to implement the Linear Algebra Matrix Multiply on FPGA. As I am unable to get this VI to work I was hoping someone could help me. In general I have two questions:

 

1) What am I doing wrong in the VI posted below?

2) What is the benefit of using this VI as apposed to writing my own code?

 

For my code, here is the code I have on my target. This is for a simple 5x5 matrix, fed into the VI 1 element at a time. I know the FIFOs and splitting the arrays work as they were from my prior home-brew matrix multiply code but I am always open to suggestions. 

target.PNG

And here is the code I have on my host,

host.PNG

As per writing my one code, I did so following the example here, https://forums.ni.com/t5/LabVIEW/Matrix-Multiplication-in-LabVIEW-FPGA-space/td-p/3561369/page/3 but I would like to get this VI working just to compile it and see if it uses more or less resources than my home-brewed code. 

0 Kudos
Message 4 of 13
(3,166 Views)

That upper image of the FPGA code....... I don't think it will do what you think it should do.

 

While loop, Single-Cycle Timed loops, For Loops....... The whole thing only runs once...... You're either doing something incredibly brilliant or just plain wrong. I need a second opinion.

0 Kudos
Message 5 of 13
(3,133 Views)

After looking around the forums, examples, and internet I have come to the conclusion that there is not a good resource/example for how to implement the Linear Algebra Matrix Multiply on FPGA. As I am unable to get this VI to work I was hoping someone could help me. In general, I have two questions:

 

1) What am I doing wrong in the VI posted below?

2) What is the benefit of using this VI as opposed to writing my own code?

 

For my code, here is the code I have on my target. This is for a simple 5x5 matrix, fed into the VI 1 element at a time. I know the FIFOs and splitting the arrays work as they were from my prior home-brew matrix multiply code but I am always open to suggestions. 

target.PNG

And here is the code I have on my host,

host.PNG

As per writing my one code, I did so following the example here, https://forums.ni.com/t5/LabVIEW/Matrix-Multiplication-in-LabVIEW-FPGA-space/td-p/3561369/page/3 but I would like to get this VI working just to compile it and see if it uses more or fewer resources than my home-brewed code. 

Download All
0 Kudos
Message 6 of 13
(3,131 Views)

Intaris, 

 

Thanks for the reply but this was supposed to be a new thread. I must have messed something up when I posted it. 

 

I have made a new thread here, https://forums.ni.com/t5/LabVIEW/Linear-Algebra-Matrix-Multiply-FPGA-Express-VI/td-p/3938434

 

I will answer your question there to keep this clean. 

0 Kudos
Message 7 of 13
(3,117 Views)

From another thread (I messed up the original post) a comment was left stating, 

 

"That upper image of the FPGA code....... I don't think it will do what you think it should do.

 

While loop, Single-Cycle Timed loops, For Loops....... The whole thing only runs once...... You're either doing something incredibly brilliant or just plain wrong. I need a second opinion."

 

I agree that in this configuration it looks like the matrix multiply function only runs once but I know that it must run over multiple clock cycles and when I collect all the "output valid" booleans I get multiple tags. So I assume this means the single cycle loop is somehow running more than once. 

0 Kudos
Message 8 of 13
(3,123 Views)

All, 

 

I am still trying to work on this project, I have a code that is compiling and running but is not returning the correct values. I have attached the code to this post but it will not let me upload my project. All the project has in it is a target-to-host FIFO. Any ideas on what I could be doing wrong?

 

fpga_v2.PNG

 

 

Download All
0 Kudos
Message 9 of 13
(3,082 Views)

I think I have some extra numbers in my FIFO that are the reason I am getting the wrong answer. From the code below I should be putting only 9 items into the FIFO but I am getting 9 numbers that start in the FIFO every time even before I run the code from the host computer. 

 

This is my code on the target where I 

fpga_v2.PNG

And these are the first 9 numbers that I get out of the FIFO. I have no idea where there are coming from. They do not change when I change my input and are in the FIFO before the invoke method on the host VI runs the code. 

extra numbers in FIFO.PNG

The next 9 numbers seem to be correct but I don't know what is causing these first 9 numbers. 

 

 

Download All
0 Kudos
Message 10 of 13
(3,070 Views)