Friday, November 30, 2012

MuPuPriNT 2.1.1 Extended beta

You can now try out MuPuPriNT 2.1.1 Extended! Find it here.

This adds testing functionality for seven new types of numbers, so there is now a total of eleven numbers you can calculate and test.

I also fixed the screenshot capabilities and modified the way the Test button works. You won't notice anything on the GUI end, but behind the scenes there has been a great deal of code clean-up and modifications to make things run a lot smoother.

Additionally, this version introduces and prototypes a completely working unified testing interface. This means that instead of about twenty different files for testing each type of number, there are now about that many that can be used to test any number at all!

Future versions will be trimmed, source-code-wise, so that there are many fewer files in the project in general. This should also speed compilation time, which has been bothering me lately, and will also facilitate finally making a fully cross-platform version that can be built from source with qmake.

I'm almost there, actually - I just need to figure out how to get it to not link against Windows-specific libraries, for example, and then I should be able to start testing on my Mac and eventually a Linux machine as well!

Wednesday, November 28, 2012

A New Era for NCPrime Development!

Okay, so the title is a bit dramatic. But it's accurate.

Today, I installed Windows 8 on the laptop I use for programming (and taking notes in class). It's an ASUS X54C-BBK5 15.4" basic notebook...with a Corsair Force 3 SATA III SSD, easily one of the fastest available at its modest price point. POST to login in 4 seconds running 64-bit Windows 8 Pro. Very nice indeed.

I took this opportunity primarily to finally try out Visual Studio 2012, and I must say, I was instantly hooked. Just look at the interface.


It's color-coded like XCode! and Eclipse. And NetBeans. And, well, most IDEs out there.

I mean wow. Great. It's easier to use than I thought. I initially was hesitant because I thought I'd have to learn a whole new set of features, but it turns out the few immediately noticeable functionality changes are actually intuitive and also improvements.

Futuristic, no?

I did, however, have to re-build Qt from source in its entirety, which took about two hours even with /MP. There are a few necessary tweaks to be made in order to build Qt 4.8.3 for VS2012 even though the mkspec remains win32-msvc2010. Since I built it with the VS2012 64-bit command prompt, I ended up with 64-bit Qt libraries and DLLs, which is fantastic, because now MuPuPriNT Extended (and soon every other NCPrime app) will be fully 64-bit!

I have yet to test the app on Windows 7 now it's rebuilt. I do have several Windows 7 machines available for testing. None have Qt installed, which is good to test the deployment itself, and one is (for some reason) 32-bit, so I'll have a go at that. Later I'll get around to testing everything on XP as well, although in the past there have been no issues even on a low-end laptop from 2005.

Currently, however, I am working on bug-squashing as for some reason the unified testing procedures for verbose and reverse BFTD do not work at all. In fact, they crash the application regardless of the number type selected or other options...

Here's what it all looks like at the moment!


Monday, November 26, 2012

MuPuPriNT Overhaul and Milestone Acknowledgements

This is the 100th post on this blog! It seems like I've made a lot more than that, but perhaps that's just me.

In any case, I have taken the last few days to make some major changes to MuPuPriNT - specifically, what it can do. Currently, MuPuPriNT 2.0.2 beta is the latest version available; it is only capable of testing four different kinds of numbers.

So, I am working on MuPuPriNT 2.1.0 Extended, which can test eleven different kinds! This includes Wagstaff, Carol, Kynea, Leyland, Thabit, and Cuban types 1 and 2 in addition to the current Proth, Cullen, Woodall, and Pythagorean options. The interface has been adjusted accordingly:


Note that there is now a drop-down box for number type selection instead of a slider. Additionally, there is now a button called "Numbers" which will display a table containing information about each type of number available for testing, including their requirements (for instance, n greater than 1, q must be prime, etc).

Also, I have made some major changes to the MuPuPriNT SourceForge page! Check it out.

I am going to be adding more to the wiki in the future, but if you are interested in how MuPuPriNT extended will work, check out the About page for 2.1.0.

Finally, I am looking into creating a unified testing procedure for MuPuPriNT. This would mean that instead of over twenty different header and source files for each type of number, there would be around twenty in total for the entire application! This would dramatically reduce compilation time, which lately has soared to about three minutes even using the /MP option. Also, it just makes more sense, and would remove a great deal of repeat code from the source repository and the application itself.

I know this is totally possible, so I will start by writing and testing this unified testing procedure with the new additions to MuPuPriNT's number "vocabulary" in order to determine its viability for full implementation. This will probably happen within the next week or so.

