Monday, October 26, 2015

Paradise ponders...

Paradise ponders...  Skip to the “Geek-free” label below to bypass the programming content.

Yesterday was a “mostly programming” day for me.  I'm building an index class (for use in sparse vectors and sparse matrices) that doesn't use objects for its members (as do all the standard Java collections).  Why?  Because the matrices (in particular) will have millions of numbers, and storing each in an object triples the amount of memory consumed.  It's also a significant performance hit – in my testing prior to deciding to implement this, numbers-in-objects were almost six times slower than numeric primitives.  Implementing the index in arrays of primitives is much faster, but it's also a lot harder than simply using the Java collections.  In all my years of Java programming, I've never run into a situation like this before – and apparently, not too many other people have, either, as I can't find production-quality (or even working!) open source implementations anywhere.

So down this rabbit hole I go :)  The task at the moment is the aforementioned index, which I'm implementing as a red/black tree entirely stored in arrays of longs.  Red/black trees are a classic solution for this problem.  I've long known about them, have read extensively about them (in particular, their O(log2(n)) performance for all the key operations), but I have never before actually implemented one.  Yesterday I finished the first hurdle of difficulty: insertion is up and running, with an implementation I'm happy with.  I also have completed a test harness for verifying the correctness of the tree.  Next step (and last challenging bit!): tree node deletion.


 As I retrieved my tea cup from the dishwasher this morning, I marveled once again at the unobvious trick that cured our spotted dishes ills.  I keep meaning to write about this, but haven't remembered until this morning.  After Debbie joined me in Paradise, in December of last year, we noticed something annoying: our dishes would come out of the dishwasher with whitish spots all over them.  It was especially noticeable on anything made of metal or glass, but they were actually on all the dishes – if you ran your finger over a porcelain plate, you could feel them there as well.  I tried everything I could think of to troubleshoot the problem, including partially disassembling the dishwasher to check for some kind of blockage.  We assumed that the problem was related to rinsing somehow, because the spots came right off if we rinsed the (washed!) dishes under the faucet and hand-dried them.  Nothing I tried worked.

In sheer desperation, I resorted to Google – which, in hindsight, should have been my first action (like it is with software engineering these days).  In mere seconds, after reading several articles, a pattern emerged: people with soft water are usually putting too much soap in their dishwashers.  We have very soft water, the result of my installing a first-class water softener last year.  Were we putting too much soap in?  Probably, because we were using the same amount we did back in Jamul, where we had extremely hard water.  So we reduced our soap by a factor of about four, and ... the dishes came out spotless and sparkling.  It really was that simple.  The cup for the soap on the dishwasher was sized to handle the needs of people with soft water, so when you “fill” it properly for hard water, it looks like you're putting way too little in.  That happened several months ago, and it still boggles my mind every time I pull the perfect, squeaky-clean, sparkling dishes out of the dish washer...

Today is the last day of our inspection period on the log cabin we're buying.  We still have a couple of things left to do, so I'm expecting to be out part of the day.  Elray (the well driller) will be back today, and he will be drilling past the 120' mark by mid-day – which means today could be the day he hits water.  If he does, that's especially good news for us, as the water at that depth has considerably less iron in it than does the water from deeper layers.  On Friday I mentioned to Elray that I had never learned to weld.  His response: he's going to bring some junk metal and a spare “hood” for me, and he's going to give me some free lessons.  He uses a gas welding rig (oxygen and propane), which I have watched in use but never tried myself.  Should be interesting!  I'm certain Elray will be highly entertained :)

No comments:

Post a Comment