1 /**************************************************************************************************
2 *                                                                                                 *
3 * This file is part of HPIPM.                                                                     *
4 *                                                                                                 *
5 * HPIPM -- High-Performance Interior Point Method.                                                *
6 * Copyright (C) 2019 by Gianluca Frison.                                                          *
7 * Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl.              *
8 * All rights reserved.                                                                            *
9 *                                                                                                 *
10 * The 2-Clause BSD License                                                                        *
11 *                                                                                                 *
12 * Redistribution and use in source and binary forms, with or without                              *
13 * modification, are permitted provided that the following conditions are met:                     *
14 *                                                                                                 *
15 * 1. Redistributions of source code must retain the above copyright notice, this                  *
16 *    list of conditions and the following disclaimer.                                             *
17 * 2. Redistributions in binary form must reproduce the above copyright notice,                    *
18 *    this list of conditions and the following disclaimer in the documentation                    *
19 *    and/or other materials provided with the distribution.                                       *
20 *                                                                                                 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND                 *
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED                   *
23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE                          *
24 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR                 *
25 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES                  *
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;                    *
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND                     *
28 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT                      *
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS                   *
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                                    *
31 *                                                                                                 *
32 * Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de                             *
33 *                                                                                                 *
34 **************************************************************************************************/
35 // system
36 #include <stdlib.h>
37 #include <stdio.h>
38 #include <string.h>
39 // hpipm
40 #include "hpipm_d_ocp_qp_dim.h"
41 #include "hpipm_d_ocp_qp.h"
42 // mex
43 #include "mex.h"
44 
45 
46 
mexFunction(int nlhs,mxArray * plhs[],int nrhs,const mxArray * prhs[])47 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
48 	{
49 
50 //	printf("\nin ocp_qp_create\n");
51 
52 	mxArray *tmp_mat;
53 	long long *l_ptr;
54 	char *c_ptr;
55 
56 	/* RHS */
57 
58 	// dim
59 	l_ptr = mxGetData( prhs[0] );
60 	struct d_ocp_qp_dim *dim = (struct d_ocp_qp_dim *) *l_ptr;
61 
62 	/* body */
63 
64 	int qp_size = sizeof(struct d_ocp_qp) + d_ocp_qp_memsize(dim);
65 	void *qp_mem = malloc(qp_size);
66 
67 	c_ptr = qp_mem;
68 
69 	struct d_ocp_qp *qp = (struct d_ocp_qp *) c_ptr;
70 	c_ptr += sizeof(struct d_ocp_qp);
71 
72 	d_ocp_qp_create(dim, qp, c_ptr);
73 	c_ptr += d_ocp_qp_memsize(dim);
74 
75 	/* LHS */
76 
77 	tmp_mat = mxCreateNumericMatrix(1, 1, mxINT64_CLASS, mxREAL);
78 	l_ptr = mxGetData(tmp_mat);
79 	l_ptr[0] = (long long) qp_mem;
80 	plhs[0] = tmp_mat;
81 
82 	return;
83 
84 	}
85 
86 
87 
88