question: private DoubleFactor pointwiseProduct ( List < DoubleFactor > factors ) { if ( factors . isEmpty ( ) ) { DoubleFactor factor = new DoubleFactor ( ) ; factor . addEntry ( new Assignment ( ) , 1.0 , 0.0 ) ; return factor ; } else if ( factors . size ( ) == 1 ) { return factors . get ( 0 ) ; } DoubleFactor factor = factors . get ( 0 ) ; factors . remove ( 0 ) ; for ( DoubleFactor f : factors ) { DoubleFactor tempFactor = new DoubleFactor ( ) ; Set < String > sharedVars = new HashSet < String > ( f . getVariables ( ) ) ; sharedVars . retainAll ( factor . getVariables ( ) ) ; for ( Assignment a : f . getValues ( ) ) { double [ ] entry = f . getEntry ( a ) ; double prob = entry [ 0 ] ; double util = entry [ 1 ] ; for ( Assignment b : factor . getValues ( ) ) { if ( b . consistentWith ( a , sharedVars ) ) { double [ ] entry2 = factor . getEntry ( b ) ; double prob2 = entry2 [ 0 ] ; double util2 = entry2 [ 1 ] ; double product = prob * prob2 ; double sum = util + util2 ; tempFactor . addEntry ( new Assignment ( a , b ) , product , sum ) ; } } } factor = tempFactor ; } return factor ; }
target:  Computes the pointwise matrix product of the list of factors