Some time back there was a question about constructing upper triangular matrices. The verbs below can help. For example,

   (1 2 3 4 * id 4) + 8 9 0 0 * (super 4) pr 2
1 0 8 0
0 2 0 9
0 0 3 0
0 0 0 4

   NB. Where

   id 4
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1

   super 4
0 1 0 0
0 0 1 0
0 0 0 1
0 0 0 0

   pr   NB. matrix power
4 : 'x o^:y id # x'"_ 0

   (super 4) pr 2
0 0 1 0
0 0 0 1
0 0 0 0
0 0 0 0

   o    NB. matrix product
+/ .*

   (super 4) o super 4
0 0 1 0
0 0 0 1
0 0 0 0
0 0 0 0

   id
=...@i.

   super
3 : '(2#y) $ 0 , (<: *: y) $ 1 , y#0'

   NB. Also

   supexp  NB. exponential for (number times super n)
3 : '+/(y&pr % !) i.#y'

   supexp 0.2 * super 4
1 0.2 0.02 0.00133333
0   1  0.2       0.02
0   0    1        0.2
0   0    0          1

   NB. The definition for supexp is a truncated exponential series
   NB. which gives the exponential of (number times super n) because
   NB. for that matrix the infinite series has zero terms beginning
   NB. with the nth.  Entries on the kth super diagonal are
   NB. (number^k)%!k .   supexp is helpful for calculating the
   NB. exponential of a general square matrix from its Jordan form.


Kip Murray


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

Reply via email to