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!

Sunday, November 18, 2012

Latest NCPrime Applications

Changes made in GJSieve 2.2.1, IsItPrime 2.0.7, and MuPuPriNT 2.0.0 as of late are all about the same, so here goes:
  • use a slider to select a test type instead of ugly checkboxes
  • use a slider to select a number type in MuPuPriNT 
  • Saved results files are more detailed with regards to what was actually done
  • Quick Stats is also more detailed 
  • Time measurements are now correct (both CPU time and wall clock time)
  • BFTD (non-verbose) was renamed to BFTD (single), meaning single-threaded
  • SPAT and BFTD (single) have been changed and updated to use a more modern and safe thread management system, so memory usage by these tests should be dramatically lower (not in IsItPrime...yet!)
  • BFTD (single) is also much more stable now
Known issues:
  • The Pause, Resume, and STOP buttons (still) do nothing. I am unsure if they ever will. I am looking into reasons for the GUI locking up despite running things in a separate thread, though I think it might be due to the GUI object itself being the thread's / threads' parent.
  • In that vein, the application may say it is "not responding" whilst doing a very long test. This is, unfortunately, normal. I have not yet run a test long enough to verify if the application is working or actually hanging, as CPU usage remains normal (for a primality test, that is)
Future changes:
  • MuPuPriNT Tweeting will say what kind of number was tested 
  • All Tweeting will say (provided the test in question has finished) if the number was prime, or how many factors it had (you will have options!)
  • Saved results files will be even more detailed!
  • You will also have the option to include the full calculated number in the results file (or, more likely, in a separate file altogether) - this will probably take a while and might not work properly or at all for very very large numbers.

GJSieve 2.2.1 beta

I also finished the testing version of GJSieve 2.2.1 for Windows using Qt. Find the archive here.

In the next post, I will describe changes to this, IsItPrime, and MuPuPriNT (all of which have been refreshed and updated within the last few days!)

Saturday, November 17, 2012

MuPuPriNT 2.0.0 beta

Here is the testing release of MuPuPriNT 2.0.0. It is still a beta, but everything should be totally functional. You can find the archive here. Bear in mind this is still not a full redistributable, so the application cannot be moved out of the directory where it's located because it needs to be in the same place as the two DLLs.

This version will only work for Windows at the moment. I will release the source once I have created a version buildable with qmake, but that is still in testing. I am still not entirely sure how to make cross-platform builds, but I'm working on it.

GJSieve will be out shortly.

Tuesday, November 13, 2012

I broke Qt


Not quite sure how I managed to do this, but I did. I waited about an hour to build Qt statically and this is what I get :(

So much for an open redistributable...

Well, it's back to the drawing board on this one for sure. I should have it fixed by later tonight...I hope...

MuPuPriNT 2.0.0 in progress

It's been over a month since this application got an update. So, since I'm on a roll with Qt stuff, here's what I've done to the aged MuPuPriNT interface and format!


Notice the use of sliders in place of silly check boxes. Also, the buttons are bigger now. It's also a lot easier to tell what kind of test you've selected and what kind of number you're calculating or testing because the labels become bold when selected.

Still working on using all of those boxes.

Sunday, November 11, 2012

GJSieve 2.2.1 in progress

I have almost completed GJSieve 2.2.1. It just needs a few more stability tweaks for reverse testing and we'll be good to go! Also, not all the menu functionality is implemented yet and there are still some options for user configuration I'd like to add, or at least look into adding.

GJSieve 2.2.1 is completely redone graphically and also uses revamped testing algorithms. Memory usage is no longer nearly as big of an issue as it was before. In fact, everything should be quite manageable now!

Here's what the interface looks like at present:


Saturday, November 10, 2012

IsItPrime Source

Taken from this page of the IsItPrime wiki.

If you are looking for really old code, click the "Code" link. That's from 1.6.0 for Windows.
The more modern code is in a SVN repo under "Source." This contains the modern (but deprecated) 1.9.5 for Windows, as well as a /branches repo for the original 2.0.0 and a /qt branch.

As of 10 November 2012, only the /qt branch is up-to-date! This is where the current version's source is contained. This was originally for the /branches repo, but that ended up getting clogged with old libraries and a lot of files that were either unnecessary or deprecated but not removed.

Also, I'm very new to the whole concept of SVN and source management in general, so bear with me. I currently use VisualSVN plugin for Visual Studio 2010 Professional (which in turn utilizes TortoiseSVN) and it's mostly automated in that I just need to click stuff. That works for me but I'm always open to suggestions on new approaches.

So, again - checkout the /qt branch if you must, not anything else (unless for some reason you want old, bad, broken, ugly, or just plain wrong code).

I don't like admitting I'm unfamiliar with things I try to do anyway, but well, it's true.

Tuesday, November 6, 2012

GJSieve Qt version

I was really on a roll yesterday and have re-done GJSieve's interface to use Qt as well.

Thus far, all basic UI functionality is there, including saving, Tweeting, and clearing the screen. Additionally, BFTD and SPAT testing works just fine.

There's also a multi-stage Calculate / Test button. Click it once to calculate the Proth number (provided it's a legitimate Proth formula). It morphs into a Test button, so you can pick a test and go from there!

 Basic interface.
 Calculating a number
