Alec's Web Log
by ajx
9M ago
During the SIGGRAPH review process a submitted paper is supposed to receive 5 reviews. Sometimes a paper accidentally receives ≥5 initial reviews. Usually because of sending out too many parallel invitations to non-committee reviewers. My sense is that this has increased since SIGGRAPH started the two-factor conflict-of-interest identification system. I’d always been suspicious that getting too many reviewers actually hurts a paper’s chance of acceptance. One argument for this is that the review process is more akin to aggregating identified flaws of a paper than whipping up excitement about t ..read more
Alec's Web Log
by ajx
9M ago
I went to a trivia night where one of the other teams only had a single person. That person got 2nd place to a team with 6 people. It was quite impressive and got me thinking if there was a way to quantify how impressive it was. This seemed related to trying to figure out a scoring system that would account for team sizes. Assume that the chance anybody knows any factoid is p. Also assume (somewhat unrealistically) that team members don’t disagree witth each other. That is, if anybody on the team knows the factoid then the team will choose that correct answer. For a team with n members, the pr ..read more
Alec's Web Log
by ajx
1y ago
When translating math to matlab, I admit I usually translate xᵀ into x'. For example, suppose x∈ℝ⁴ and I have a quadratic energy: xᵀ A x I would implement this in matlab with x' * A * x The ' isn’t actually calling transpose. It’s actually calling ctranspose, the complex conjugate transpose. For real input, this is the same as transpose so most of the time this works just fine for me. However, today I was experimenting with the complex step method for numerically computing gradients. I immediately got incorrect results. Here’s a simple example: i = sqrt(-1); t = 1.5; A = [1 2 3;2 3 4;3 4 ..read more
Alec's Web Log
by ajx
1y ago
One of the worst design aspects of matlibberish is how anonymous functions are handled. Anonymous functions are the only way to define functions in the workspace without files. Script files can have functions at the bottom but after evaluating the script they’re not accessible from the workspace. So I often end up hacking around this by chaining small anonymous functions. Since anonymous functions in matlab can’t have multiple lines (and thus no assignment or auxiliary variables), it can be awkward to do replacements. Here’s a funny one to replace non-zeros in an (dense) array with infs by abu ..read more
Alec's Web Log
by ajx
1y ago
The Gauss-Newton method is classically applied to non-linear least squares minimization problems of the form minimize ‖ f(x) ‖² x ^---.---^ E(x) where f(x) : ℝⁿ → ℝᵐ. The method defines an update rule of x ← x₀ - (JᵀJ)⁻¹ Jᵀ f(x₀) where J = ∂f/∂x @ x₀ ∈ ℝᵐˣⁿ. We can recognize Jᵀ f(x) = ∂E/∂x, the gradient of the minimization objective and JᵀJ ≈ ∂²E/∂x² @ x₀ its Hessian where we ignore terms involving d²f/dx². For descent this is convenient as JᵀJ is symmetric positive definite by construction. When f(x) is linear (affine) in x, this method degenerates into the usual no ..read more
Alec's Web Log
by ajx
1y ago
Wow. This was a lot harder than I thought it’d be. Rendering folks seem to really like .exr files. Not sure why. imread doesn’t support it. All the matlab readers I found based on openexr eventually either wouldn’t compile or crashed at runtime. Finally I gave up trying to load directly and settled on converting the image to a .mat file using python+opencv+numpy+scipy. Even that was fraught with exr specific troubles. pip3 install opencv-python numpy scipy then here’s a one-liner to convert .exr to a .mat file with a im variable containing the image. OPENCV_IO_ENABLE_OPENEXR=1 python3 -c "i ..read more
Alec's Web Log
by ajx
1y ago
Homography transformations describe the change in projected position of points on a rigidly moving plane observed between 2D images. A homography H ∈ ℝ³ˣ³ transforms a point (x y)∈ℝ² to a new point (x' y')∈ℝ² by linear transformation in homogeneous coordinates: / x'/w \ / h₁₁ h₁₂ h₁₃ \ / xᵢ \ | y'/w | = | h₂₁ h₂₂ h₂₃ | | yᵢ | \ w / \ h₃₁ h₃₂ h₃₃ / \ 1 / We can pose the problem of finding the homography H which matches a set of input points (xᵢ yᵢ)∈ℝ² to corresponding target points (x'ᵢ y'ᵢ)∈ℝ²: ‖ / x'ᵢ \ - / (h₃₁ h₃₂ h₃₃ )/ xᵢ \ \⁻¹ /h₁₁ h₁₂ h₁₃ \/ xᵢ \ ‖² min ∑ᵢ ‖ \ y ..read more
Alec's Web Log
by ajx
1y ago
MATLAB appears to use dense operations when broadcasting certain multiplication/division operations to sparse matrices: A = sprand(100000,90000,6./100000); b = rand(size(A,1),1); spy(A) tic;C1 = A.*b;toc Elapsed time is 7.008773 seconds. tic;C2 = (A'.*b')';toc Elapsed time is 0.072233 seconds. norm(C1-C2,inf) ans = 0 ..read more
Alec's Web Log
by ajx
1y ago
Matlab has a (clunky) interface to python. Passing data can be awkward. There is no built in support (AFAIK) for passing matlab sparse matrices to scipy sparse matrices. For starters, don’t do this: A = sprandn(10000,10000,0.0001); pyA = py.scipy.sparse.csc_matrix(full(A)); casting to full defeats the purpose of sparse storage. Instead you can build a scipy sparse matrix directly. In scipy, you must explicitly specify the storage, for this example I’ll use CSC: [AI,AJ,AV] = find(A); pyA = py.scipy.sparse.csc_matrix({AV,{uint64(AI-1) uint64(AJ-1)}},{uint64(size(A,1)),uint64(size(A,2))}); N ..read more
Alec's Web Log
by ajx
1y ago

OR