added apply_A and elementwise_mult