FAQ: Difference between revisions

51 bytes added ,  16 November 2011
Line 589: Line 589:
However,
However,


             if ([]) != if (all ([]))
             if ([])


because samp ([]) == 1 because, despite the name, it is really returning true if none of the elements of the matrix are zero, and since there are no elements, well, none of them are zero. This is an example of vacuous truth. But, somewhere along the line, someone decided that if ([]) should be false. Mathworks probably thought it just looks wrong to have [] be true in this context even if you can use logical gymnastics to convince yourself that "all" the elements of a matrix that doesn't actually have any elements are nonzero. Octave however duplicates this behavior for if statements containing empty matrices.
is not the same as
 
            if (all ([]))
 
because, despite the name, the <tt>all</tt> is really returning true if none of the elements of the matrix are zero, and since there are no elements, well, none of them are zero. This is an example of [http://en.wikipedia.org/wiki/Vacuous_truth vacuous truth]. But, somewhere along the line, someone decided that <tt>if ([])</tt> should be false. Mathworks probably thought it just looks wrong to have <tt>[]</tt> be true in this context even if you can use logical gymnastics to convince yourself that "all" the elements of an empty matrix are nonzero. Octave however duplicates this behavior for if statements containing empty matrices.


===Solvers for singular, under- and over-determined matrices===
===Solvers for singular, under- and over-determined matrices===