jemnotesversion 2 / featuring math-ish or see all/search

Oct 5
The leading dimension (LDA) in lapack refers to the ‘distance in memory between elements of two consecutive columns which have the same row index’ (source).
Thus, in general, LDA is the same as N, but if you’re working with a submatrix A(91:100, 1:100), you’ll set N = 10 but LDA = 100.
Jul 31
Sampling from a discrete distribution, where p is a vector of probabilities:
min(find(rand() < cumsum(p)))
Jul 29
Have a look at this bizarre Matlab behaviour:
>> 1 / [1 2 3]' 
ans =
         0         0    0.3333
Apparently, this is how they wanted it. Excusing the use of \\backslash as if it were mathematics, we have the equivalence:
A / B = (B^T \backslash A^T)^T,
leading to the bizarre conclusion that in Matlab,
    / = \backslash^T.
Of course, the syntax that I really wanted was 1 ./ [1 2 3]'. This is fully consistent with Matlab’s elementwise operations, but would it be so bad if 1 / [1 2 3]' just did not work, especially rather than silently giving you something totally weird but the same shape?