keithsullivan / opencloth

Automatically exported from code.google.com/p/opencloth
0 stars 0 forks source link

Passing arrays to function by value #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
First of all, thanks for such a great resource.

All I wanted to say was that in the code, you are passing arrays around by 
value. This is not great because it requires lots of unneccessary copying.
I got about a 30% speedup of your implicit integration code by simply changing 
all functions to recieve matrices and vectors by reference.

for example:

change: 
void SolveConjugateGradientPreconditioned(LargeVector<glm::mat3> A, 
LargeVector<glm::vec3> x, LargeVector<glm::vec3> b,LargeVector<glm::vec3> P, 
LargeVector<glm::vec3> P_inv)

to :
void SolveConjugateGradientPreconditioned(LargeVector<glm::mat3>& A, 
LargeVector<glm::vec3>& x, LargeVector<glm::vec3>& b,LargeVector<glm::vec3>& P, 
LargeVector<glm::vec3>& P_inv)

Original issue reported on code.google.com by daley.pa...@gmail.com on 19 Apr 2013 at 4:10

GoogleCodeExporter commented 9 years ago
Hi daley.paley,
  Thanks for the pointer. I always through arrays would be passed by reference but yes you are spot on. I will do that in the main truck as soon as possible.

Original comment by mmmova...@gmail.com on 22 May 2013 at 9:46

GoogleCodeExporter commented 9 years ago
I will be adding the updated version soon.

Original comment by mmmova...@gmail.com on 29 Mar 2014 at 6:31