LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

enumerate combinations


@Mark_Yedinak

LabVIEW, more precisely G, is a programming language. It is not intended to be the be-all-end-all mathematics tool. I not familiar with the R tool that you mention but I suspect that is a very focused tool for solving mathematics problems, not a general purpose programming language. Most programming languages would not have that as a builtin function.

I think LabVIEW is an excellent tool for the computer-machine interactions. Altenbach has convinced me that is it also great for fitting spectroscopic lines. However, I do not consider/think it is a general purpose programming language, as it was not originally built for that function. But it is extremely useful for a lot of use cases.

 

mcduff

0 Kudos
Message 11 of 33
(1,397 Views)

When I used to program in Pascal, I once wanted to compute a rather insane N Choose R (maybe the number of Bridge hands?), and quickly saw that I didn't want to use Factorials (though if you are clever and factor things, you can reduce the problem to "cancel factors, multiply, and add").  I used the Formula on which Pascal's Triangle is based -- N Choose R = (N-1) Choose (R-1) + (N-1) Choose R.  No multiplication at all, only simple addition.  Oh, and recursion (I love using recursion).

 

Many years later, "just for fun", I coded this in LabVIEW.  Here are some results, with timings:

   215 Choose 2 = 23005, and takes 0.019 s to compute (yes, 19 ms).

   215 Choose 3 = 1633355, and takes 1.08 s.

   215 Choose 4 = 86567815, and takes 53.7 s.

 

Do I dare try 215 Choose 5?  Maybe while having dinner ...

 

Bob Schor

Message 12 of 33
(1,397 Views)

Cannot edit my previous post, but am now getting the same answers, my one-line solution was giving all possible subsets up to length 2 or 4, instead of only length 2 or 4, so now my answers are

 

Length[Subsets[Range[215], {4}]]

86567815

Length[Subsets[Range[215], {2}]]

23005

 

And for @Bob_Schor

 

AbsoluteTiming[Length[Subsets[Range[215], {4}]] ]

{15.074, 86567815}

AbsoluteTiming[ Length[Subsets[Range[215], {2}]] ]

{0.0028553, 23005}

 

Somewhat surprised that an interpreted language is faster, I guess the function is highly optimized.

I'm guessing that CA will submit some code before the night is over, the size of a postage stamp that puts these benchmarks to shame.

 

mcduff

 

PS Started to run Choose 5, still running and using 120GB of my computer's memory and starting to freeze my system.

0 Kudos
Message 13 of 33
(1,393 Views)

Well, LabVIEW says 215 Choose 5 = 3653161793, and it took 2258 s (37 minutes, 38 s) on my three-year-old laptop and LabVIEW 2016.

 

Just for fun, I asked Mathematica what Binomial[215, 5] was. 

AbsoluteTiming[Binomial[215, 5]]

{5.92593*10^-6, 3653161793}

 That's 6 microseconds!!  And LabVIEW's value for the Coefficient is the same.  But then Mathematica was designed to do Math, and do it quickly, whereas LabVIEW is an Engineering Workbench and does what it does better than most other systems I know about.

 

Bob Schor

0 Kudos
Message 14 of 33
(1,383 Views)

Tl,dr

 

Yes I scanned the thread but it really boils down to that last itty bitty bit of an IEEE 754 represention of a real number.

 

I really didn't enjoy 7th grade..I was somewhat of a nerd and sang descant...  not exactly happy times but, I remember set theory.  There is a set of whole numbers, there is a set of real numbers, there is a set of real numbers that can be exacty discribed with yeah so many bits interpreted in such a way...sign, mantisa, exponent 

 

Could you clarify?


"Should be" isn't "Is" -Jay
0 Kudos
Message 15 of 33
(1,380 Views)

@mcduff wrote:

@Mark_Yedinak

LabVIEW, more precisely G, is a programming language. It is not intended to be the be-all-end-all mathematics tool. I not familiar with the R tool that you mention but I suspect that is a very focused tool for solving mathematics problems, not a general purpose programming language. Most programming languages would not have that as a builtin function.

I think LabVIEW is an excellent tool for the computer-machine interactions. Altenbach has convinced me that is it also great for fitting spectroscopic lines. However, I do not consider/think it is a general purpose programming language, as it was not originally built for that function. But it is extremely useful for a lot of use cases.

 

mcduff


I guess I need to change my job then since I have been using LabVIEW for the past 20+ years as a general purpose programming language. I have written some very large applications in LabVIEW that don't interact with a single piece of hardware, at least not the type most people think of when talking about LabVIEW. A current application tests printer firmware. Yes, one could argue that communicating with a printer is communicating with HW it is simply using the printer's language to communicate over TCP or USB.

 

The application below is written 100% in LabVIEW.

 

ZCAT Plus.png



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 16 of 33
(1,378 Views)

@Mark_Yedinak

I guess I need to change my job then since I have been using LabVIEW for the past 20+ years as a general purpose programming language. I have written some very large applications in LabVIEW that don't interact with a single piece of hardware, at least not the type most people think of when talking about LabVIEW. A current application tests printer firmware. Yes, one could argue that communicating with a printer is communicating with HW it is simply using the printer's language to communicate over TCP or USB.

 

The application below is written 100% in LabVIEW.

 

 


