I did not find a method for solving a set of linear equations, apart from
the ones in /math/misc/linear.ijs which did not work for mutual dependent
equations. So I constructed a solution myself. 
(See also http://www.jsoftware.com/jwiki/RE%20Boss/J-blog/(De)Convolution )


NB. y is a matrix representing a set of equations given by the multipliers
(}:"1 y) and the results ({:"1 y).
NB. the result is a vector, or a matrix, the minimal set of independent
equations

sle=: 3 : 0                                             NB. solve linear
equations
 Y=. (#"1~ +./@:*)&.|: y                                NB. eliminate
dependent equations
 Y=. \:~ rdeq^:(<:@{:@$)^:_ Y                           NB. reduce the
equations and sort them in descending order
 if. 1 = -~/ $Y do. {:"1 Y return. end.                 NB. give the
solution in the natural order
 Y                                                      NB. give the minimal
set of independent equations
)

rdeq=: 3 : 0                                            NB. reduce equations
 y0=. {.y
 assert. (0 ~: +./ }:y0) +. 0 = {:y0                    NB. conflicting
equations
 t=. ((%~<:)@{. , }. % {.) y {"1~ 1 i.~ * | y0          NB. coefficients to
be used
 Y=. ({. ,~ }.) t (] - (*/ {.)) y                       NB. cleaning the
column
 (#"1~ +./@:*)&.|: Y                                    NB. eliminate
dependent equations
)

T=:".;._2]0 :0                  NB. from
http://www.jsoftware.com/jwiki/RE%20Boss/J-blog/(De)Convolution 
6 0 0 0 0 0 0 0 0 0 0 0  30
9 6 0 0 0 0 0 0 0 0 0 0  57
0 9 6 0 0 0 0 0 0 0 0 0  72
6 0 9 6 0 0 0 0 0 0 0 0 141
3 6 0 9 0 0 0 0 0 0 0 0  72
0 3 6 0 0 0 0 0 0 0 0 0  60
0 0 3 6 0 0 0 0 0 0 0 0  57
0 0 0 3 0 0 0 0 0 0 0 0  15
2 0 0 0 6 0 0 0 0 0 0 0  34
9 2 0 0 9 6 0 0 0 0 0 0  85
1 9 2 0 0 9 6 0 0 0 0 0  95
7 1 9 2 6 0 9 6 0 0 0 0 233
3 7 1 9 3 6 0 9 0 0 0 0  95
0 3 7 1 0 3 6 0 0 0 0 0 128
0 0 3 7 0 0 3 6 0 0 0 0  89
0 0 0 3 0 0 0 3 0 0 0 0  15
0 0 0 0 2 0 0 0 6 0 0 0   8
0 0 0 0 9 2 0 0 9 6 0 0  78
0 0 0 0 1 9 2 0 0 9 6 0 139
0 0 0 0 7 1 9 2 6 0 9 6 238
0 0 0 0 3 7 1 9 3 6 0 9 135
0 0 0 0 0 3 7 1 0 3 6 0 138
0 0 0 0 0 0 3 7 0 0 3 6 102
0 0 0 0 0 0 0 3 0 0 0 3  24
0 0 0 0 0 0 0 0 2 0 0 0   0
0 0 0 0 0 0 0 0 9 2 0 0  14
0 0 0 0 0 0 0 0 1 9 2 0  81
0 0 0 0 0 0 0 0 7 1 9 2 104
0 0 0 0 0 0 0 0 3 7 1 9 130
0 0 0 0 0 0 0 0 0 3 7 1  92
0 0 0 0 0 0 0 0 0 0 3 7  83
0 0 0 0 0 0 0 0 0 0 0 3  24
)

   sle T
5 2 9 5 4 0 9 0 0 7 9 8

   ({:"1 T) -: (}:"1 T)(+/@:*"1) sle T
1


R.E. Boss

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

Reply via email to