Github Copilot understanding matrix multiply. 

Getting back to Raul’s question on whether it understands +/ . * as matrix 
multiply. Github copilot seems to be very context sensitive. At least in the 
sense that when it starts down a path it remembers the context of the file. So 
I started with a New file. I put in the comments and the J code under the 
comment is what Copilot returned:

NB. define a 4 x 4 matrix
a =: 4 4 $ i. 16
NB. define a 4 x 4 matrix
b =: 4 4 $ i. 16

NB. let c =: a matrix mulply b
c =: a +/ .* b

So in a fresh file where I define matrices as numbers (where in my previous 
file I was mixing strings with trying ask for matrix multiplication) Copilot 
was able to offer the standard J matrix multiply operation. Certainly even a J 
advanced beginner would see it is easier just to multiply the 2 matrices and 
not engage Copilot at all. I have to type more characters in comments than the 
J code that gets generated. For J I loose notation as a tool of thought in 
working this way. However, I wanted to keep informed on AI code generation 
since it is all the rage for other languages. 


As interesting as Copilot is. It seems to excel at verbose languages where 
explicit loops and block oriented code are used frequently. As much as we here 
feel the terseness of J is a huge benefit if the language. The marketing of the 
AI tools seems to indicate what we have already known: That verbosity is added 
drudgery in a programming language. 

What is hidden in this particular thread is the code review that was mixed in. 
Michael Day proffered an improved version of the make palindrome function. Skip 
Cave provided a palindrome test for integers. This implies a better use for AI. 
Batch code review my J code (or any code) and suggest improvements. I did a 
quick search and there wasn’t anything that jumped out at me as fulfilling this 
particular function. There was one open source project that tied into GitHub 
pull requests to check code. 

I pose one more question to the group. Where speed of execution is important, 
wouldn’t it be better for AI to generate assembly code? It seems to me it is 
far more simple structurally. The mnemonic statements have a limited 
funcitonality and only a few modes of parameter use. I would think AI would be 
a better assembly language code generator than it would for high level 
languages. 




----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to