public static Polynomial multiply ( Polynomial a , Polynomial b , Polynomial result ) { int N = Math . max ( 0 , a . size ( ) + b . size ( ) - 1 ) ; if ( result == null ) { result = new Polynomial ( N ) ; } else { if ( result . size < N ) throw new IllegalArgumentException ( "Unexpected length of 'result'" ) ; result . zero ( ) ; } for ( int i = 0 ; i < a . size ; i ++ ) { double coef = a . c [ i ] ; int index = i ; for ( int j = 0 ; j < b . size ; j ++ ) { result . c [ index ++ ] += coef * b . c [ j ] ; } } return result ; }
Multiplies the two polynomials together .