Intel's Ronler Acres Plant

Silicon Forest
If the type is too small, Ctrl+ is your friend

Wednesday, May 30, 2018

Calculating

I'm working on a little program to play with some numbers and I need an array of the appropriate size. It's easy to do, you decide on some array size and then you ask the O.S. for a chunk of memory that big. If you are a well behaved program, and the O.S. likes the cut of your jib, he might let you have it.

You don't want to ask for anymore than you need because if you ask for a great deal, that might interfere with whatever else you are trying to do, like trying to watch YouTube videos. Also, large amounts of memory can involve lots of processor time, and you might not want to run the program for that long, so you run on it a smaller set of data.

In the C programming language there are a couple of ways to do this. The traditional way is call malloc, the O.S.'s memory allocation procedure with number of bytes you want. It will return a pointer which you will base your data structure on.

    fraction_s* a = malloc(q * sizeof(fraction_s));

Another way is to declare your array in the main procedure (which is where the program starts), and use another variable as the size of the array. You need to assign a value to the size variable before you try and make use of it in the declaration of the array. Get all that? Sounds kind of convoluted. Maybe it's just my explanation is convoluted. Let's see if a bit of code helps.

int main(int argc, char** argv)
{

    int q = 1000;    // default value
    if (argc>1)
        q = atoi(argv[1]);    // pick up value from command line

    fraction_s    a[q];       // declare an array of data blocks

    memset(a, 0, sizeof(a));  // zero out the array

Last thing is to fill the array with zeros. Saves having to do it explicitly whenever we are loading data, we can just skip all those locations for which we don't have data. That way, come run time, we can be sure we won't misinterpret them for data. We might want to set a flag in each block that does have valid data.

Took a while to get here, but we have finally got to the crux of the matter. I'm working on a program to check out Farey Addition of fractions. I need an array to hold of all the possible fractions that can be generated using any pair of integers, up to some limit. For instance if my limit was 1,000, I would need an array to hold a million numbers. If I confine my self to proper fractions (the numerator is smaller than the denominator), then I only need half as much. Roughly.

You don't want to get a size calculation like this wrong, because while it might be a nuisance when the program is only going to run for a few seconds, it would be the shitz if your program got a memory fault after it had been running for a week and it lost all your work, all because you got the memory request size calculation wrong.

You screw up once or twice and you start taking pains to get it right. Getting it right also insures that your program doesn't get kicked off for asking for too much memory, when a properly sized request would allow you to run. It also tells you how much memory you need for the kinds of problems you are working with.

There's probably a name for the series that tells you how many fractions you are going to generate. Fibonacci or Bernoulli, or maybe, I dunno, Flatulence? I think I'm getting burned out on the math section of Quora. Seems like half the questions over there are talking about some obscure thing named after an even more obscure, old, dead, white guy (usually). Numberphile does that some too, but usually it's just kind of a decoration, like ribbons and bows, on their presentation. On Quora, these names are in these questions and understanding what the term means is crucial to understanding the question. Sometimes it's really simple, like this fraction thing I am working around to explaining, which is great, it means I can understand the question. But sometimes it's such an esoteric term that only the half dozen people who are writing theses on it have any idea what it means. I'm not going into those ratholes, I have plenty of my own, thank you.

Back to our array. For a denominator of 1 you can have two values in the numerator: 0 or 1. We're only going to count the zero. One over one is one, which really isn't a fraction. We aren't going to count the one, so for one, we have one value. For a denominator of 2 you can have two real values: 0 or 1. Plus 1 for zero gives you three. Like so:

Denominator /
Number of Proper Fractions    Total
            1              1
            2              3
            3              6
            4             10
            5             15
            6             21
            7             28
            8             36
            9             45
           10             55

It kind of looks (n+1) * n/2. It looks an exact calculation to me. No issue with rounding due to division by 2 (of n and (n+1) ), one is going to be even and the other will be odd, so the product will always be even and divisible by two.

We could eliminate the zeros, and maybe I will, all zeros are alike, am I right? But right now it's handy becuase I've been using zero based arrays for so long it's like second nature. Taking out the zeros, oh boy, I dunno if that's ever been done before Mr. Halliday (figment of my imagination, my inner Jimmy Stewart talking to big fat boss man with the straw hat, bifocals and a cigar).

Smart Phones

Looks like the Smartphone market is saturated. From a report by Mary Perkins. Via Detroit Steve.

Is it 'Smart Phone'  or 'Smartphone'? I'm a little perturbed by this mashing together of two perfectly cromulent words to make a new word. Sometimes it just doesn't work. I ran into one earlier that really confused me. It took me several seconds to decode it. Can't remember what it was now. Wasn't that important, just another example of our world going to hell in a handbasket, and we've already got plenty of those.

Mixer Repair

Bypass Thermal Protector
Our electric hand mixer quit the other day. We suspected that it had gotten overheated but that when it cooled down it would come back to life. It didn't, so I opened it up to see what I could see. I didn't see anything wrong, and it didn't smell burnt. I did notice a little lump under the yellow tape covering the windings on the stator. I cut the tape and checked the continuity on the little white part and, as I suspected, there was none. Twisting the leads together circumvented that problem. If this was a real repair, I would have soldered the wires together. Scratch that, if this was a real repair, I would have replaced the part. I sort of made an attempt in that direction. In order to secure a replacement, I need to identify it. Being as it is so tiny that even with my glasses the numbers were hard to read I decided to take a picture. As you can see from the photo that didn't really help. The macro function on my camera wasn't up to the task so all I got was some indecipherable squiggles.

I secured the yellow tape back in place with a piece of duck tape. I had electrical tape, but the adhesive on electrical tape doesn't seem to adhere as well, or as long, as duct tape. For some situations, electrical tape works fine, but I've had too many places where the sticky gave up the ghost. So duck tape.

The mixer runs, though it sounds a little growly on the slow speed settings. I looked for a replacement, but I couldn't find one that had a bigger than 250 Watt motor. That seems to be the upper limit for hand mixers. Yes, I could have gotten a big stand mounted mixer, but it would have just sat in the cupboard because no one wants to go to the effort to pull it out, and after it's set in there for a couple of years we would have forgotten that we even have it. We already have a good selection of kitchen appliances we don't use. We don't need another one.

Maybe we just need more counter space in the kitchen. I suspect that wouldn't really help because it would just be consumed by a bunch of new appliances that we bought because we had room for them. I still cut pizza with a chef's knife, I don't need to steenking pizza cutter.

Monday, May 28, 2018

Conspiracies Я Us


I think there is a conspiracy operating in downtown Portland that is trying to destroy real estate values. Walking around a small area near Nordstrom I noticed numerous storefronts that are either empty or for lease. The city government seems bent on destroying the automobile. Mass transit and conversion of parking spaces to anything but parking seems to be the order of the day. The result of this, along with their increasing taxes, is that running a small business in Portland is becoming a losing proposition, hence the numerous empty storefronts. They are empty because nobody’s renting them because they don’t believe they could operate their business successfully in such a hostile atmosphere. Businesses operating on the upper floors are kind of immune to all this. Virtually none of them depend on walk-in traffic. But office space is a commodity. The only time you can charge a premium is if there is a view or office space market is tight.


Meanwhile rent for ground floor places is plummeting, which has to be driving the value of the property down. Eventually some real estate investors are going to get tired of the bullshit and sell off their holdings. At that point the conspirators will swoop in and snatch it all up at bargain prices.

Once they have consolidated their hold on downtown they will replace the City Council with one that has the proper attitude and all these bullshit regulations and restrictions will be blown away, people will start driving cars again, storefront businesses boom and the conspirators will reap their criminal rewards.


I’m pretty sure this theory is nonsensical and could easily be destroyed by any kind of elementary analysis but the fact remains that I am troubled by the numerous empty storefronts. Maybe we don’t need so many retail establishments anymore. So what do you do with them? What could these places be used for that would generate kind of rent that a retail store would? Maybe it doesn’t make any difference since nobody seems to be opening any new retail stores.
You might be able convert them to parking, but many buildings are not going to be suitable for that. Or maybe they will become squats for the homeless. There are certainly enough of them. I saw maybe a dozen while I was out walking, so I'm estimating that somewhere between one out of a thousand and one out of a hundred people are homeless.




I originally wrote this using pen and paper while I was waiting for my wife. She got herself a new iPhone 8+ today because her old iPhone 6 was getting flakey, so I thought I would try using the 'talk-to-text' feature instead of typing it in by hand. She set up her phone to compose an email, pressed the go button and I read what I had written. It took three emails to get it all, but I don't know whether that was due to the operator or the phone. That got the bulk of it entered, but then I had to go through and replace the incorrect words and insert the necessary punctuation. It was kind of a fun experiment, but not very efficient.

The actual conversion of voice to text is done on a server somewhere in the cloud, so theoretically you should be able to do this from any computer with a microphone and an Internet connection.

Friday, May 25, 2018

More Thinkin'

Thinking about how get things done, things like WW2 where results are what count. And things like city council subcommittee meetings where 'process' (whatever that is) is all important. Sometimes you need to do something, right or wrong, but something needs to be done. Sometimes nothing needs to be done, we can postpone it till next week, or next month, or next never. The difference is in the risk and the reward. When you are out on the fringes of civilization, standing on the edge of plaza facing down the barbarians who would love nothing more that to overrun your plaza and smash everything and everyone on it, a forceful and decisive attitude is what you need. When you are in operating within the confines of the plaza, you can dilly dally all you like, that's why we built the plaza, so we could recline on soft couchs and eat delicacies and argue about the most inconsequential of things.

God protect me from subcommittee meetings. I would die of boredom. Listening to people that I don't know talk is my least favorite inactivity. Maybe if I was drunk I could do it, but they generally don't let beer into those sessions. Just as well, waste of good beer.