LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Mathematics in LabVIEW Power Programming VI's

A month ago or so I was in the library of my university and I was doing some LV programming. When I was bored I did some walking and then, because well I can, thought about checking out if they had any LV books. Well they had some, also LabVIEW Power Programming, from 1998.I did some reading and noticted chapter 6, LabVIEW and Mathematics. It also discusses some arithmetic on very large numbers. About 4 months ago I wrote my own VeryLargeNumber library but the only thing that is really missing is division. Now unfortunatly the library did not had the CD-ROM of the book with the VI's of the book. I then e-mailed the publisher but as of today I had no response. Hence I hope someone here can help me out and provide me the VI's from chapter 6? 

0 Kudos
Message 1 of 13
(4,004 Views)

I have a copy of the book and the CD.  However, the terms of the copyright notice do not appear to allow distribution of these VIs without permission.

 

You might check with the librarian to see if that is why the CD had been removed from the library copy. I am not sure how the use privileges of the copyright apply to libraries.

 

Lynn

0 Kudos
Message 2 of 13
(3,989 Views)

Well there is a very plain explenation for that 😛 they just don't have it anymore, i.e. lost it, or something, the book is from 1998 euh 😉 that is something like a century ago in calculated in internet time. Anyhow the book can be easily found threw the web, because I already searched the web. Futher buying the book is fairly impossible, amazon does not sell it anymore (you can still order it but all sellers will tell at checkout, that they can't ship at this time or something similar. If it doesn't sell on amazone I'm sure all the other bookstores who pro-claim to sell it can't provide it either. Further as a poor student I need the money for my other 150 euro books for university hahaha.

 

I just hope someone can help me in some manner O:-)

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

Unfortunately copyrights last much longer.  If McGrawHill will give permission to release the data, I have no problem.

 

If there is some particular part of the program you need, I may be able to tell you how it works without violating the protection.

 

Lynn

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

Well as told I'm very curious how the division operator works under the hood. I got a few algorithms at hand but the one of Knuth, Art of computer programming, seems the easiest to implement. I already created it in C but in LabVIEW it is a painfull job xD

 

division.png

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

I will try to take a look at it tomorrow.

 

Lynn

0 Kudos
Message 6 of 13
(3,967 Views)

Here are my current VI's.

 

I have everything implemented accept division. I have two different division VI's the __uintDivide.vi is partly based on what is described: here; http://kanooth.com/blog/2009/08/implementing-multiple-precision-arithmetic-part-2.html. The otherone is fully based on how Knuths describes it.

 

The one who is fully based on Knuths works also for certain numbers but not for all... (The MSB is in the last index) Example. try Uint1[0,5] = 50 and Uint2[0,2] = 20. Then the correct result is outputted. floor(Uint1/Uint2) = 2, Uint1 mod Uint2 = 10. This works for other choices for Uint2, 21,22,23,24... Then at 25 it is in a infinitly loop when calculating q*. Also when you try 19 you get the wrong output.

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

Did you already take a look ;)?

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

I did get to look at the approach taken by Gary Johnson's book.  It does the calculation digit by digit in much the same way you would do it by hand.  The input strings are converted to arrays of I8 where each element represents a digit and the first element can be -1 for negative numbers.

 

Division is done by repeated subtraction.  The result is returned as two arrays which are converted to strings representing quotient and remainder.

 

He included a test VI which performs signed addition, multiplication, division and greatest common denominator on a 36 digit numerator and 29 digit denominator. Whe I ran it repeatedly in LV 2011 I got average times of 9 and 5 microseconds for the string to array conversions, 994 us for division, 177 us for multiplication, 25 us for addition, and 3723 us for greatest common denominator.

 

Your _uintDividetest.vi took 14720 us to divide a 6-digit number by a 5-digit number and got the remainder wrong.  I did not wait to see how long it took for the larger numbers used in Gary's test VI.

 

I did not look at your implementation of Knuth's algorithm.  Besides the error, I can't imagine that his algorithm is that much slower than Gary's.  There must be something slow about your implementation.

 

Lynn

0 Kudos
Message 9 of 13
(3,835 Views)

ah ok thank you for explaining. That the current implementation is slow is due the fact that it is wrong I bet 😉 because my the addition algo can easily add two numbers of 1000 digits in a flinch of a second. 

 

But I don't understand what you are saying now... Are you know saying that Gary's VI calculates the quotient and remainder digit by digit, because then it is proberbly using knuths algorithm... could you compare it?

 

Or...

 

Does it take the two inputs and keeps substracting them from each other, in a loop, till it cannot be done anymore?

 

0 Kudos
Message 10 of 13
(3,827 Views)