Skip to content

Commit 4f93f7c

Browse files
Transurgeonclaude
andcommitted
Add total_parameter_size field to problem struct
Precompute total parameter size in problem_register_params, mirroring how total_constraint_size is computed in new_problem. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 36ec239 commit 4f93f7c

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

include/problem.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ typedef struct problem
6262
/* Parameter tracking for fast parameter updates */
6363
expr **param_nodes; /* weak references to parameter nodes in tree */
6464
int n_param_nodes;
65+
int total_parameter_size;
6566

6667
/* Statistics for performance measurement */
6768
Diff_engine_stats stats;

src/problem.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,10 @@ void problem_register_params(problem *prob, expr **param_nodes,
453453
prob->n_param_nodes = n_param_nodes;
454454
prob->param_nodes = (expr **)malloc(n_param_nodes * sizeof(expr *));
455455
memcpy(prob->param_nodes, param_nodes, n_param_nodes * sizeof(expr *));
456+
457+
prob->total_parameter_size = 0;
458+
for (int i = 0; i < n_param_nodes; i++)
459+
prob->total_parameter_size += param_nodes[i]->size;
456460
}
457461

458462
void problem_update_params(problem *prob, const double *theta)

0 commit comments

Comments
 (0)