public SparseVector plus ( SparseVector b ) { SparseVector a = this ; if ( a . N != b . N ) throw new IllegalArgumentException ( "Vector lengths disagree : " + a . N + " != " + b . N ) ; SparseVector c = new SparseVector ( N ) ; for ( int i : a . symbolTable ) c . put ( i , . get ( i ) ) ; // c = a for ( int i : b . symbolTable ) c . put ( i , . get ( i ) + . get ( i ) ) ; // c = c + b return c ; }
Calcualtes return a + b