Matlab

Matlab code really doesn’t like nested for-loops. I didn’t realize how much until I had written the following piece of code for an assignment:


for i=1:k
     sum_z = zeros(1,size(z,2));
     misclassified = 0;
     
     for r=1:totalSamples
         if dot(a, z(r,:)) < 0
             sum_z = sum_z + z(r,:);
             misclassified = misclassified + 1;
         end
     end
    
    a = a + sum_z;
     
     if misclassified < best_misclassified
         best_misclassified = misclassified;
         aBest = a;
     end
end

For values of k larger than 10,000 the code took several minutes to run.

I re-wrote the code and removed the inner for-loop and if statement.

for i=1:k
    tmp = bsxfun(@times, a, z);
    s = sum(tmp, 2);
    misclassified = z(find( s < 0 ),:);
    numMisclassified = size(misclassified,1);
    sum_z = sum(misclassified);
    
    a = a + sum_z;
    
    if numMisclassified < best_misclassified
        best_misclassified = numMisclassified;
        aBest = a;
    end
end

Somewhat surprisingly it now only takes seconds to run.

Re-seating Samsung Series 9 Ultrabook CPU heatsink

The main computer that I’ve been using more and more recently is a Samsung Series 9 Ultrabook. This laptop/ultrabook is rather nice combination of power and size.

Samsung Series 9

Samsung Series 9

My setup involves having the laptop off to the side on a cooling mat, while it is hooked up to an external keyboard and monitor. (This allows for a more ergonomic set up as I can use a Kinesis Advantage keyboard as well as various trackballs/mice.)

However even with the cooling mat, I’ve noticed that the laptop seems to run rather warm.

I used Speedfan to measure the fluctuating temperature of the laptop under various loads. The laptop seems to idle around 55°C under normal usage (running chrome and a few text editors). However, if using something more intensive, such as a full-screen Skype video call, the laptop runs anywhere from 60 to 70°C. I’ve even seen the laptop get as high as 72°C, at which point the cooling fan in the laptop seems to be running as fast as possible and sounds like a little jet engine.

Not only is this annoying to listen to, but I’m concerned about the lifetime of the fan. I’ve had to replace fans in laptops before and they are not cheap. So in this light I decided I would disassemble the laptop and attempt to re-seat the heatsink with better thermal compound.

The laptop is surprisingly easy to disassemble. A few simple screws on the bottom to remove and the bottom cover pops off. From here most of the important things are accessible (excluding things like the keyboard and such).

Removed back cover

Removed back cover

Back cover

Back cover

   

There is a single heatsink in the laptop that serves both the CPU and GPU. This heatsink also has a copper heat pipe to transfer heat away from the CPU towards the radiator fins by the fan.

Heatsink

Heatsink

Removing the heatsink is also very straightforward. There are 5 Philips screws to remove and it simply pops right off. I also took the blower fan out and cleaned it out. There was some dust in the radiator fins as well that was easily removed.

Removed the heatsink

Removed the heatsink

CPU & GPU dies

CPU & GPU dies

   

I cleaned off the old thermal compound and insured the surfaces or sparkling clean using 99% isopropyl rubbing alcohol. (If you’re doing any electronic or computer-related work I recommend the 99% alcohol rather than lower concentrations like 50%. The reason is that the 99% concentration ensures there are less impurities in the liquid itself as well as it dries much quicker saving you a bit of time.)

Cleaned heatsink

Cleaned heatsink

All clean and shiney

All clean and shiney

   

I was rather surprised at the thermal compound that Samsung chose to use for the laptop. Normally in laptops they use some form of cheap thermal compound that tends to dry rather quickly and become crusty and flaky. Or even worse, sometimes cheap laptop manufacturers won’t even use thermal compound and will instead use thermal pads that sit between the CPU die and the heatsink. Samsung had chosen to use a somewhat decent thermal compound that was still slightly liquid in nature.

As a replacement thermal compound I decided to use the Arctic MX-4 as I had some leftover from when I built a desktop computer.

Arctic Thermal Compound

Arctic Thermal Compound

