That's fun! You can factor out one mp:
fun =: ] mp B + (A mp ])
fun"1] 5 3 2,:9 9 9
151022 818253
NB. 9 9 9 is still problematic along with other inputs where
(100 <: ({.+/@:*}.)-1&{ ) input
eg
(100 <: ({.+/@:*}.)-1&{ )"1] 5 3 2, 8 8 6,:9 9 9
0 1 1
Mike
Mike
On 14/12/2014 15:45, Kip Murray wrote:
A
0 5000.5 50.5
5000.5 0 0
50.5 0 0
and the vector
B
0 _1 0
your function fun is the sum of a quadratic part
Q =: ] mp A mp ]
and a linear part
L =: B mp ]
where mp is the matrix product +/ . *
Thus
fun =: Q + L
fun 5 3 2
151022
---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com
-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2014.0.4794 / Virus Database: 4235/8734 - Release Date: 12/14/14
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm