Software


MATLAB (the scientific computing software) has a lot of built-in functions for doing various matrix operations quickly without using loops (for, while, etc.).  When you’re computing vast amounts of data, this can save a lot of time as each loop iteration eats compute cycles.

Today I needed a function that returned only the positive elements of a matrix.  I was surprised to find that MATLAB does not include this as a built-in function.  A quick google search came up empty.  It’s very easy to write a program to search for elements that are postive by iterating through all the elements of a matrix and forming either a mask (a matrix of 1’s and 0’s - 1’s for positives) or directly generating the matrix needed.  However, this does not keep with the idea of avoiding loops.

Here is the solution I came up with.  First of all, let’s do some math.  If you add the absolute value of a negative number to itself, you’ll get zero.

Example: -2+|-2| = 0

For positive numbers you’ll end up with two times the number…

Example: 3+|3| = 6

Thus, an equation to get only the positive (elements) numbers, where X is any matrix of numbers is:

X + |X| / 2 = positive numbers of X

In MATLAB this is coded as:

MATLAB > (X+abs(X))./2

Now, let’s get a bit mask out of this.  All we need to do is divide the matrix X by itself to get ones since anything divided by itself equals one (x/x = 1).  However, this method will produce “divide by zero” warnings in MATLAB if you have zeros in your matrix.  A simple fix is to use binary arithmatic instead of dividing the matrix by itself.  The following will produce the mask of positive elements:

MATLAB > ((X+abs(X))./2)&1

In this case the positive values are converted to 1’s by performing a binary AND with 1 on the matrix.  Now we have a nice bit mask to work with for the next step of finding the negative numbers.  Taking the code from before and inverting it gives us a mask of non-positives (includes zeros).  But the zeros will fall out when multiplied by the original matrix.  That gives us this code of the negative elements of the matrix:

MATLAB > ~(((X+abs(X))./2)&1).*X

If a mask of negative elements is desired, simple use the binary AND operator again.

MATLAB > ~(((X+abs(X))./2)&1).*X&1

And finally if we want a mask of zeros in the matrix, we can combine both masks and invert.

MATLAB > ~((~(((X+abs(X))./2)&1).*X&1)+(((X+abs(X))./2)&1))

These pieces of code allow efficient computation of positive, negative, and zero elements as well as their corresponding bit masks.

It’s a sad day.

LeechFTP finally refused to cooperate with my Windows setup.  After trying various work-arounds, disabling all firewalls, etc. I have come to the conclusion that it just won’t play nice with Vista.  I had it working for about 7 months with no problems.

Tonight I had to install FileZilla just to download some files from a website.  Let me tell you - I do not like the UI (user interface) in this program.  To me, nothing beats the UI in LeechFTP and I am going to sincerely miss this program.  I will say that FileZilla has improved the site management over the past few years, so that will make one part of this program much easier to use compared to the past.  I think their management of the threads is annoying.  I also do not like that the program cycles through the remote folders when it traverses them to download their contents.  I cannot find a way to turn this off.  I’ll keep working with FileZilla for awhile and see how it goes.

Goodbye Leech.

Wake up, Jan Debis.

I’ve bought a few CDs on iTunes “Plus” recently - all of which I promptly burnt to a CD and listened to that way.  For me, iTunes’s puny 128kbps standard encoding is too poor to enjoy much of the music that I like.  So when iTunes Plus, featuring “DRM-free music tracks featuring high quality 256 kbps AAC encoding for audio quality” came out I was thrilled.  The new tracks I downloaded seemed to stand up to my library - all encoded at 320kbps.

Today I purchased an album by the Doves on iTunes Plus.  I didn’t have the time to burn a CD, so I just threw my DRM-free tracks on my portable HD and headed into work.  Then I tried to play the files in Windows Media Player.  No luck.

I researched the iTunes Plus file format (.m4p) and discovered that WMP doesn’t play this type of file.  This is somewhat astonishing to me.  Obviously, it is good for Apple to not have their tracks playable on Microsoft software such as WMP, a direct competator.  But what made me frustrated is their DRM-free label.  A quick google search reveals various converters and even some “codecs” that I have read varying degrees of success about.  But why, Apple?  Why not give us what we all want…???

…the MP3

I guess I’ll go back to Amazon.com’s MP3 store.

I have recently acquired a passion for subversion control (SVN) through my work with the SiteX project.  I gave another developer in the SiteX community a charge to figure out SVN for version control and collaborative development.  By the end of the weekend our development process had been taken to the next level.

My SVN client software of choice is TortoiseSVN.  This program installs in Windows and creates a new menu when you right click any file or folder.  You can create your own repository or connect to an existing external repository.  The repository is the place where your stuff is stored and accessed.  Files are “committed” to the repository along with a note.  This creates a revision.  You can “update” you files to download the latest revision.  When you’ve reached an acceptable stable “version” of your software, this can be “tagged” and stored in its current state for easy access later on.  TortoiseSVN also includes a decent diff tool which shows you the differences in two side-by-side files.  This is great for comparing a new file to an old revision or merging two new files together.  Access can be controlled to your SVN as well.  There are so many features and options it is impossible to describe them all here.

Currently, the SiteX project uses Sourgeforge.net for our SVN hosting since it is integrated with some nice project management tools all bundled via their website for free.

SVN is so popular that there are now server hosts that specialize in private, backed up SVN packages which include ticket management (like Bugzilla and Trac).  If I had an extra $30 laying around each month, this would definitely be a good investment.  Many include great features like cluster computing, RAID 5, and 10 minute backups.  I’ve even found one host that has a free account (no tracking or web-based SVN browsing included).

I personally am beginning to use SVN for more than just SiteX.  I’ve now expanded my personal repository to track revisions of documents and other web projects.  That way I always have a record of changes.  If you’ve never tried out SVN and you manage any sort of code that changes periodically, you simply MUST check it out!

Space Quest 1 (VGA)This past week I reconnected with an old floppy disk game Space Quest 1 (VGA edition) by Sierra.  Luckily I have backups of my floppies now, because the disks no longer work.  If you’re holding on to old floppies, you may be  surprised to discover that the data is no longer there!  Anyways, I played the game through in about 3 hours the other night and really enjoyed it.  Space Quest 1 is an old Sierra RPG in which you are a janitor given the job of saving the universe.  The game is a ton of fun and was one of my favorite computer games when I was younger.  What’s funny is this game has to run on DosBOX, an emulator of DOS.  It’s hard to imagine we already need emulators for those games in a Windows environment.

Have you recently reconnected with an old video game? 

Next Page »