I am translating MATLAB code to Haskell using the hmatrix library. Everything is going well, but I stumble upon the pos function because I don’t know what it does or what is the Haskell equivalent.
The MATLAB code is as follows:
[U,S,V] = svd(Y,0);
diagS = diag(S);
...
A = U * diag(pos(diagS-tau)) * V';
E = sign(Y) .* pos( abs(Y) - lambda*tau );
M = D - A - E;
My translation of Haskell:
(u,s,v) = svd y
diagS = diag s
a = u `multiply` (diagS - tau) `multiply` v
Actually, this type of check is fine, but of course I miss the "pos" call and it gives an error:
inconsistent dimensions in matrix product (3,3) x (4,4)
So, I assume pos is doing something with matrix size? Googling "matlab pos function" didn’t bring anything useful, so any pointers are really appreciated! (Obviously, I know little MATLAB)
By the way, this is for the TILT algorithm for restoring low-rank textures from a noisy, distorted image. I am very excited about this, even if the math goes beyond me!
, pos MATLAB:
function P = pos(A)
P = A .* double( A > 0 );
, . , , "True" == 1.0 "False" == 0.0
?