Sorry, I made a mistake: the order of the entries is wrong. And what your code does is compute (R pi)%4 rather than R(pi%4) so I guess my solution (with swapped sin entries) is what you wanted.
Am 18.12.20 um 09:09 schrieb Hauke Rehr: > First of all, I wonder which result you expect. > Is the result of “R mf pi%4” what you want? > > Personally, I woldn’t mind if R’s shape reflects > what we call a matrix as long as its result does > (after all, you won’t be able to “matrix multiply > gerund matrices”) > > So my solution would look like this: > > R2 =: ((cos , -@sin) ,. sin, cos) > R2 pi%4 > > which yields the results I would have expected. > > Am 18.12.20 um 08:58 schrieb Francesco Pedulla': >> Dear all, >> I need to represent the 2D rotation matrix 'R' >> >> R = |cos(t) -sin(t)| >> |sin(t) cos(t)| >> >> and compute it for different values of the rotation angle 't'. I am aware >> the matrix of function can be represented as a gerund, which I like: >> >> R =: 2 2$cos`(-@sin)`sin`cos . >> >> To compute R(t), I wrote the following definition: >> >> mf =: conjunction : '($x)$,(,x)/.((+/$x)$y)' >> >> >> so that "R mf pi%4" returns R(pi/4). But I find the code for 'mf' not very >> elegant. Is there a better way to achieve this? >> Thanks in advance for any hint, >> >> Francesco >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> > -- ---------------------- mail written using NEO neo-layout.org ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm