@@ -39,11 +39,7 @@ static void jacobian_init(expr *node)
3939 x -> jacobian_init (x );
4040
4141 /* same sparsity pattern as child */
42- node -> jacobian = new_csr_matrix (node -> size , node -> n_vars , x -> jacobian -> nnz );
43-
44- /* copy row pointers and column indices (sparsity pattern is constant) */
45- memcpy (node -> jacobian -> p , x -> jacobian -> p , (x -> jacobian -> m + 1 ) * sizeof (int ));
46- memcpy (node -> jacobian -> i , x -> jacobian -> i , x -> jacobian -> nnz * sizeof (int ));
42+ node -> jacobian = new_csr_copy_sparsity (x -> jacobian );
4743}
4844
4945static void eval_jacobian (expr * node )
@@ -68,11 +64,7 @@ static void wsum_hess_init(expr *node)
6864
6965 /* same sparsity pattern as child */
7066 CSR_Matrix * child_hess = x -> wsum_hess ;
71- node -> wsum_hess = new_csr_matrix (node -> n_vars , node -> n_vars , child_hess -> nnz );
72-
73- /* copy row pointers and column indices (sparsity pattern is constant) */
74- memcpy (node -> wsum_hess -> p , child_hess -> p , (child_hess -> m + 1 ) * sizeof (int ));
75- memcpy (node -> wsum_hess -> i , child_hess -> i , child_hess -> nnz * sizeof (int ));
67+ node -> wsum_hess = new_csr_copy_sparsity (child_hess );
7668}
7769
7870static void eval_wsum_hess (expr * node , const double * w )
0 commit comments