Perhaps we have both been missing the point.
I hastily said
“you won’t be able to ‘matrix multiply gerund matrices’”

In J, you can actually achieve that.
And if that’s what OP wanted, we indeed missed the point.

A solution would then keep R as-is in order to let the user
make good use of Js functional algebra/grammar (but beware of
any verbs that don’t have rank 0).

When it comes to evaluating a matrix of this kind,
I don’t see a necessity to alter OP’s solution
other than making it an adverb (maybe a matter of taste).
Then R mf pi%4 would work without parenthesis.

Looking forward to replies from other members of this list.

And thanks to Ben: I didn’t know one can use both r and p in
a single numeric literal. I’ll have to study microsyntax again.

cheers,
Hauke


Am 18.12.20 um 12:56 schrieb Ben Gorte:
> Perhaps I'm missing the point, but I would say:
> 
> R =: ((cos , -@sin) ,: sin , cos)
> 
> R 1r6p1
> 
> 0.866025 _0.5
> 
> 0.5 0.866025
> 
> 
> Ben
> 
> On Fri, 18 Dec 2020 at 18:59, Francesco Pedulla' <mel...@gmail.com> wrote:
> 
>> 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
>>
> ----------------------------------------------------------------------
> 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

Reply via email to