- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Got fail
Admin
Something telling me it's BASIC language family but it definetely looks like perl
Admin
Might have something to do with the "#"'s and "&"'s on all the variable names, asdf. And yes, this was found in a Visual Basic program (although it apparently started life as a more obscure dialect).
Admin
Notice that the Leibniz formula for determinants might be of theoretical interest, but it's complexity is n! whereas good methods are n^3 or less under appropriate circumstances.
Admin
I# can&t* e#(ven): goto CO2
CO2: read& th=is c0*de
Which awful language is that? I can't even follow the control flow because of all the weird characters.
Admin
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).
Admin
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.
Admin
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.
Admin
This thing only does 3x3? As in a11*(a22a33-a23a32) - ...? Nice.
Admin
Admin
Are they quantum functions?
Admin
Admin
because scientists find those sorts of problems interesting, programmers find them annoying and invent excuses to not do them.
I think that's how enterprise software gets created.
Admin
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.
Admin
The only real way to do determinants is with APL...now, that's cryptic.
Admin
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.
Admin
Notice that, for small n, n! < n^3
Admin
Matrices are essential for any kind of 3D graphics programming.
Admin
TRWTF is using LET statements in any form of Microsoft BASIC.
The LET keyword was already obsolete in nineteen freaking seventy nine.
Admin
I haven't used them much, but I'm mostly writing pretty straightforward data-driven business applications. I've done a little graphics programming on the side, which sometimes calls for a little matrix work (although you'll usually let an API do the heavy lifting there).
Admin
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.
Admin
Sure you have. Most folks call them 2d arrays.
Admin
This stops working when n>6.
Admin
"APL? It's all Greek to me."
Admin
I didn't see a requirement that the results of the computation had to be correct...this could be another variant of "sleep"
Admin
From http://dfns.dyalog.com/n_det.htm
Note that the boxes are really boxes, not boxed-out font gaps, and the zeros are, as usual in APL, the dotted kind.
Admin
Stare at this for 5 seconds, tilt your head in awe or disgust and realize that the line after label DE2 really starts to look like a middlefinger?
Admin
Dammit, my glasses jumped off my nose when they've seen this crap...
Captcha: conventio. The above WTF uses a very lousy coding conventio
Admin
Admin
Matrices are essential for all sorts of problems, including probability and statistics, including multivariable statistics, Markov chains, Montecarlo simulation, etc.
Computing eigenvectors and eigenvalues from square matrices is a very useful operation, since the basis of eigenvectors tells us which directions are "preserved" by the linear transformation the matrix represents. You need determinants to compute these values.
That said, if anything in CS is a "solved problem", this is it. You are better off knowing how to use a good linear algebra API than how to write one.
Admin
Admin
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.
Admin
Correct, fast to implement, fast to run: pick 2.
Or maybe pick 0 or 1 in this case.
Admin
This code is so hard to follow, I have no idea where the "That's it!" comment is supposed to go.
Admin
But the fact is, for a programmer it is absolutely useless. It's not even on the Bubble Sort scale of inefficient, it's on the "nobody would EVER use this" scale.
Regarding the code: It's about as easy to read as the corresponding disassembler output would be.
Admin
d = det(X)
MATLAB FTW...
Sometimes, the proper use of an appropriate tool eliminates a lot of pain from your life.
Admin
Admin
I tried to draw a flowchart of this algorithm, but my paint program refused to let me.
Admin
The Easy Reader version has it right, by the way...
Admin
Admin
Don't forget about Octave, either It's equally as powerful for prototyping these machine-learning/matrix manipulation problems...
Admin
Admin
Admin
Yes, even: (∀n<N)(O(f(n))=O(g(n))=O(1))
If you don't have a variable (sized) input, then you can calculate everything in constant time. Eg. I can calculate whether every number below 10^100000 is prime in constant time - by simply iterating through all numbers below that and test if it's a divisor, and not terminating until you've tested all of them. It will be a massive constant though.
That doesn't mean you can't use the big-Oh notation to determine which algorithm is likely to be better. O(n!) may be better than O(n^3) for small n (n<6), unless the constant hidden in the order is bigger for O(n!). Of course, you can't know for sure easily. But it could very well make sense to change the algorithm:
if(n < 6) { // Use algorithm O(n!) } else { // Use algorithm O(n^3) }
Which isn't even necessary if all your matrices are small enough. If you're only using 3x3 and 4x4 matrices, for example...
Admin
Type Characters: http://msdn.microsoft.com/en-us/library/s9cz43ek(v=vs.71).aspx
%: Integer &: Long @: Decimal !: Single #: Double $: String S: Short I: Integer L: Long D: Decimal F: Single R: Double C: Char
*: Unreadable
Definitely hurts the readability advantage of Visual Basic. Although I do admit casting strings as characters using this convention fairly often.
Admin
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.
Admin
" It’s optimized in the sense that it doesn’t always return the right answer."
So it was optimized for speed then?
Admin
Same here. Used matrices first day on the job, and continued to use them for the next 14 years of my career, non-stop.
Any time you need manipulate an object in > 1D space matrices come into play. Even 2D objects require 3x3 matrices to do all the fancy spinny/scaley effects (think: user interfaces).
I make videogames, where all the fun and crazy-challenging jobs are. Every videogame programmer worth half his weight in salt knows linear algebra with as much expertise as his programming language of choice.
/loves his job
Admin
(^^ in reply to ^)
Admin