cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Duplicate Function

MikeArmstrong
5-Regular Member

Duplicate Function

In respect of a query raised in the Prime number thread, I have decided to create a new one due to the question being slightly off topic.

The following function accepts a vector and returns a two column nested array, one column indicating the duplicate values and the other indicating none duplicate values from the passed vector.

All comments welcome as I'm sure it can be programmed much more elegantly, but I have ran out of time.

Mike

6 REPLIES 6

I have noticed an error due to the rushing.

Additional function added.

Mike

Another Way

MikeArmstrong
5-Regular Member
(To:hilbert)

Nice.

I do like the way different collabs attack different problems. Waiting for Richard and Stuart now .

Mike

...another oar...actually, after I did mine, I looked at Mike's, and I think that they are fairly the same, except that I chose to embed my tests, and I think that the overall speed is greater (and it is easier for this simple brain to comprehend the logic)...but that would mean a speed test for them all on, say, 10K data points.

~R~

MikeArmstrong
5-Regular Member
(To:Ninetrees)

Cheers for the input Rich,

Lets not get into talking about calculation speed again ..... Nice answer by the way.

I like the title of your Mathcad sheet - the way forward.

Mike

Hi Mike,

I'm very conscious of speed issues all the time when I use computer-based tools. Prolly because I spent so much time addressing such issues back when we actually knew how many clock cycles an ADD required. Also built real-time embedded systems. Just got a call from a client who wanted help on a system for which I had built the software (on a real time platform). Seems that a few dozen pieces of equipment were going nuts and couldn't be controlled. We tracked the problem to a faulty instrument power supply...anyway, that system is 15 years old, and expected to last another 10. The reason? It's the fastest in its class, and two competitors have lost ~$500K trying to replace it. It's the fastest in its class because I am very conscious of CPU cycle usage in everything that I do...and that includes working with products such as Mathcad...

I seem to recall a discussion in the collab a few years ago where a grad student couldn't get his program to "run" and asked for help. We eventually discovered that his use of (I think) vectorize was making his real data analysis (9000 points) take literally days longer than it otherwise needed, so he concluded that it wasn't actually running. If he'd a waited a few days, he'd have had his answer 😉 For the small programs we run here, it doesn't matter, but I run sims that take hours..days to run, and that means paying attention to details. In our example here, we used the Mathcad sort routine - a bubble sort, I think - pretty slow, but convenient for us. Were we to consider a larger data set, we'd be better off finding some sort of programmatic approach. There is, of course, a trade off twixt the labor of doing more complicated programming and the time cost of grabbing a tool from our math toolbox.

So I'll try 😉 not to bring up speed issues too much...but...sigh...can't help but think of them...

~R~

Top Tags