Results of a non-verbose BFTD test. This goes up to the square root, but stops after finding just one factor.

Yes, I know it's a bit hard to read the box with the quotient (a long number) and the Quick Stats box with the square root (an equally long number). I will work on that.

Sunday, November 4, 2012

Build IsItPrime!

I have written Makefiles for IsItPrime 2.0.5 that work with a Qt project file to build the application using nmake.

This means it is currently Windows-only - specifically, Windows 7. It builds an x86 version, which is more a symptom of Qt itself.

Find the archive here and run the runBuild batch file in the IsItPrimeQT_200 folder.

Let me know if there are any problems or concerns...

Thursday, November 1, 2012

IIP 2.0.4 testing release

This version is almost done. In fact it's the closest to optimally "done" as I've yet gotten!

Still to do:
  • BFTD-Reverse testing interface and implementation
  • SPAT and BFTD threading re-work
  • figure out why things lock up
Try out this latest testing release! Don't move the DLLs out of the folder there...I'll try and bundle them but I still don't know how.

Why Qt, anyway?

adapted from the IsItPrime Wiki

Why re-write the entire application using the same basic language but a different framework?

Qt is a cross-platform application development framework by Nokia. It is great for graphically-enabled applications that need to be deployed on multiple operating systems in different environments with little to no intrinsic change.

Qt is great for applications such as IsItPrime and other NCPrime projects because it is simple, straightforward, and allows for the look and feel to stay more or less the same on different OSs. Currently, IsItPrime for OS X and Windows not only look different, but actually are different.

With the creation of a Qt codebase, this will change. Soon, IsItPrime will be consistent on many different platforms, including (eventually) Linux.

The Windows version of IsItPrime Qt (2.0.0) has been re-written from the ground up to use absolutely no Windows-specific code - that is, it no longer uses the Win32 API whatsoever.
This is both a good thing and a bit of a hurdle. Qt luckily includes functionality identical or at least similar to what can be done with the Windows API. If it doesn't, there is usually a workaround for emulation.

The OS X version, while it may still be Qt-enabled, will also include several OS X-specific features like Twitter and Facebook integration, as that exists with OS X Mountain Lion (10.8.2) and above. For backwards compatibility, a version will be released with different workarounds for these features (or with them removed).

Linux will be tricky as I haven't ever actually programmed for/on Linux. I do have a LinuxBook Pro now (read: MacBook Pro running Ubuntu), so that should definitely help. The idea is to take the current Visual Studio 2010 solution and convert the whole thing to a qmake project that can then be compiled cross-platform on any system with Qt installed.

Currently, the Qt version of IsItPrime must be distributed with two DLLs included in the application directory (and the DLLs cannot be moved); if I wanted to write an installer, that would remove the need for the DLLs to be packaged in the application directory but would also be a lot of work and an unneccesary extra step.

I really like portable applications - that is, no installation. So I intend to keep all NCPrime applications working out-of-the-box with no installation necessary.

Soon, I will also be re-writing GJSieve to use Qt. Most likely, it will be IsItPrime with a few things changed in the UI and behind the scenes (ie to calculate the Proth number). Then, in the not-too-distant-but-still-distant future, MuPuPriNT will get a nice Qt makeover as well!

For now, I suppose Windows users will just have to settle for the current versions of GJSieve and MuPuPriNT.

By the way, if you currently cannot get to the MuPuPriNT, GJSieve, or IsItPrime, it's SourceForge having some technical difficulties.