<commit_before>/**************************************************************************************************
* 
* Author: <NAME>, <EMAIL>
*
* Factorizes in double precision the extended LQ control problem, factorized algorithm
*
**************************************************************************************************/

#include "mex.h"
#include <stdio.h>
#include <stdlib.h>
/*#include <math.h>*/

#include <hpmpc/c_interface.h>



// the gateway function 
void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
	{
		
	// get data 
	double *A, *G, *C, *f, *Q, *R, *q, *r, *y, *x0, *L0, *xe, *Le, *w;
	
	const int smooth = (int) mxGetScalar(prhs[0]);
	const int nx = (int) mxGetScalar(prhs[1]);
	const int nw = (int) mxGetScalar(prhs[2]);
	const int ny = (int) mxGetScalar(prhs[3]);
	const int N  = (int) mxGetScalar(prhs[4]);

	A = mxGetPr(prhs[5]);
	G = mxGetPr(prhs[6]);
	C = mxGetPr(prhs[7]);
	f = mxGetPr(prhs[8]);
	Q = mxGetPr(prhs[9]);
	R = mxGetPr(prhs[10]);
	q = mxGetPr(prhs[11]);
	r = mxGetPr(prhs[12]);
	y = mxGetPr(prhs[13]);
	x0 = mxGetPr(prhs[14]);
	L0 = mxGetPr(prhs[15]);
	xe = mxGetPr(prhs[16]);
	Le = mxGetPr(prhs[17]);
	w = mxGetPr(prhs[18]);
	
	int work_space_size = hpmpc_ric_mhe_dp_work_space(nx, nw, ny, N);

	double *work = (double *) malloc( work_space_size * sizeof(double) );;
	
	// call the solver
	fortran_order_riccati_mhe( 'd', smooth, nx, nw, ny, N, A, G, C, f, Q, R, q, r, y, x0, L0, xe, Le, w, work );
	//c_order_riccati_mhe( 'd', smooth, nx, nw, ny, N, A, G, C, f, Q, R, q, r, y, x0, L0, xe, Le, w, work );

	return;

	}

<commit_msg>fixed deallocation bug in ric mhe octave mex<commit_after>/**************************************************************************************************
* 
* Author: <NAME>, <EMAIL>
*
* Factorizes in double precision the extended LQ control problem, factorized algorithm
*
**************************************************************************************************/

#include "mex.h"
#include <stdio.h>
#include <stdlib.h>
/*#include <math.h>*/

#include <hpmpc/c_interface.h>



// the gateway function 
void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
	{
		
	// get data 
	double *A, *G, *C, *f, *Q, *R, *q, *r, *y, *x0, *L0, *xe, *Le, *w;
	
	const int smooth = (int) mxGetScalar(prhs[0]);
	const int nx = (int) mxGetScalar(prhs[1]);
	const int nw = (int) mxGetScalar(prhs[2]);
	const int ny = (int) mxGetScalar(prhs[3]);
	const int N  = (int) mxGetScalar(prhs[4]);

	A = mxGetPr(prhs[5]);
	G = mxGetPr(prhs[6]);
	C = mxGetPr(prhs[7]);
	f = mxGetPr(prhs[8]);
	Q = mxGetPr(prhs[9]);
	R = mxGetPr(prhs[10]);
	q = mxGetPr(prhs[11]);
	r = mxGetPr(prhs[12]);
	y = mxGetPr(prhs[13]);
	x0 = mxGetPr(prhs[14]);
	L0 = mxGetPr(prhs[15]);
	xe = mxGetPr(prhs[16]);
	Le = mxGetPr(prhs[17]);
	w = mxGetPr(prhs[18]);
	
	int work_space_size = hpmpc_ric_mhe_dp_work_space(nx, nw, ny, N);

	double *work = (double *) malloc( work_space_size * sizeof(double) );
	
	// call the solver
	fortran_order_riccati_mhe( 'd', smooth, nx, nw, ny, N, A, G, C, f, Q, R, q, r, y, x0, L0, xe, Le, w, work );
	//c_order_riccati_mhe( 'd', smooth, nx, nw, ny, N, A, G, C, f, Q, R, q, r, y, x0, L0, xe, Le, w, work );

	free(work);

	return;

	}


{'fraction_non_alphanumeric': 0.2955242182709994, 'fraction_numerical': 0.022072348252605765, 'mean_word_length': 4.7957371225577266, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5270242', 'n_tokens_mistral': 1423, 'n_tokens_neox': 1390, 'n_words': 346}