From 3ba40230ddd2501bb908b845230a61ccf1846efe Mon Sep 17 00:00:00 2001 From: EvilSpirit Date: Fri, 12 May 2017 10:02:33 +0700 Subject: [PATCH] Some optimization 1. We are making FoldConstants first, so we are copying less amount of data in DeepCopyWithParamsAsPointers. 2. Since we already perform DeepCopyWithParamsAsPointers, PartialWrt already produces params as pointers --- src/system.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/system.cpp b/src/system.cpp index 0cfa27d..c93b0a1 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -48,8 +48,8 @@ bool System::WriteJacobian(int tag) { continue; mat.eq[i] = e.h; - Expr *f = e.e->DeepCopyWithParamsAsPointers(¶m, &(SK.param)); - f = f->FoldConstants(); + Expr *f = e.e->FoldConstants(); + f = f->DeepCopyWithParamsAsPointers(¶m, &(SK.param)); for(j = 0; j < mat.n; j++) { mat.A.sym[i][j] = zero; @@ -63,7 +63,6 @@ bool System::WriteJacobian(int tag) { if(j == paramToIndex.end()) continue; Expr *pd = f->PartialWrt(p); pd = pd->FoldConstants(); - pd = pd->DeepCopyWithParamsAsPointers(¶m, &(SK.param)); mat.A.sym[i][j->second] = pd; } paramsUsed.Clear();