void SNLLBase:: copy_con_grad(const RealMatrix& local_fn_grads, RealMatrix& grad_g, const size_t& offset) { // Unlike DAKOTA, OPT++ expects nonlinear equations followed by nonlinear // inequalities. Therefore, we have to reorder the constraint gradients. // Assign the gradients of the nonlinear constraints. Let g: R^n -> R^m. // The gradient of g, grad_g, is the n x m matrix whose ith column is the // gradient of g_i. The transpose of grad_g is called the Jacobian of g. // WJB: candidate for more efficient rewrite?? (both are ColumnMajor grads!) size_t i, j, n = local_fn_grads.numRows(), num_nln_eq_con = optLSqInstance->numNonlinearEqConstraints, num_nln_ineq_con = optLSqInstance->numNonlinearIneqConstraints; for (i=0; i<n; i++) for (j=0; j<num_nln_eq_con; j++) grad_g(i, j) = local_fn_grads(i,offset+num_nln_ineq_con+j); for (i=0; i<n; i++) for (j=0; j<num_nln_ineq_con; j++) grad_g(i, j+num_nln_eq_con) = local_fn_grads(i,offset+j); }