implement sum and transpose