/ *   
 
   *   P R O J E C T :   N y A R T o o l k i t C S ( E x t e n s i o n ) 
 
   *   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
   *   T h e   N y A R T o o l k i t C S   i s   J a v a   e d i t i o n   A R T o o l K i t   c l a s s   l i b r a r y . 
 
   *   C o p y r i g h t   ( C ) 2 0 0 8 - 2 0 0 9   R y o   I i z u k a 
 
   * 
 
   *   T h i s   p r o g r a m   i s   f r e e   s o f t w a r e :   y o u   c a n   r e d i s t r i b u t e   i t   a n d / o r   m o d i f y 
 
   *   i t   u n d e r   t h e   t e r m s   o f   t h e   G N U   G e n e r a l   P u b l i c   L i c e n s e   a s   p u b l i s h e d   b y 
 
   *   t h e   F r e e   S o f t w a r e   F o u n d a t i o n ,   e i t h e r   v e r s i o n   3   o f   t h e   L i c e n s e ,   o r 
 
   *   ( a t   y o u r   o p t i o n )   a n y   l a t e r   v e r s i o n . 
 
   *   
 
   *   T h i s   p r o g r a m   i s   d i s t r i b u t e d   i n   t h e   h o p e   t h a t   i t   w i l l   b e   u s e f u l , 
 
   *   b u t   W I T H O U T   A N Y   W A R R A N T Y ;   w i t h o u t   e v e n   t h e   i m p l i e d   w a r r a n t y   o f 
 
   *   M E R C H A N T A B I L I T Y   o r   F I T N E S S   F O R   A   P A R T I C U L A R   P U R P O S E .     S e e   t h e 
 
   *   G N U   G e n e r a l   P u b l i c   L i c e n s e   f o r   m o r e   d e t a i l s . 
 
   * 
 
   *   Y o u   s h o u l d   h a v e   r e c e i v e d   a   c o p y   o f   t h e   G N U   G e n e r a l   P u b l i c   L i c e n s e 
 
   *   a l o n g   w i t h   t h i s   p r o g r a m .     I f   n o t ,   s e e   < h t t p : / / w w w . g n u . o r g / l i c e n s e s / > . 
 
   *   
 
   *   F o r   f u r t h e r   i n f o r m a t i o n   p l e a s e   c o n t a c t . 
 
   * 	 h t t p : / / n y a t l a . j p / n y a t o o l k i t / 
 
   * 	 < a i r m a i l ( a t ) e b o n y . p l a l a . o r . j p >   o r   < n y a t l a ( a t ) n y a t l a . j p > 
 
   *   
 
   * / 
 
 u s i n g   S y s t e m ; 
 
 u s i n g   S y s t e m . D i a g n o s t i c s ; 
 
 n a m e s p a c e   j p . n y a t l a . n y a r t o o l k i t . c s . c o r e 
 
 { 
 
 
 
         / * * 
 
           *   S0n0000o00#zez_0O0pe0[ňW0~0Y00
 
           * / 
 
         p u b l i c   c l a s s   N y A R S y s t e m O f L i n e a r E q u a t i o n s P r o c e s s o r 
 
         { 
 
                 / * * 
 
                   *   i _ r e f t h0i _ r i g h t n0teT'`0xW0~0Y00
 
                   *   @ p a r a m   i _ l e f t 
 
                   *   @ p a r a m   i _ r i g h t 
 
                   *   @ r e t u r n 
 
                   * / 
 
                 p r i v a t e   s t a t i c   b o o l   i s V a l i d 2 d A r r a y ( d o u b l e [ ] [ ]   i _ l e f t ,   d o u b l e [ ]   i _ r i g h t ) 
 
                 { 
 
                         i n t   s m   =   i _ l e f t . L e n g t h ; 
 
                         i n t   s n   =   i _ l e f t [ 0 ] . L e n g t h ; 
 
                         i f   ( i _ l e f t . L e n g t h   ! =   s m ) 
 
                         { 
 
                                 r e t u r n   f a l s e ; 
 
                         } 
 
                         i f   ( i _ r i g h t . L e n g t h   ! =   s m ) 
 
                         { 
 
                                 r e t u r n   f a l s e ; 
 
                         } 
 
                         f o r   ( i n t   i   =   1 ;   i   <   s m ;   i + + ) 
 
                         { 
 
                                 i f   ( i _ l e f t [ i ] . L e n g t h   ! =   s n ) 
 
                                 { 
 
                                         r e t u r n   f a l s e ; 
 
                                 } 
 
                         } 
 
                         r e t u r n   t r u e ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0peo00ez_n0OpeMRk0000n0mSl0[LW0~0Y00
 
                   *   [ i _ l e f t _ s r c ] = [ i _ r i g h t _ s r c ] n0_k0000n0mSl0[LW0f00i _ l e f t n0 }01 k0j000F0k0W,g	Yb_W0~0Y00
 
                   *   i _ m h0i _ n L0I{W0O0j0D04XTo00 gB}Ln0 }L01 k0j00~0g0W,g	Yb_0[LW0f00B}NW0~0Y00
 
                   *   < p > 
 
                   *   ez_n0Opeo00!kn00F0k0eQRW0~0Y00
 
                   *   < p r e > 
 
                   *   < t a b l e > 
 
                   *   < t r > < t d > i _ l e f t [ 0 ] [ 0 ] * X + < / t d > < t d > i _ l e f t [ 0 ] [ 1 ] * Y + < / t d > < t d > i _ l e f t [ 0 ] [ 2 ] * Z < / t d > < t d > = < / t d > < t d > i _ r i g h t [ 0 ] < / t d > < / t r > 
 
                   *   < t r > < t d > i _ l e f t [ 1 ] [ 0 ] * X + < / t d > < t d > i _ l e f t [ 1 ] [ 1 ] * Y + < / t d > < t d > i _ l e f t [ 1 ] [ 2 ] * Z < / t d > < t d > = < / t d > < t d > i _ r i g h t [ 1 ] < / t d > < / t r > 
 
                   *   < t r > < t d > i _ l e f t [ 2 ] [ 0 ] * X + < / t d > < t d > i _ l e f t [ 2 ] [ 1 ] * Y + < / t d > < t d > i _ l e f t [ 2 ] [ 2 ] * Z < / t d > < t d > = < / t d > < t d > i _ r i g h t [ 2 ] < / t d > < / t r > 
 
                   *   < / t a b l e > 
 
                   *   < / p r e > 
 
                   *   pe0[LY00h00MRo0!kn00F0k0j00~0Y00
 
                   *   < p r e > 
 
                   *   < t a b l e > 
 
                   *   < t r > < t d > 1 < / t d > < t d > 0 < / t d > < t d > 0 < / t d > < t d > = < / t d > < t d > A < / t d > < / t r > 
 
                   *   < t r > < t d > 0 < / t d > < t d > 1 < / t d > < t d > 0 < / t d > < t d > = < / t d > < t d > B < / t d > < / t r > 
 
                   *   < t r > < t d > 0 < / t d > < t d > 0 < / t d > < t d > 1 < / t d > < t d > = < / t d > < t d > C < / t d > < / t r > 
 
                   *   < / t a b l e > 
 
                   *   < / p r e > 
 
                   *   < / p > 
 
                   *   @ p a r a m   i _ l e f t 
 
                   *   #zez_n0]$P0c[W0~0Y00[ i _ m ] [ i _ n ] n0MR0c[W0f0O0`0U0D00
 
                   *   @ p a r a m   i _ r i g h t 
 
                   *   #zez_n0S$P0c[W0~0Y00[ i _ m ] n0MR0c[W0f0O0`0U0D00
 
                   *   @ p a r a m   i _ n 
 
                   *   #zez_n0Open0pe0c[W0~0Y00
 
                   *   @ p a r a m   i _ m 
 
                   *   #zez_n0pe0c[W0~0Y00
 
                   *   @ r e t u r n 
 
                   *    gB}L~0g0W,g	Yb_L0g0M0f0p0t r u e 0ԏW0~0Y00
 
                   * / 
 
                 p u b l i c   s t a t i c   b o o l   d o G a u s s i a n E l i m i n a t i o n ( d o u b l e [ ] [ ]   i _ l e f t ,   d o u b l e [ ]   i _ r i g h t ,   i n t   i _ n ,   i n t   i _ m ) 
 
                 { 
 
                         / / teT'`0xY00. 
 
                         D e b u g . A s s e r t ( i s V a l i d 2 d A r r a y ( i _ l e f t ,   i _ r i g h t ) ) ; 
 
 
 
 
 
                         / / 1 LvNM
 
                         f o r   ( i n t   s o l v e _ r o w   =   0 ;   s o l v e _ r o w   <   i _ m ;   s o l v e _ r o w + + ) 
 
                         { 
 
                                 { / / 0000d\O
 
                                         i n t   p i v o d   =   s o l v e _ r o w ; 
 
                                         d o u b l e   p i v o d _ v a l u e   =   M a t h . A b s ( i _ l e f t [ p i v o d ] [ p i v o d ] ) ; 
 
                                         f o r   ( i n t   i   =   s o l v e _ r o w   +   1 ;   i   <   i _ m ;   i + + ) 
 
                                         { 
 
                                                 d o u b l e   p i v o d _ 2   =   M a t h . A b s ( i _ l e f t [ i ] [ p i v o d ] ) ; 
 
                                                 i f   ( p i v o d _ v a l u e   <   M a t h . A b s ( p i v o d _ 2 ) ) 
 
                                                 { 
 
                                                         p i v o d   =   i ; 
 
                                                         p i v o d _ v a l u e   =   p i v o d _ 2 ; 
 
                                                 } 
 
                                         } 
 
                                         i f   ( s o l v e _ r o w   ! =   p i v o d ) 
 
                                         { 
 
                                                 / / Ln0eQ0fH0( C n0Bfo000000000Oc0f0) 
 
                                                 d o u b l e [ ]   t   =   i _ l e f t [ s o l v e _ r o w ] ; 
 
                                                 i _ l e f t [ s o l v e _ r o w ]   =   i _ l e f t [ p i v o d ] ; 
 
                                                 i _ l e f t [ p i v o d ]   =   t ; 
 
                                                 d o u b l e   t 2   =   i _ r i g h t [ s o l v e _ r o w ] ; 
 
                                                 i _ r i g h t [ s o l v e _ r o w ]   =   i _ r i g h t [ p i v o d ] ; 
 
                                                 i _ r i g h t [ p i v o d ]   =   t 2 ; 
 
                                         } 
 
                                 } 
 
                                 d o u b l e [ ]   d e s t _ l _ n   =   i _ l e f t [ s o l v e _ r o w ] ; 
 
                                 d o u b l e   d e s t _ l _ n n   =   i _ l e f t [ s o l v e _ r o w ] [ s o l v e _ r o w ] ; 
 
                                 i f   ( d e s t _ l _ n n   = =   0 . 0 ) 
 
                                 { 
 
                                         / / xb_n0[҉ }L00 k0j0c0f0W0~0c0_001YWeY000
 
                                         r e t u r n   f a l s e ; 
 
                                 } 
 
 
 
                                 / / mS{( 0   -   s o l v e _ r o w - 1 ~0g0n0mS) 
 
                                 f o r   ( i n t   i   =   0 ;   i   <   s o l v e _ r o w ;   i + + ) 
 
                                 { 
 
                                         d o u b l e   s   =   d e s t _ l _ n [ i ] ; 
 
                                         f o r   ( i n t   i 2   =   0 ;   i 2   <   i _ n ;   i 2 + + ) 
 
                                         { 
 
                                                 d o u b l e   p   =   i _ l e f t [ i ] [ i 2 ]   *   s ; 
 
                                                 d e s t _ l _ n [ i 2 ]   =   d e s t _ l _ n [ i 2 ]   -   p ; 
 
                                         } 
 
                                         d o u b l e   k   =   i _ r i g h t [ i ]   *   s ; 
 
                                         i _ r i g h t [ s o l v e _ r o w ]   =   i _ r i g h t [ s o l v e _ r o w ]   -   k ; 
 
 
 
                                 } 
 
                                 / / mSln0[L( rR0{) 
 
                                 d o u b l e   d   =   d e s t _ l _ n [ s o l v e _ r o w ] ; 
 
                                 f o r   ( i n t   i 2   =   0 ;   i 2   <   s o l v e _ r o w ;   i 2 + + ) 
 
                                 { 
 
                                         d e s t _ l _ n [ i 2 ]   =   0 ; 
 
                                 } 
 
                                 i f   ( d   ! =   1 . 0 ) 
 
                                 { 
 
                                         d e s t _ l _ n [ s o l v e _ r o w ]   =   1 . 0 ; 
 
                                         f o r   ( i n t   i   =   s o l v e _ r o w   +   1 ;   i   <   i _ n ;   i + + ) 
 
                                         { 
 
                                                 d e s t _ l _ n [ i ]   / =   d ; 
 
                                         } 
 
                                         i _ r i g h t [ s o l v e _ r o w ]   / =   d ; 
 
                                 } 
 
                         } 
 
                         r e t u r n   t r u e ; 
 
                 } 
 
                 / * * 
 
                   *   S0n0peo00i _ l e f t h0i _ r i g h t g0hsU00_0#zez_0D0f00i _ l e f t , i _ r i g h t Q[0feW0~0Y00
 
                   *   i _ r i g h t [ n ] n0Q[L00i _ l e f t [ x ] [ n ] juvn0Open0k0j00~0Y00
 
                   *   MRn0hsk0d0D0f0o00{ @ l i n k   # d o G a u s s i a n E l i m i n a t i o n } 0SgqW0f0O0`0U0D00
 
                   *   @ p a r a m   i _ l e f t 
 
                   *   #zez_n0]$P0c[W0~0Y00[ i _ m ] [ i _ n ] n0MR0c[W0f0O0`0U0D00
 
                   *   @ p a r a m   i _ r i g h t 
 
                   *   #zez_n0S$P0c[W0~0Y00[ i _ m ] n0MR0c[W0f0O0`0U0D00
 
                   *   @ p a r a m   i _ n u m b e r _ o f _ s y s t e m 
 
                   *   ez_n0pe0c[W0~0Y00
 
                   *   @ r e t u r n 
 
                   *   ez_L0Q00p0t r u e 0ԏW0~0Y00
 
                   * / 
 
                 p u b l i c   s t a t i c   b o o l   s o l v e ( d o u b l e [ ] [ ]   i _ l e f t ,   d o u b l e [ ]   i _ r i g h t ,   i n t   i _ n u m b e r _ o f _ s y s t e m ) 
 
                 { 
 
                         r e t u r n   d o G a u s s i a n E l i m i n a t i o n ( i _ l e f t ,   i _ r i g h t ,   i _ n u m b e r _ o f _ s y s t e m ,   i _ n u m b e r _ o f _ s y s t e m ) ; 
 
                 } 
 
         } 
 
 } 