/ *   
 
   *   P R O J E C T :   N y A R T o o l k i t C S 
 
   *   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
   *   T h i s   w o r k   i s   b a s e d   o n   t h e   o r i g i n a l   A R T o o l K i t   d e v e l o p e d   b y 
 
   *       H i r o k a z u   K a t o 
 
   *       M a r k   B i l l i n g h u r s t 
 
   *       H I T L a b ,   U n i v e r s i t y   o f   W a s h i n g t o n ,   S e a t t l e 
 
   *   h t t p : / / w w w . h i t l . w a s h i n g t o n . e d u / a r t o o l k i t / 
 
   * 
 
   *   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 1 2   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 ; 
 
 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0A R T o o l K i t 1uegn00000$P{pe0cOW0~0Y00
 
           *   < p > m e m o : 
 
           *   S0n0000o00N_q}T0JRdY00S'`L0B00~0Y00
 
           *   < / p > 
 
           * / 
 
         p u b l i c   c l a s s   N y A R V e c 
 
         { 
 
                 / * *   0000n0Rpe* / 
 
                 p r i v a t e   i n t   c l m ; 
 
                 / * *   0000$P0<h
}Y00MR* / 
 
                 p r i v a t e   d o u b l e [ ]   v ; 
 
 
 
 
 
                 / * * 
 
                   *   0000000g0Y00
 
                   *   Rpe0c[W0f000000000ubW0~0Y00
 
                   *   @ p a r a m   i _ c l m 
 
                   *   Rpeg0Y00
 
                   * / 
 
                 p u b l i c   N y A R V e c ( i n t   i _ c l m ) 
 
                 { 
 
                         v   =   n e w   d o u b l e [ i _ c l m ] ; 
 
                         c l m   =   i _ c l m ; 
 
                 } 
 
 
 
                 / * * 
 
                   *   0000n0000000000i _ c l m k0ASRk0j000F0k0	YfW0~0Y00
 
                   *   [L_0Rn0T$Po0
N[k0j00~0Y00
 
                   *   @ p a r a m   i _ c l m 
 
                   *   eW0D0Rpe
 
                   * / 
 
                 p u b l i c   v o i d   r e a l l o c ( i n t   i _ c l m ) 
 
                 { 
 
                         i f   ( i _ c l m   < =   t h i s . v . L e n g t h ) 
 
                         { 
 
                                 / /   ASRj0MRL0B00p0UO0W0j0D00
 
                         } 
 
                         e l s e 
 
                         { 
 
                                 / /   
NASRj00S0vY00
 
                                 v   =   n e w   d o u b l e [ i _ c l m ] ; 
 
                         } 
 
                         t h i s . c l m   =   i _ c l m ; 
 
                 } 
 
 
 
                 / * * 
 
                   *   0000n0Rpe0ԏW0~0Y00
 
                   *   @ r e t u r n 
 
                   *   0000n0Rpe
 
                   * / 
 
                 p u b l i c   i n t   g e t C l m ( ) 
 
                 { 
 
                         r e t u r n   c l m ; 
 
                 } 
 
 
 
                 / * * 
 
                   *   0000$P0<h
}W0_0MRn0Sgq$P0ԏW0~0Y00
 
                   *   @ r e t u r n 
 
                   *   MRn0Sgq$P
 
                   * / 
 
                 p u b l i c   d o u b l e [ ]   g e t A r r a y ( ) 
 
                 { 
 
                         r e t u r n   v ; 
 
                 } 
 
 
 
                 / * * 
 
                   *   a r V e c I n n e r p r o d u c t pen0TI{Tg0Y00
 
                   *   S0n0peo0R\O00000W0f0J00Z00_jW0~0[000
 
                   *   s0}o0
Nfg0Y00
 
                   *   @ p a r a m   y 
 
                   *   
Nf0
 
                   *   @ p a r a m   i _ s t a r t 
 
                   *   o{YR( 0O00K00j0D0Q0i0a r V e c T r i d i a g o n a l i z e n0|Ts0QW0CQg0j00K0W0f00) 
 
                   *   @ r e t u r n 
 
                   *   
Nf0
 
                   *   @ 
 
                   * / 
 
                 p u b l i c   d o u b l e   v e c I n n e r p r o d u c t ( N y A R V e c   y ,   i n t   i _ s t a r t ) 
 
                 { 
 
                         N y A R E x c e p t i o n . t r a p ( " S0n0peo0R\Oxg0M0f0D0~0[000" ) ; 
 
                         d o u b l e   r e s u l t   =   0 . 0 ; 
 
                         / /   d o u b l e [ ]   x _ a r r a y = x . v ; . g e t A r r a y ( ) ; 
 
                         / /   d o u b l e [ ]   y _ a r r a y = y . g e t A r r a y ( ) ; 
 
 
 
                         i f   ( t h i s . c l m   ! =   y . c l m ) 
 
                         { 
 
                                 t h r o w   n e w   N y A R E x c e p t i o n ( ) ; / /   e x i t ( ) ; 
 
                         } 
 
                         f o r   ( i n t   i   =   i _ s t a r t ;   i   <   t h i s . c l m ;   i + + ) 
 
                         { 
 
                                 N y A R E x c e p t i o n . t r a p ( " *g0000n000" ) ; 
 
                                 r e s u l t   + =   t h i s . v [ i ]   *   y . v [ i ] ; / /   r e s u l t   + =   x - > v [ i ]   *   y - > v [ i ] ; 
 
                         } 
 
                         r e t u r n   r e s u l t ; 
 
                 } 
 
 
 
                 / * * 
 
                   *   a r V e c H o u s e h o l d pen0TI{Tg0Y00
 
                   *   s0}o0
Nfg0Y00
 
                   *   @ p a r a m   i _ s t a r t 
 
                   *   o{YR( 0O00K00j0D0Q0i0a r V e c T r i d i a g o n a l i z e n0|Ts0QW0CQg0j00K0W0f00) 
 
                   *   @ r e t u r n 
 
                   *   
Nf0
 
                   *   @ 
 
                   * / 
 
                 p u b l i c   d o u b l e   v e c H o u s e h o l d ( i n t   i _ s t a r t ) 
 
                 { 
 
                         N y A R E x c e p t i o n . t r a p ( " S0n0peo0R\Oxg0M0f0D0~0[000" ) ; 
 
                         d o u b l e   s ,   t ; 
 
                         s   =   M a t h . S q r t ( t h i s . v e c I n n e r p r o d u c t ( t h i s ,   i _ s t a r t ) ) ; 
 
                         / /   d o u b l e [ ]   x _ a r r a y = x . g e t A r r a y ( ) ; 
 
                         i f   ( s   ! =   0 . 0 ) 
 
                         { 
 
                                 N y A R E x c e p t i o n . t r a p ( " *g0000n000" ) ; 
 
                                 i f   ( t h i s . v [ i _ s t a r t ]   <   0 ) 
 
                                 { 
 
                                         s   =   - s ; 
 
                                 } 
 
                                 N y A R E x c e p t i o n . t r a p ( " *g0000n000" ) ; 
 
                                 { 
 
                                         t h i s . v [ i _ s t a r t ]   + =   s ; / /   x - > v [ 0 ]   + =   s ; 
 
                                         t   =   1   /   M a t h . S q r t ( t h i s . v [ i _ s t a r t ]   *   s ) ; / /   t   =   1   /   s q r t ( x - > v [ 0 ]   *   s ) ; 
 
                                 } 
 
                                 f o r   ( i n t   i   =   i _ s t a r t ;   i   <   t h i s . c l m ;   i + + ) 
 
                                 { 
 
                                         N y A R E x c e p t i o n . t r a p ( " *g0000n000" ) ; 
 
                                         t h i s . v [ i ]   * =   t ; / /   x - > v [ i ]   * =   t ; 
 
                                 } 
 
                         } 
 
                         r e t u r n   - s ; 
 
                 } 
 
 
 
                 / * * 
 
                   *   s(W000W0f0D00MR0S0YW0f00eW0D0MRh00Rpe0000W0~0Y00
 
                   *   @ p a r a m   i _ a r r a y 
 
                   *   eW0O0-[Y00MRg0Y00S0n0MRo00t h i s L0@b	gW0~0Y00
 
                   *   @ p a r a m   i _ c l m 
 
                   *   eW0D0V e c t o r n0Rpeg0Y00
 
                   * / 
 
                 p u b l i c   v o i d   s e t N e w A r r a y ( d o u b l e [ ]   i _ a r r a y ,   i n t   i _ c l m ) 
 
                 { 
 
                         t h i s . v   =   i _ a r r a y ; 
 
                         t h i s . c l m   =   i _ c l m ; 
 
                 } 
 
         } 
 
 } 