Thanks. Should have noticed that.

R.E. Boss


> -----Oorspronkelijk bericht-----
> Van: [email protected] [mailto:programming-
> [email protected]] Namens Roger Hui
> Verzonden: zaterdag 13 maart 2010 17:49
> Aan: Programming forum
> Onderwerp: Re: [Jprogramming] Solving linear equations
> 
> The dyad %. solves overdetermined linear systems,
> i.e. tall (or square) matrices.  e.g.
> 
>    X=: _25 + 10 4 ?...@$ 50
>    b=: 2 3 4 5
>    e=: 10 ?...@$ 0
>    y=: e + X +/ .* b
> 
>    y %. X
> 2.00375 3.03291 3.99406 4.97709
> 
>    y1=: X +/ .* b
>    y1 %. X
> 2 3 4 5
>    (i{y1) %. i{X [ i=: 4?#X
> 2 3 4 5
> 
> The columns of the matrix must be linearly independent,
> however.
> 
> 
> 
> ----- Original Message -----
> From: "R.E. Boss" <[email protected]>
> Date: Saturday, March 13, 2010 6:51
> Subject: [Jprogramming] Solving linear equations
> To: 'Programming forum' <[email protected]>
> 
> > 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
> > dependentequations. 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
> > independentequations
> >
> > 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
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

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

Reply via email to