Speedup working: gradient computation time linear in terms of conditionalVector but takes a lot of memory