55#include <math.h>
66#include <stdlib.h>
77
8- /* Note: Q is not freed here because it's owned by the caller */
9-
108static void forward (expr * node , const double * u )
119{
1210 expr * x = node -> left ;
1311
14- /* children 's forward passes */
12+ /* child 's forward pass */
1513 x -> forward (x , u );
1614
1715 /* local forward pass */
@@ -45,8 +43,7 @@ static void jacobian_init(expr *node)
4543 else /* x is not a variable */
4644 {
4745 /* compute required allocation and allocate jacobian */
48- bool * col_nz = (bool * ) calloc (
49- node -> n_vars , sizeof (bool )); /* TODO: could use iwork here instead*/
46+ bool * col_nz = (bool * ) calloc (node -> n_vars , sizeof (bool ));
5047 int nonzero_cols = count_nonzero_cols (x -> jacobian , col_nz );
5148 node -> jacobian = new_csr_matrix (1 , node -> n_vars , nonzero_cols + 1 );
5249
@@ -65,9 +62,6 @@ static void jacobian_init(expr *node)
6562
6663 node -> jacobian -> p [0 ] = 0 ;
6764 node -> jacobian -> p [1 ] = node -> jacobian -> nnz ;
68-
69- /* Cast x to linear operator to use its A_csc in eval_jacobian */
70- node -> iwork = (int * ) malloc (sizeof (int ));
7165 }
7266}
7367
@@ -109,6 +103,7 @@ expr *new_quad_form(expr *left, CSR_Matrix *Q)
109103 expr * node = & qnode -> base ;
110104
111105 /* Initialize base fields */
106+ assert (left -> d2 == 1 );
112107 init_expr (node , left -> d1 , 1 , left -> n_vars , forward , jacobian_init , eval_jacobian ,
113108 NULL , NULL );
114109
0 commit comments