[R] Hadamard transformation
mohan radhakrishnan
r@dh@kr|@hn@n@moh@n @end|ng |rom gm@||@com
Mon Sep 18 19:45:10 CEST 2023
Hello,
I am attempting to port the R code which is an answer to
https://codegolf.stackexchange.com/questions/194229/implement-the-2d-hadamard-transform
function(M){for(i in 1:log2(nrow(M)))T=T%x%matrix(1-2*!3:0,2)/2; print(T);
T%*%M%*%T}
The code, 3 inputs and the corresponding outputs are shown in
https://tio.run/##PYyxCsIwFEX3fkUcAu@VV7WvcSl2dOwi8QNqNSXQJhAqrYjfHoOIwz3D4XBDNOJYiGgerp@td9Diy/gAVlgnynr0A4MLfkkeUTdarnLq5mBXKAvON1W9J8YdZ1rmsk3T72jgV/TAVBHTAROYrs/00@jz5YSY/aOSFKmvGP1yD9sk4Wa7ARSSRowf
These are the inputs.
f(matrix(c(2,3,2,5),2,2,byrow=TRUE))
f(matrix(1,4,4))
f(lower.tri(diag(4),T))
My attempt to port this R code to another framework(Tensorflow) was only
partially successful
because I didn't fully understand the cryptic R code. The second input
shown above works after
hacking Tensorflow for a long time.
My question is this. Can anyone code this in a clear way so that I can
understand ? I understand
Kronecker Product and matrix multiplication and can port that code but I am
missing something as the same ported code does not work for all inputs.
Thanks,
Mohan
[[alternative HTML version deleted]]
More information about the R-help
mailing list