use map to do scalar product