Since this is a milestone post on this blog, I'd just like to thank all of you who follow my progress, provide feedback and recommendations on SourceForge, and actually test or use my applications. I recognize that prime number testing is a bit of a "niche market," but I'm glad there are others out there whose interest in recreational mathematics has led them to the NCPrime family!

Saturday, November 24, 2012

GJSieve 2.0.3 beta

I'm on a roll. Now GJSieve uses significantly less memory (>30MB) for tests and also has the option to save the number to its own file! Find 2.0.3 beta here.

Yes, I am still technically considering this a beta. It is in testing. It is not perfect. It is also not too terribly flawed once you get past the fact the GUI is prone to lock up sometimes. But not all the time. Only sometimes. It's strange.

In any case, test away.

Friday, November 23, 2012

Massive Integer I/O

One of the biggest challenges faced when dealing with massive multiple-precision integers is memory usage. The last thing we want is stack overflows stemming from attempts to read or write a number too big for the space allocated.

Luckily, GMP (MPIR for Windows) seems to render most of those concerns moot, as it dynamically allocates, re-allocates, and eventually frees memory as variables are initialized, operated upon, and subsequently cleared. Of course, it ultimately still comes down to the programmer to remember to properly initialize all variables before their first use, and clear them from memory when done with them.

A more in-depth approach involves manually clearing and re-initializing integer variables as is done in all NCPrime applications. At the end of a single round of testing (dividing n by x), the variables that store(d) the remainder and quotient are cleared and immediately re-initialized. Since GMP/MPIR uses a standard zero-initialization technique, there is no loss of data and no residuals, meaning you will never end up with a partial integer being rounded up or down to give a variable a value it shouldn't actually have.

When the testing thread exits, several things happen. This will be covered in a later post, but behind the scenes, stuff is constantly getting deleted from and (sometimes) re-entered into memory. On completion of the thread, the instance of the "worker" class is scheduled for deletion when safe to do so. This happens as soon as the thread has completely exited. The worker class contains instances of structures for testing data, which are deleted when the worker instance is. Deletion of the structure leads to clearing of the actual variables used in testing.

It is a bit complicated, but efficient nonetheless. However, using multiple-precision integers internally is easy compared to inputting and outputting them. Input is done via strings. That is easy enough, especially considering the data in question already exists as a string (usually somewhere in the GUI).

Output is difficult because it involves creating a massive array of multi-byte characters...this usually, if not always eats up available memory. I have caught applications like GJSieve using well over 2GiB of RAM on some machines. It doesn't even get close to that on my usual testing/programming machine with a total of 4GiB RAM.

Printing the number takes A LOT less memory as it does not ever actually display the number. In fact, if the number is already displayed, it does practically no work at all. If not, it simply calculates the number based on the current number type selected and prints it to a string.

This is why I recommend in applications like MuPuPriNT and GJSieve leaving the "Show Number" box unchecked unless it is a small number (or a Pythagorean number, as those are often much smaller).

I just thought I'd write about that for a while. In the future, expect more posts on the inner workings of NCPrime applications. It really is quite fascinating.

MuPuPriNT 2.0.2 beta

I have finished MuPuPriNT 2.0.2. This is still considered a beta release, but it is quite stable and has all the functionality I wish it to at this time. Find it here.

Note that it is a good idea to leave "Show Number" un-checked, especially for very large numbers...if it is longer than a few hundred thousand digits, displaying the number will require creating a massive array in memory, which takes a ridiculous amount of memory to display, register, and render - not worth it! Save yourself some time.

Additionally, there is now an option to print the full number to a (separate) results file. This will be stored in a folder inside Documents/MuPuPriNT Results called Calculated Numbers (with sub-folders for each type of number).

It's all highly efficient and quite organized. It should work just fine. If not, let me know.

Also, Tweeting has been fixed and the string and/or URL created will always encode properly now. That one was tricky, but is functional and rather useful, too!

Monday, November 19, 2012

IsItPrime 2.0.8

IsItPrime 2.0.8 is out now. Find the archive here.

Changes:
  • major stability fixes and memory usage reductions for single-threaded BFTD and SPAT. 
  • new form of Tweeting results - choose what you want to say or include! - formatting fixes as usual - more detailed testing info
  • much more stable in long tests 
Known issues:
  • GUI still locks up
  • Pause/Resume functionality doesn't exist
  • Hard/Impossible to stop a test in progress...working on it! 
Note: currently the application must be kept with the two included DLLs. This will change in the future, but for now the application is built to call DLLs and not linked with static libraries included in the build. I'm still working on that!

I am currently having no luck with the static libraries, or with Qt 5.0 beta in general. I'm sure I can try more in the future once some things get patched up and/or I get more familiar with the whole qmake thing and makefiles in general. That should make stuff a bit easier, especially for cross-platform builds!