Author: mattchung

  • No exercise (or tennis) this week

    I’ve been limping around for the past week, pulling a muscle in my left thigh. No fault other than my own, though. 

    One evening last week, Jess and I hit the gym together, exercising at the Northgate 24 hour fitness (which is apparently one of the more popular 24 hour fitnesses in Seattle, due to the larger floor plan and access to the wide range of newer equipment).  The two of us were standing in front of the mirrors, facing the dumbbell racks, shrugging our shoulders up and down to work our traps. After 12 shrugs, the first set was complete but out of no where, I decided to transition, without rest, directly into a new exercise that I invented on the spot: air lunges with 35 pound weights in either hand.

    So with the circular 35 pound weights dangling on the finger tips of my hands, I stepped my left foot out in front of me and lowered both my knees to 90 degree angles, pausing for a moment and inhaling deeply, and then pressed the balls of my feet into the ground to propel me against the gym floor. After a thunderous landing, I switched to the other side, my right foot now in front, repeating the same motion.

    But it only took 1 repetition of this ridiculous exercise to realize that this was a bad idea. Air lunges — without weights — already strains both the muscles in my thighs and calves, the additional weights pushing me over the edge, exceeding my pain threshold. Immediately after, I regretted my decision. Worst of all, this impromptu exercise must’ve really damaged either my ligaments or muscles or tissues (or all three) cause since then, I’be been in a fair amount of pain and unable to neither exercise nor walking normally.

    Lesson learned.

    Take it slow — I’m not 15 any more (in fact, I’m twice that age!).

  • Linear algebra – exam 1

    Earlier this morning, before starting the work week, I took my first linear algebra exam at the nearby Northgate Testing center.  The proctored exam covered the first four modules in the course, topics including:

    • Gaussian elimination (row echelon)
    • Gaussian Jordan elimination (row reduced echelon)
    • Adding, subtracting, multiplying matrices
    • Calculating the inverse of matrices (using identity matrices)
    • LU Factorization

    I felt well prepared (thanks again to Khan Academy and 3Blue1Brown). Going into the exam, I worked (and reworked) the suggested exercises in the textbook.  Honestly, I think if I hadn’t attempted the exercises, my mind would’ve tricked me into believing that I understood the material. But that obviously wasn’t the case because the different math problems had me fumbling around, furiously scribbling pencil all over my notebook paper followed by vigorous strokes of erasing. Anyways, 1 exam down — 2 more to go.

    Next topic: calculating the determinant of a matrix (at this present moment, I have no idea what that means)

     

  • Assembly RA (return address)

    About a year has passed since I took computer organization and I’m a bit disappointed of how much of the material faded from my memory. I only realized this while reading about Exception Control Flow (ECF) in the book Computer Systems: A programmer’s perspective, when the authors mentioned:

    As with a procedure call, the processor pushes a return address on the stack before branching to the handler

    Section 8.1 Exceptions

    I had to pause for a moment because despite a handful of assembly programs — one of them where I implemented quicksort — I totally forgot how, in assembly, how the return address gets handled. But after reviewing my own assembly program that I wrote earlier this year, I realized that the syscall directs the processor to store the PC value into the ra (return address) register.  Then, it’s the callee’s responsiblity to then save that value on the stack and after its routine finishes, call jr (jump return).

    Here’s some sample code

    main:
    	la $a0, numbers		# Load the address numbers into $a0, the first argument
    	li $a1, 0		# Load 0 into $a, the second argument
    	lw $t0, length		# Load the length of the array into temporary register $t0
    	sub $a2, $t0, 1		# Subtract 1 from the length of the array and store into $a3, the first argument
    	jal quicksort
    	li $v0, 10
    	syscall
    
    quicksort:
    
    quicksort_if:
    
    	bge $a1, $a2, quicksort_end_if	# CHeck if low < high
    
    quicksort_body:
    	addi, $sp, $sp, -24	# Update the stack pointer, allocating enough room for savin the 6 registers
    	sw $ra, 0($sp)		# Store return address on the stack
    	sw $s0, 4($sp)		# Store $s1 on the stack
    	sw $s1, 8($sp)		# Store $s2 on the stack
    	sw $s2, 12($sp)		# Store $s3 on the stack
    	sw $s3, 16($sp)		# Store $s3 on the stack
    	sw $s4, 20($sp)		# Store $s3 on the stack
    	move $s0, $a0		# Store $a0 (address of array) into $s0
    	move $s1, $a1		# Store $a1 (low) into $s1
    	move $s2, $a2		# Store $a2 (high) into $s2
    	jal partition		# Call the subprogram partition
    	move $s4, $v0		# Store pivot -1 into $a2
    	move $a0, $s0		# Store $s0, array, into $a0
    	move $a1, $s1		# Store $s1, low, into $a1
    	move $a2, $s4		# Store pivot position in $a2
    	sub $a2, $a2, 1		# Subtract 1 from $a2 (i.e. pivot - 1)
    	jal quicksort		# First call to quicksort (i.e. quickSort(array, low, pivotPosition - 1)
    	move $a0, $s0		# Store array into $a0
    	move $a1, $s4		# Move pivot into $a1
    	add $a1, $a1, 1		# Add 1 to $a1 (i.e. pivot + 1)
    	move $a2, $s2		# Move high (i.e. $s2) into $a2
    	jal quicksort		# Second call to quicksort (i.e. quickSort(array, pivotPosition + 1, high)
    	lw $ra, 0($sp)		# Restore the return address from the stack and back into $ra
    	lw $s0, 4($sp)		# Restore $s0 from the stack
    	lw $s1, 8($sp)		# Restore $s1 from the stack
    	lw $s2, 12($sp)		# Restore $s2 from the stack
    	lw $s3, 16($sp)		# Restore $s2 from the stack
    	lw $s4, 20($sp)		# Restore $s2 from the stack
    	addi $sp, $sp, 24	# Pop the call frame
  • Tennis serve in slow motion

    Last week, with just my iPhone and a camera tripod, I recorded myself hitting tennis balls launched by the ball machine and recording myself smacking a few serves.  The idea of recording myself was inspired from several articles that I had read from tennisplayer.net. To elaborate, I wanted to objectively analyze my tennis strokes — see them through a different lens.  And after I recorded the clips, I uploaded them up to my computer and watched myself and was completely surprised to find a major disconnect between how I was perceiving to hit the ball and how I actually hit the ball.

    For example, below are two slow motion clips of my serve. The first clip captures me hitting my serve as I have always hit my serve. And what shocked me the most was that I couldn’t believe how little I was elevating off of the court when jumping up and swinging upwards. I always thought I deeply bent my knees and launched upwards. But that’s not the case.  On top of that, my left foot barely moved past the service line, opposed to (pros) landing up to 1 foot within the baseline.

    After watching myself, I decided to alter my serve, focusing on one change: a deep knee bed. That’s it. No other adjustments. Not swinging arm. No tweaks to the ball toss — just singularly focused on bending my knees and shifting my weight evenly to both planted fleet. The results were baffling. Not only did I rise higher off the ground, but I landed two to three times further into the baseline than my previous serve.

  • 3Blue1Brown – Linear Algebra videos

    Right out the gate, I want to express my gratitude for the 3Blue1Brown YouTube channel for publishing a wonderful video series titled Essentials of Linear Algebra. After watching, and rewatching, the first four beautifully animated videos, I can say that I’ve developed a much better understanding, much more intuitive, of what I’m been learning in my linear algebra course.

    Before watching the videos, I’ve been reading the first few sections from the assigned textbook (and PDF lectures supplied by the instructor), which covers adding and subtracting and multiplying matrices as well as finding the inverses of matrices. Now, for these topics, I’ve been presented with sample exercises and, for the most part, been solving them with little to no questions.  However, I had no idea why I was doing what I was doing — I was simply going through the mechanics of solving problems.  For instance, multiplying matrices: what does that actually do? To elaborate, what’s the purpose of multiplying two matrices together, let alone adding them.  I had shared this frustration with my uncle, a physicists and who works at Boeing, and he recommended that I check out 3Blue1Brown YouTube videos.  So I did.

    And the videos, which are crisp and concise and aesthetically beautiful, cleared up much of my confusion around the concepts. And sure, the videos don’t jump into example exercises but that’s not the point of the videos. Instead, I think the expectation of the viewer is to go and practice problems on their own, and then supplement those exercises by watching the videos. At least that’s how I’m leveraging these videos.

  • Flexing C muscles

    I’ve been sharpening my C programming skills because I’m now working on a team (i.e. EC2 Networking) within Amazon Web Services that requires skills in lower level software development. And I must say, I’m truly rusty. A noob. On top of that, my only experience with C in the past has been fairly superficial, me dabbling here and there in the K & R book, long before I had taken any computer science courses.  But since taking computer organization and data structures, I have a tight understanding of pointers and their practical uses.

    But I digress.

    I’m currently working through a book written by Zed Shaw, the book titled “Learn C the hard way.” I had picked up the book at the local library in Seattle, stumbling upon it while I was running my fingers along the spines of books in the computer science section. This book has mixed reviews. Some websites strongly dissuade readers from reading anything published by this particular author.  But others recommend it. So, I’m taking their advice with a grain of salt and forming my own opinion.

    At the end of every chapter, the author recommends some extra credit exercises.  In one of these exercises, the author suggests implementing a stack data structure in C.  Now, there are two popular implementations when building a stack: using an array and using a linked list. So, I took this exercise as an opportunity to write a simple stack data structure using linked lists (you gotta love them C pointers).

    Here’s the program output:

    ./stack_linked_list
    
    Stack is empty. Pushing 10 to the top of stack
    Stack is not empty. Pushing 20 to the top of the stack
    Stack is not empty. Pushing 30 to the top of the stack
    Popped item: 30
    Peeking at next item: 20
    Peeking at next item: 20
    Peeking at next item: 20
    Popped item: 20
    Popped item: 10
    Popped item: -1

    And the corresponding code:

    #include <stdio.h>
    #include <stdlib.h>
    #include <stdbool.h>
    
    struct Node {
        int value;
        struct Node * next;
    };
    
    struct Stack {
        int count;
        struct Node * top;
    };
    
    
    bool isEmpty(struct Stack * stack)
    {
        return stack->top == NULL;
    }
    
    void push(struct Stack * stack, int item)
    {
        /*
         * Edge case: first item to push
         */
    
        struct Node * node = (struct Node *) malloc(sizeof(struct Node));
        node->value = item;
    
        if (stack->top == NULL){
            printf("Stack is empty. Pushing %i to the top of stack\n", item);
            stack->top = node;
        } else {
            printf("Stack is not empty. Pushing %i to the top of the stack\n", item);
            node->next = stack->top;
            stack->top = node;
        }
    
        stack->count++;
        return;
    
    }
    int pop(struct Stack * stack)
    {
        if (isEmpty(stack)){
            return -1;
        }
    
        struct Node * node = stack->top;
        stack->top = node->next;
    
        return node->value;
    }
    
    int peek(struct Stack * stack)
    {
        if (isEmpty(stack)){
            return -1;
        }
    
        return stack->top->value;
    }
    
    
    int main(int argc, char * argv[])
    {
        struct Stack stack;
        push(&stack, 10);
        push(&stack, 20);
        push(&stack, 30);
        printf("Popped item: %i\n", pop(&stack));
        printf("Peeking at next item: %i\n", peek(&stack));
        printf("Peeking at next item: %i\n", peek(&stack));
        printf("Peeking at next item: %i\n", peek(&stack));
        printf("Popped item: %i\n", pop(&stack));
        printf("Popped item: %i\n", pop(&stack));
        printf("Popped item: %i\n", pop(&stack));
        return 0;
    }

     

  • Linear algebra check in

    I signed up for linear algebra online course through the University of North Iowa, where I’ll be taking my second university level math course, the first being discrete mathematics. I enrolled in this course because it’s a fundamental course that’s typically required of all aspiring computer science students. Moreover, linear algebra is essential (from what I hear) for taking upper division computer science courses such as machine learning.

    Up until now, I’ve expressed interested in machine learning. However, polled my colleagues, asking them what they consider their favorite computer science course and an overwhelming majority voted for machine learning. So with that in mind, coupled with the fact that Amazon offers a machine learning university for full time employees, I figure I should establish a foundation in the mathematics required for machine learning so that in the future, say my second or third year into my masters (at Georgia Tech OMSCS), I can enroll in the course knowing that I’ve met the underlying requirements.

    What’s funny is that a few years ago, about five or six, I had asked my uncle (who’s a rocket scientist at Boeing) what mathematics course I should take in preparation for a masters in computer science. This is long before I officially applied for a masters, when I was just toying with the idea of returning back for academia to pursue a masters in computer science. Anyways, he had recommended that I take linear algebra but to be honest, at that time, I was intimidated since I have mixed feelings when it comes to my mathematical maturity.

    Because when I was a young boy, and up until high school, I (in a sense) flourished in mathematics. I considered it one of my easiest subjects, from elementary all the way up until my senior year in high school. I would sit down at the table, quickly scribble in my answers, with relatively no effort.  But looking back, I never truly took the time to understood mathematics: not algebra, not geometry, not trigonometry, not calculus. None of it.  Did I score high on the homework and exams? Yes. But back then, I had zero desire to understand how or why I was solving the problems or learning the subject. And because math “came easy” to me, I blasted through all the homework, many times solving the problem based off of intuition only. This type of mentality handicapped me later on in my senior year of high school, in AP Calculus. This course kicked me in the butt. Like other high level courses, calculus built on top of other branches of mathematics, courses that I had taken the previous years. And because I didn’t put in the effort in those other courses, I found myself completely lost and confused and frustrated during calculus. I mean, I could mechanically solve for the derivative or integral, but I had zero clue as to why I was doing it and I had zero clue of how to apply these concepts.

    Anyways, I’m now taking linear algebra and like other areas of my life, rebuilding my relationship — with mathematics. So far, I’m about three weeks into the course, the three weeks focusing on the following topics: adding matrices, multiplying matrices, converting matrices to echelon form, converting matrices into row echelon form, and transposing matrices from one dimension to another.

  • Admitted into Georgia Tech Master’s in Computer Science

    On Tuesday, I received an e-mail notification from Georgia Tech, informing me that after 5:00 PM EST, I would be able to check the status of my OMSCS (Online Masters of Science in Computer Science) application, whether I was accepted or rejected. So during dinner, with Jess sitting next to me in the cozy booth of the ramen restaurant, I pulled up the PDF attachment that I received from Georgia Tech on my iPhone, the words “Congratulations Matt” inked across my screen. Accepted!!!

    I’m ecstatic. Because for the past 5 years, the idea of tackling a master’s in computer science has been lurking in the back of my mind. Like Jess had said, “It’s a scratch you need to itch.”  And it’s fair to say that I was never 100% committed to the idea. I think some of the hesitation stemmed from my own fear and insecurities, since I didn’t study CS during my undergraduate degree.  But after taking undergraduate computer science courses (e.g. computer organization, data structures, discrete mathematics, linear algebra), I’m convinced that learning more about my craft is something I want to dedicate myself to.

    Anyways, I’ve already started reading through the different course descriptions and decided to to take Introduction to Operating systems as my first course, assuming that I can enroll in January (i.e. Spring 2019) without being waitlisted. Oh well, only time will tell.

     

  • Friday night arguments

    My wife’s parents told us that when they first moved in together, they noticed that when they argued with one another, the arguments normally took place on Friday evenings.  And when they became aware of this pattern, the two of them agreed to shelve any important discussions for the next day. And surprisingly, this worked for them. What’s even more interesting is that my wife and I encountered a similar situation: we too would argue on Friday evenings, which made no sense to me.  But I think I may know why.

    I’m reading a book that I picked up at my library yesterday, a book titled When (by Daniel H Pink).  Although I’ve only read through the a dozen or so pages, the author explains how researchers identified that people (all over the world, different races and different genders and different religions) felt the happiest during the morning, the happiness peaking at noon and then plummeting to it’s lowest point in the evening: around 5pm. And although I’ve only read through the first few pages, this new piece of information alone leads me to believe that this steep decline in positive energy correlates to arguments that pop up what should be the happiest time of day: Friday evenings.

    Anyways, I’m going to continue reading the book (it is quite gripping) and report back. And if I’m right about the Friday evening situation, then I’ll create a habit to defer any important discussions to Saturday morning. Let’s see.

  • Libraries are love

    Earlier this evening, I neatly stacked my unbounded 200 page textbook onto the document feeder of a waist high scanner, converting a college Linear Algebra book from physical form into a 40 megabyte colored PDF — all within 3 minutes. And best of all: it was free! That’s right, I didn’t pay a single penny, thanks to my local library, which is somehow stocked with a blazing fast multi functioning scanner, a Sharp MX-4070 that sells for $15,000.  Tapping into the free resources that my library offers reminded me just how amazing libraries are. And after I scanned my book, I strolled up and down a couple aisles, running my fingers horizontally across book spines, settling on three books that caught my attention: “When” by Daniel H. Pink, String Theory by David Foster Wallace, and “Where the Past Begins” by Amy Tan. These three books are now sitting on the corner of my desk, within arm’s reach, books that I’ll cycle through over the next couple weeks.

    Anyways, today’s experience served as a reminder of how magical libraries are and how, instead of buying new books that often lay on my shelf collecting dust, I should stroll down to my local library and lap into an incredible, free resource.