After reassembling the laptop and putting the bottom back on I tested it and measure the temperature with Speedfan again.

All done & heatsink back on

All done & heatsink back on

I wasn’t expecting a very large difference considering that Samsung had used a seemingly decent quality thermal compound before, but I was pleasantly surprised with the results. The laptop now idles around 47°C, and under higher load with a full-screen Skype video call the temperature peaks at about 66°C. (That’s a 8°C difference while idle and a 4-6°C difference under load)

It’s rather amazing that you can get an approximate 5°C temperature drop just by using a better quality thermal compound. Absolutely nothing else was changed in the laptop, and I did not change any settings in the software/operating system.

Full disclosure: One thing I did not account for in these measurements was the ambient temperature of the room. Obviously having a higher temperature in the room would cause a higher temperature for the CPU.

That said, the measurements before and after were done on the same day in a relatively short period of time, and the temperature was relatively constant throughout the day.

Overall I’m rather pleased with the end result. The cooling fan in the laptop no longer needs to run at full speed all the time while the laptop is under load.

Kensington Optical Expert Mouse – Review & Teardown

Trackballs have a long history as an input devices for computers. (The very first trackball invented used a 5-pin bowling ball as the ball device. ) However, in recent times it seems as though the popularity of the trackball is in decline. Finding them in retail stores seems to be more and more difficult. After coming to the realization that I’ve tried just about every type of mouse in existence – and still having no success with my wrist pain – I decided to give trackballs a try. My first real experience with a trackball was with a form of industrial trackball that was clearly designed with ruggedness first, and user comfort second.

A typical industrial trackball. Ruggedness first, comfort second.

A typical industrial trackball. Ruggedness first, comfort second.

Regardless of the shortcomings of the design, I found that using two trackball mice simultaneously (one for each hand) worked marvelously for my wrists. Being able to click with one hand and control the positioning with another seemed to work quite well. In addition, you could alternate between which hand was doing the clicking, and which was doing the positioning. Having had success with using two old industrial trackball mice, I decided that it would probably be worthwhile looking into obtaining a better trackball mouse. The old industrial mice used rollers which accumulated dirt and fuzz over time. Furthermore, the buttons were rather difficult to press and required a fair bit of force for one finger. After doing some research I decided on trying the Kensington Expert Mouse. This particular mouse seems to have relatively favorable reviews online, and comes with a 5 year warranty from the company.

Kensington Expert Mouse Optical Trackball

Kensington Expert Mouse Optical Trackball

I ordered it from Amazon.com as that was the cheapest place I could find it. Instead of just doing a text-based review, I decided to do a review of the mouse in video form as well.

I ended up taking the mouse apart as the scroll ring seemed rather rough and like it was catching on something. I didn’t notice any “Warranty Void if Opened” stickers on the mouse so I’m guessing that the warranty is still intact. The mouse itself was rather easy to disassemble and there honestly was not much inside. The easy disassembly is quite nice in case the inside becomes dirty and needs to be cleaned.

Trackball Disassembled

Trackball Disassembled

Side View

Side View

Trackball cup upside-down

Trackball cup upside-down

Unfortunately there wasn’t much that I could do about the scroll ring. The entire cup that the ball sits in is one solid piece of snap together plastic. You can see little white ball bearings that the scroll ring rides on though; perhaps if I had some sort of plastic lube I could have lubricated them. [Aside: apparently I’m not the only one with some issues with the scroll ring.] That said though, the trackball itself is quite nice. I did note that initially the ball was difficult to move when first taken out of the packaging. However, after handling the ball somewhat and rubbing my finger on the 3 ball bearings that it sits on, the movement was much smoother. Despite some concern voiced online about the driver software having issues with Windows 7, I did not have any problems. I suspect that Kensington has updated the software since those complaints as the software driver I downloaded stated that it was copyright 2011.

Trackball Software

Trackball Software

Trackball Software

Trackball Software Version 1.1

Overall, I’m rather pleased with the trackball – It’s working quite well and I have no complaints other than the scroll ring roughness. Of course, time will tell. I plan on using the trackball as my main pointing device for the next few weeks and see how my wrists fair.