12-06-2011 11:07 PM - edited 12-06-2011 11:09 PM
Hi everyone,
I'm trying to write a vi to solve Laplace's equation via Method of Relaxation, wolfram link. Where a 2d surface (matrix in my program) has fixed boundary values and an initial guess at the rest of the values in the middle of the matrix. The program then recalculates the inner values to be the average of their nearest neighbors. This can then be repeated "iteratively" to approach the real solution.
I have the code written and it appears to be working but it seems a little slow, excel so far seems to be doing the same task a fair bit faster. So I wanted to check with you guys if the code I've written has any glaring efficiency problems and I'll admit right off the bat I probably have a few too many local variables. Most of my labview coding up to now has been controlling hardware of a nature where I haven't needed to learn the most efficient looping methods. But since this new code is just number crunching its time I did.
Any suggestions?
P.S. I'm using Labview 2009 vers. 9.02f
12-09-2011 07:47 AM
Hi,
Are you doing any parallel processes? If not, I don't think you need the sequence structures. Try getting rid of the nested for loops. Also, try to preallocate arrays. What does your program in Excel look like? Are you using any special functions in Excel? How much of a time difference are you seeing between the two?