• Guitarist (unregistered)

    This looks more like song chords than actual code. The "A#" keeps jumping out at me...

  • Aargle Zymurgy (unregistered) in reply to TGV
    TGV:
    F:
    Demos:
    Notice that, for small n, n! < n^3
    More specifically: for n<6, n!<n^3. </div>
    Even more specifically: none of you two have any idea about complexity, do you? For any N, (∀n<N)(O(f(n))=O(g(n)).</div>
    Even more pedantically: if n=2; neither if n>2; none
  • (cs) in reply to Guitarist
    Guitarist:
    This looks more like song chords than actual code. The "A#" keeps jumping out at me...

    It took a 256x256 matrix and a little bit of fiddling with sound functions to get "Bohemian Rhapsody" out of this code.

  • (cs) in reply to operagost
    operagost:
    MindChild:
    This is QBasic code that has been ported to Visual Basic. Visual Basic had an amazing/cursed ability at backward compatibility with QBasic. You could use line numbers. Any graphical output would draw to the main form instead of the DOS terminal. & = long, # means double.
    Although, the LETs tell us that this was either ported from an even older BASIC dialect in turn, or just coded by a major greybeard.
    The LETs and the 2 character variable names suggest a version of BASIC Four to me. http://en.wikipedia.org/wiki/MAI_Basic_Four for you historians.
  • Lone Marauder (unregistered)

    I was told there would be no math.

  • yetihehe (unregistered) in reply to iToad
    iToad:
    d = det(X)

    MATLAB FTW...

    Sometimes, the proper use of an appropriate tool eliminates a lot of pain from your life.

    This explains why you need 1gb of libraries for a 100kb program. Now if you need another program you need even more libraries and frameworks of which you typically use about 2%.

  • Symbolic Logic (unregistered) in reply to Rick
    Rick:
    The LETs and the 2 character variable names suggest a version of BASIC Four to me. http://en.wikipedia.org/wiki/MAI_Basic_Four for you historians.
    FTFA: Basic/Four Corporation was created as a subsidiary of Management Assistance, Inc.

    So I guess this dates back to the time when every computer product, hardware or software, was required to have a slash in its name. Before CamelCase there were Slash/Words.

    Even the first OS I learned required every command line to begin with a slash. You know, as in, Hey Computer! Wake up! Incoming!!

  • Garrison Fiord (unregistered) in reply to qazwsx
    qazwsx:
    Matrices are essential for any kind of 3D graphics programming.
    Well, they used to be...and still are if you don't want to use any type of game engine. Nowadays, it's obscured by an API that allows you to use a generic transformation matrix. That's probably the way it should be, since all you're doing is applying the same formula everywhere. Nevertheless, a basic understanding of how matrix operations work is a good idea.
  • Garrison Fiord (unregistered) in reply to qazwsx
    qazwsx:
    Swedish tard:
    Remy Porter:
    Because there are? Matrix operations are very common.

    But just because you're working with matrices doesn't mean you need to know the determinant of the matrix. A lot of matrix operations have been structured such that you don't need to know the determinant to calculate them.

    I've worked with programming 5 years now, and I have not encountered a matrix so far. Even less so anything involving any nontrivial mathematic. And I work in *nix and linux systems, developing heavy lifting server software. Should the need arise to work with matrices and math, it's probably a good idea to refresh my university studies in the matter though. :D Since as I had to write a library for doing matrix math in my second programming course.

    Matrices are essential for any kind of 3D graphics programming.

    Well, they used to be...and still are if you don't want to use any type of game engine. Nowadays, it's obscured by an API that allows you to use a generic transformation matrix. That's probably the way it should be, since all you're doing is applying the same formula everywhere. Nevertheless, a basic understanding of how matrix operations work is a good idea.

  • Matt (unregistered)

    I learned in my numerical analysis class, if you think you want the determinant of a matrix, you're probably mistaken.

  • Shark8 (unregistered) in reply to n_slash_a
    n_slash_a:
    Somebody Else here. I help program avionics GPSs and about 1/4 of our code is trig functions, matrices, vectors, ect... And yes, I wish I paid more attention in my linear algebra class. Also, just because there is a library to transfer coordinate systems, you still need to know which function to call, and more importantly, if it returned the correct answer.
    Hm, are you using Ada? (I've heard Ada is prevalent in Avionics.) If so, What do you think of Ada.Numerics family of packages?
  • Reggie (unregistered) in reply to Matt
    Matt:
    I learned in my numerical analysis class, if you think you want the determinant of a matrix, you're probably mistaken.
    You have a problem. You decide to calculate the determinant of a matrix. Now you have two problems.
  • (cs) in reply to Reggie
    Reggie:
    Matt:
    I learned in my numerical analysis class, if you think you want the determinant of a matrix, you're probably mistaken.
    You have a problem. You decide to calculate the determinant of a matrix. Now you have two problems.
    Same applies to the inverse. Never solve equation systems by explicitly calculating the inverse.
  • Albert (unregistered) in reply to topspin
    topspin:
    Reggie:
    Matt:
    I learned in my numerical analysis class, if you think you want the determinant of a matrix, you're probably mistaken.
    You have a problem. You decide to calculate the determinant of a matrix. Now you have two problems.
    Same applies to the inverse. Never solve equation systems by explicitly calculating the inverse.
    Explicitly calculating the universe should also be avoided, due to performance issues.
  • Fred (unregistered) in reply to Albert
    Albert:
    Explicitly calculating the universe should also be avoided, due to performance issues.
    There are some who argue that this has most likely already occurred.

    https://en.wikipedia.org/wiki/Simulation_argument

    It would certainly explain why everything seems to be digitized (quantum) if we zoom in far enough, and why quantum stuff doesn't like being analyzed too closely (uncertainty principle) and how the multiple universe hypothesis could be implemented by nothing more than a fork() call.

    Personally I think the programmers of our "reality" are frantically trying to stay ahead of our experiments such as the LHC. Also they keep coming up with more and more bizarre stuff to throw at us and we keep buying it.

    If I'm correct, they'll probably arrange to delete this post. Or me.

  • Shinobu (unregistered) in reply to MindChild
    MindChild:
    This is QBasic code that has been ported to Visual Basic. Visual Basic had an amazing/cursed ability at backward compatibility with QBasic. You could use line numbers. Any graphical output would draw to the main form instead of the DOS terminal. & = long, # means double.
    The semantics were completely different though:
    Sub Main() 'VB
    A& = 42
    A$ = "Hello world!"
    End Sub
    Won't compile: the $ doesn't match the fact that A is a Long. Type declaration characters are completely optional in VB and it doesn't make a difference if you leave them off, except when (possibly implicitly, like in line 2 above) you declare the variable. But when it's there, it must be correct.
    A& = 42 'QB
    A$ = "Hello world!"
    PRINT A&
    PRINT A$
    PRINT A
    This will result in:
    42
    Hello world!
    0
    When you explicitly declare the variable you'll get the same result as in VB however. -------------------------------- Line numbers were already a compatibility feature in QB:
    20 PRINT 20 'GW-BASIC
    10 PRINT 10
    This will print:
    10
    20
    Whereas in QB the same code will print:
    20
    10
    In VB, line numbers can appear only in procedures and behave like labels in every respect.
    Sub Main()
    20 MsgBox 20
    10 MsgBox 10
    End Sub
    

    Sub OtherSub() 10 MsgBox 10 20 MsgBox 20 End Sub

    The first box will say 20, the second 10. It's no problem that OtherSub contains the same line numbers, same as with labels.

    Graphical statements have become methods, which means that in true object oriented fashion* this:

    Print 42
    Calls the Print method on Me. If there is no Me (in a standard module) it won't compile. If there is but it doesn't support graphics methods, you'll get a run-time error.

    • Somewhat tongue in-cheek. The graphics methods are ‘special’, probably because of their syntax. Most of the time they work like you'd expect, but not for example in With blocks. If you wanted to support printing you had little other choice than to declare the target As Object because there was no type ‘Drawable’ that you could cast Form, PictureBox and Printer to.
  • Dan (unregistered) in reply to MindChild

    No a 2d array of Strings is not a matrix, it would have to be a 2d array of numbers. Even then I would say that not all 2d arrays of numbers are matrices, it would have to serve a purpose that relates to the mathematical meaning of "matrix".

  • José (unregistered) in reply to Demos

    By small n you must mean 0 < n < 5

  • fwip (unregistered) in reply to Dan
    Dan:
    No a 2d array of Strings is not a matrix, it would have to be a 2d array of numbers. Even then I would say that not all 2d arrays of numbers are matrices, it would have to serve a purpose that relates to the mathematical meaning of "matrix".
    Exactly - it'd have to be "a rectangular array of numbers, symbols, or expressions, arranged in rows and columns." A very high bar to reach, indeed.
  • DB (unregistered) in reply to C-Derb
    C-Derb:
    This code is so hard to follow, I have no idea where the "That's it!" comment is supposed to go.

    Hahahahaha

  • gnasher729 (unregistered) in reply to qazwsx
    qazwsx:
    Matrices are essential for any kind of 3D graphics programming.
    Nobody but a complete numbnuts has ever used the determinant of a matrix greater than 2x2. For 3x3, it is too complicated and inefficient. For 4x4 calculating the determinant is just perversion.
  • Reynold (unregistered) in reply to Fred
    Fred:
    Albert:
    Explicitly calculating the universe should also be avoided, due to performance issues.
    There are some who argue that this has most likely already occurred.

    https://en.wikipedia.org/wiki/Simulation_argument

    It would certainly explain why everything seems to be digitized (quantum) if we zoom in far enough, and why quantum stuff doesn't like being analyzed too closely (uncertainty principle) and how the multiple universe hypothesis could be implemented by nothing more than a fork() call.

    Personally I think the programmers of our "reality" are frantically trying to stay ahead of our experiments such as the LHC. Also they keep coming up with more and more bizarre stuff to throw at us and we keep buying it.

    If I'm correct, they'll probably arrange to delete this post. Or me.

    So you're trying to keep this on today's "Matrix" topic but failing to realize that we aren't talking about a movie.

  • caecus (unregistered) in reply to Mike
    Mike:
    This is 60s/70s style programming, sadly still much in use in the 80s due to the crappy bits of kit called micros. Anything written like this in the 90s was just from a crappy coder.

    This is one of those programmers with 30 years of experience that aren't curious to go right-click+view-source in their browser.

  • Sylwester (unregistered)

    I really don't like VB, but this I could handle. It's clearly a work of art. (and art doesn't need to be correct for all circumstances (and none)) Adding comments would ruin it's beauty!

  • caecus (unregistered) in reply to Mason Wheeler
    Mason Wheeler:
    Some Damn Yank:
    iToad:
    d = det(X)

    MATLAB FTW...

    Sometimes, the proper use of an appropriate tool eliminates a lot of pain from your life.

    Sometimes, the boss says "I pay you to write code, not buy it. Request denied." In fact, in 32 years in this business I have never used a third-party tool. If it doesn't come with the compiler we can't have it. In one job I worked for an entire department that supported an in-house graphics library we could have purchased, but by then it was deemed cheaper to maintain ours than re-write code to use something else.

    Wow. If my boss was ever stupid enough to pull out a line like that, I'd respond something like this:

    "Yes, you pay me to write code. Approximately ABC dollars per day, in fact. Now if you want me to develop this, I estimate it will take three days to get the basic functionality, and then most likely the better part of a week over the course of the next two years dealing with edge cases. That's over X thousand dollars. Or you could find room for $XYZ somewhere in the budget, which is less than two days' salary for me, and we could have a mature library tomorrow that's already been through that process. It's up to you."

    Of course, if he was that dumb, I wouldn't continue working for him. I currently have a boss who gets it, and I like that.

    Nah, dude - this is how most corporate budget-oriented dumbasses look at a situation like this:

    I pay you x amount of dollars per year to work for me as a developer. (For the sake of simplicity, let's say you're the only IT-related cost to the company.) You're asking for y dollars to buy something that you could otherwise create? Are you nuts? You do it. What am I paying you for? I'll be paying you to be here anyway.

  • caecus (unregistered) in reply to n_slash_a
    n_slash_a:
    Carl:
    There are a large number of programming problems that involve the use of matrices and linear algebra.
    Yeah, 32 years programming here, and still never found a reason why they put me through the most basic algebra class much less all that college stuff.

    OK so if you're going to be writing robot vision software or a digital multiplexing radio for the next smartphone maybe you'll need that. And maybe you'll need to code your own filesystem too since embedded devices don't have them. But for data processing, web development, operations, sys admin... you know -- where most all the jobs are... learning higher math is an absolute waste of time.

    Yes I even spent several years writing a 3D data visualization package, and I still never needed anything more than an understanding of when to call what trig function to transform a planar coordinate system to spherical. All the heavy math: handled by the graphics card. So still, unless you're making your own graphics card, it is Somebody Else's Problem.

    Somebody Else here. I help program avionics GPSs and about 1/4 of our code is trig functions, matrices, vectors, ect... And yes, I wish I paid more attention in my linear algebra class. Also, just because there is a library to transfer coordinate systems, you still need to know which function to call, and more importantly, if it returned the correct answer.

    And I wish they don't hire math dropouts to develop avionics software.

  • Norman Diamond (unregistered)

    If anyone here ever rode in a vehicle powered by something other than muscles or whose wheels have designs more complicated than simple spokes, you depended on matrix calculations even though you didn't do the calculations yourself.

    If your computer sometimes plugs into AC power, you depend on the power company's matrix calculations even though you didn't do the calculations yourself.

    If you have a hard drive that lets you read back what you wrote...

    etc.

    Yes matrix calculations are common, even though most of us never have to do them.

  • (cs)

    It's amazing how much you forget when you don't use it. I had determinants in school, but I'll be damned if wikipedia's page doesn't look like an alien language. This page has a great step by step on solving for n sized matrices. Easy to read and understand. http://people.richland.edu/james/lecture/m116/matrices/determinant.html

  • Andrew Au (unregistered)

    I am really curious what kind of application need to compute determinant of arbitrary size ... well, except Matlab style of app whose purpose is to enable other to do scientific computation.

  • (cs) in reply to TGV
    TGV:
    Remy Porter:
    Yes, but I linked that one because it's a fairly easy to understand formula- I think most of us don't work with determinants that often (I certainly don't).
    Then why did you start with "There are a large number of programming problems that involve the use of matrices and linear algebra."?
    Some people, when confronted with a problem involving matrices, think "I know, I'll use a determinant". Now they have two problems.
  • Tynam (unregistered) in reply to gnasher729

    Sorry, not true. I've worked with some statistical applications where you simply need to know the determinant; it's OK to use efficient matrix factoring methods first (since we need to do other things with the matrix anyway), but when we're finished being efficient we still need to know the actual determinant.

    (Admittedly, one of these applications had a bug that I seriously considered submitting, except that there's no way to anonymise it and many reasons why the code is commercially secret.)

  • Ru (unregistered) in reply to Mason Wheeler
    Mason Wheeler:
    "Yes, you pay me to write code. Approximately ABC dollars per day, in fact. Now if you want me to develop this, I estimate it will take three days to get the basic functionality, and then most likely the better part of a week over the course of the next two years dealing with edge cases. That's over X thousand dollars. Or you could find room for $XYZ somewhere in the budget, which is less than two days' salary for me, and we could have a mature library tomorrow that's already been through that process. It's up to you.".

    The problem with this approach is that you run into the "You seem to be telling me that you're a worthless programmer" issue that generally has "...security will escort you off the premises now" solution.

    This is probably a good thing for you in the long term, but may be bad for your mortgage repayments or food purchasing in the short term.

  • TRWTFVB (unregistered)

    TRWTF literally is Visual Basic

  • foo2 (unregistered) in reply to TRWTFVB
    TRWTFVB:
    TRWTF literally is Visual Basic

    How original you are! Oh yes you are, you original little person you!

    If you get here earlier you could try for a fr!st p0$t too!

  • Andrew Au (unregistered) in reply to Dan

    Mathematically - [url="http://en.wikipedia.org/wiki/Matrix(mathematics)"]matrix[url] element can be anything comes from a [url="http://en.wikipedia.org/wiki/Field(mathematics)"]field[url] or even a [url="http://en.wikipedia.org/wiki/Ring_(mathematics)"]ring[url].

  • Andrew Au (unregistered) in reply to Tynam

    Computing log-likelihood for general multivariate Gaussian, yes, that would be a reason for computing determinant of matrix of arbitrary size.

  • Ol' Bob (unregistered) in reply to Andrew
    Andrew:
    NaN (Not a Name):
    I found that mathematical functions don't have to always return the correct answer as long as you can calculate the probability that they will or will not.
    If it's floating point, it doesn't have to be right, because we all know that floats are inaccurate by nature. Because of that, 2.0f + 2.0f = 5.0f

    That's only true for sufficiently large values of 2.0f.

    (Redneck CAPTCHA: jugis - Dang! My jugis empty!)

  • Ol' Bob (unregistered) in reply to Lone Marauder
    Lone Marauder:
    I was told there would be no math.

    We lied.

    (CAPTCHA - ingenium : Gentlemen, start your ingenium!)

  • Ol' Bob (unregistered) in reply to caecus
    caecus:
    Mason Wheeler:
    Some Damn Yank:
    iToad:
    d = det(X)

    MATLAB FTW...

    Sometimes, the proper use of an appropriate tool eliminates a lot of pain from your life.

    Sometimes, the boss says "I pay you to write code, not buy it. Request denied." In fact, in 32 years in this business I have never used a third-party tool. If it doesn't come with the compiler we can't have it. In one job I worked for an entire department that supported an in-house graphics library we could have purchased, but by then it was deemed cheaper to maintain ours than re-write code to use something else.

    Wow. If my boss was ever stupid enough to pull out a line like that, I'd respond something like this:

    "Yes, you pay me to write code. Approximately ABC dollars per day, in fact. Now if you want me to develop this, I estimate it will take three days to get the basic functionality, and then most likely the better part of a week over the course of the next two years dealing with edge cases. That's over X thousand dollars. Or you could find room for $XYZ somewhere in the budget, which is less than two days' salary for me, and we could have a mature library tomorrow that's already been through that process. It's up to you."

    Of course, if he was that dumb, I wouldn't continue working for him. I currently have a boss who gets it, and I like that.

    Nah, dude - this is how most corporate budget-oriented dumbasses look at a situation like this:

    I pay you x amount of dollars per year to work for me as a developer. (For the sake of simplicity, let's say you're the only IT-related cost to the company.) You're asking for y dollars to buy something that you could otherwise create? Are you nuts? You do it. What am I paying you for? I'll be paying you to be here anyway.

    Opportunity cost. As in "...if I'm solving ancillary problems I don't have the opportunity to solve real business problems, which thus wastes time and money".

    HOWEVER - the key here is not mentioning "opportunity" or "cost". The key point is to mention that solving the non-business-related problem will be "fun", at least here in the good old U.S. of A. If the boss (any boss) hears you're having fun the automatic reaction will be "Oh, no you don't! This is a business, my friend!". (No, actually you're not, but I digress). "You're here to solve critical business issues!" (Translation: you're here to be my puppet. Dance, puppet, dance!) "Just to SPITE you I will purchase the software you'd rather write yourself! HAH! I AM SO MUCH SMARTER THAN YOU!! BU-WA-HA-HA!!!!!".

    Sometimes it's just a matter of learning which button to pull. :-)

    (CAPTCHA - iusto : I'll be ready in iusto minute.)

  • (cs) in reply to MindChild
    MindChild:
    This is QBasic code that has been ported to Visual Basic. Visual Basic had an amazing/cursed ability at backward compatibility with QBasic. You could use line numbers. Any graphical output would draw to the main form instead of the DOS terminal. & = long, # means double.

    Line numbers are actually very useful things to have in a Visual Basic program - or at least VB6; you can use the Erl variable and an error handler to tell you precisely where an error occurred in a function or sub routine - but it only works (usefully) if you've numbered your lines.

    I only found this out because I am forced to maintain VB6 code at work and anything that makes bug fixing easier is welcome; the fact that I found a plugin for VB6 which automagically numbered all the source files was a boon too.

  • Chris (unregistered)

    There's a reason why I dropped out of college to code web business apps: math makes my eyes bleed.

  • Jonas (unregistered) in reply to TGV
    TGV:
    Even more specifically: none of you two have any idea about complexity, do you? For any N, (∀n<N)(O(f(n))=O(g(n)).</div>

    Let's recall the definition of O(): a function f is big-oh of g (sometimes written as (O(f(n))=O(g(n))) if {exists c, M: forall m > M: f(m) <= c*g(m)}.

    Let's go over your statement: {forall N, n < N: exists c, M: forall m > M: f(m) <= c*g(m)}. In other words, all functions are big-oh of all other functions. Which is wrong.

    What you probably meant to say is that the values of f and g on any finite set of numbers doesn't influence whether f is big-oh of g. More precisely, if f* and g* differs from f and g at only finitely many values n, then f = O(g(n)) iff f* = O(g(n)) iff f = O(g*(n)) iff f* = O(g*(n)).

    Proof: I'll do both directions of the first 'iff'; hopefully you can extrapolate the technique from there.

    let's first say that f=O(g(n)), iow, exists c, M: forall m > M: f(m) <= cg(m). Let M2 be the largest number at which f and f differ (f(M2) != f*(M2) and forall M3 > M2: f(M3) = f*(M3)), or anything (e.g. M) if f = f*. Then, forall m > max(M, M2): f*(m) = f(m) <= c*g(m).

    Next let's say that f!=O(g(n)), iow, forall c, M: exists m > M: f(m) > cg(m). Let M2 be as before; then forall c, M: exists m > max(M, M2): f(m) = f(m) > c*g(m).

    Also, the constants do matter. That's why we don't flip a coin when choosing between quicksort and heapsort, or between splay trees, AVL trees and red-black trees. In practice, resource use for only moderately large values of n is also highly relevant. Avoid fibonacci heaps like the plague. While they theoretically speed up Dijkstra's shortest path algorithm, they're dog slow in practice.

    When correcting people, please be correct :P

Leave a comment on “Determined”

Log In or post as a guest

Replying to comment #:

« Return to Article