Did not mean to step on any toes. I am a chemist by training, whose work involves quite a bit of LabVIEW, so don't take my opinion too seriously.

 

However, in my opinion,

  1. Your application is impressive, but I still think it "talks" to hardware(printers). This is a task well-suited for LabVIEW.
  2. I think the best application of non-hardware general purpose LabVIEW is VIPM. I do not know if it is 100% LabVIEW, but still mighty impressive in my eyes.
  3. If you can write a compiler, OS, web browser, with LabVIEW, I'll change my opinion, which may be too narrow in scope.
  4. Just because it is not completely general purpose does not mean it is not awesome. I am probably still employed because I know and love LabVIEW. It's a great language and works well for what is was designed for.

mcduff

0 Kudos
Message 17 of 33
(1,362 Views)

@Bob_Schor wrote:

Well, LabVIEW says 215 Choose 5 = 3653161793, and it took 2258 s (37 minutes, 38 s) on my three-year-old laptop and LabVIEW 2016.

 

Just for fun, I asked Mathematica what Binomial[215, 5] was. 

AbsoluteTiming[Binomial[215, 5]]

{5.92593*10^-6, 3653161793}

 That's 6 microseconds!!  And LabVIEW's value for the Coefficient is the same.  But then Mathematica was designed to do Math, and do it quickly, whereas LabVIEW is an Engineering Workbench and does what it does better than most other systems I know about.

 

Bob Schor


LabVIEW has the Binomial Coefficient built-in(???), see below using it on my computer I get ~2 us, on Mathematica 11us, so LabVIEW wins!

snip.png

 

 

 

 

The commands in Mathematica that I was using before actually generate a list of all the possible combinations as dictated by the OP. So you end up with a long list, that is what takes so long.

 

mcduff

 

Message 18 of 33
(1,360 Views)

Wow!  I didn't even look into whether or not LabVIEW had a Binomial Coefficient Function (I assumed it wouldn't, as I mistakenly thought it would be too "obscure" to include).  Did you notice that it returns the answer as a Dbl, probably because they do "efficient", but "brute-force" multiplication and division in their solution?  Can lead to interesting "rounding errors" (and possible overflow problems) in a problem that, as it is a "counting" problem, should always be in the realm of integers.  

 

And on my same Laptop, LabVIEW 2016 also beats Mathematica (to my shocked amazement), computing 215 Choose 5 in 5.5 microseconds.  Man, that's a fast multiplier chip.

 

Bob Schor

Message 19 of 33
(1,356 Views)

@mcduff wrote:

@Mark_Yedinak

I guess I need to change my job then since I have been using LabVIEW for the past 20+ years as a general purpose programming language. I have written some very large applications in LabVIEW that don't interact with a single piece of hardware, at least not the type most people think of when talking about LabVIEW. A current application tests printer firmware. Yes, one could argue that communicating with a printer is communicating with HW it is simply using the printer's language to communicate over TCP or USB.

 

The application below is written 100% in LabVIEW.

 

 


Did not mean to step on any toes. I am a chemist by training, whose work involves quite a bit of LabVIEW, so don't take my opinion too seriously.

 

However, in my opinion,

  1. Your application is impressive, but I still think it "talks" to hardware(printers). This is a task well-suited for LabVIEW.
  2. I think the best application of non-hardware general purpose LabVIEW is VIPM. I do not know if it is 100% LabVIEW, but still mighty impressive in my eyes.
  3. If you can write a compiler, OS, web browser, with LabVIEW, I'll change my opinion, which may be too narrow in scope.
  4. Just because it is not completely general purpose does not mean it is not awesome. I am probably still employed because I know and love LabVIEW. It's a great language and works well for what is was designed for.

mcduff


In the strictest sense, yes this application is communicating with hardware. However, not in the sense most people think of when talking about hardware and LabVIEW. Most think of that as digital and analog signaling. Every programming language supports communicating with a device, be it software or hardware, via TCP. The application I posted does way more than simply communicate with a printer. It communicates with the database for all of the test data, it supports a RESTful interface for remote control from web applications. It is a distributed application which has a network publish/subscribe message broker.

 

Also, while it would be quite the undertaking I see no reason why LabVIEW couldn't be used to write a compiler or an OS. I agree that it has some limitations when it comes to user interfaces but under the hood I don't really see what language components are missing which would prevent it from being able to implement any of the things you are talking about. The limitations that I see at the moment are because it is a proprietary language right now. It is difficult for other to add support for a wider array of processors which is easier to do in languages like C or C++. From a programming standpoint G is one of the nest languages for implementing highly parallel code. Dataflow itself is the cornerstone of parallel execution. Traditional languages require quite a bit of work to truly harness the power of parallel programming. G makes this extremely easy for the programmer.

 

My background is computer science. It is a pet peeve of mine when others make the claim that G is not a real programming language. Every language has some strengths and weakness but there is nothing fundamentally missing from G for it to not be considered a full and complete programming language. I would love to see computer science move past the dark ages of programming and embrace graphical programming and dataflow programming as more of the norm rather than a niche. What holds this back is that G is a proprietary language and a snobbish mindset of the CS community to think the only proper way to code is using a text editor.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 20 of 33
(1,329 Views)