From 7bbe3e29f0e8475710e7d8a2ac92f5ed9b782256 Mon Sep 17 00:00:00 2001 From: Patrice Matz Date: Tue, 16 Jan 2018 22:24:13 +0100 Subject: [PATCH] - added 5.4.2 (optim.) and started 4.1.2 (lin. interpol.) --- Mex/a411.cpp | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++ Mex/a411.m | 18 +++++++++ Mex/a412.cpp | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++ Mex/a542.cpp | 60 ++++++++++++++++++++++++++++ 4 files changed, 296 insertions(+) create mode 100644 Mex/a411.cpp create mode 100644 Mex/a411.m create mode 100644 Mex/a412.cpp create mode 100644 Mex/a542.cpp diff --git a/Mex/a411.cpp b/Mex/a411.cpp new file mode 100644 index 0000000..b85eb34 --- /dev/null +++ b/Mex/a411.cpp @@ -0,0 +1,109 @@ +#include "mex.h" +#include "matrix.h" +#include "stdlib.h" +#include "math.h" + +void mexFunction(int nlhs, mxArray *plhs[], // Output variables + int nrhs, const mxArray *prhs[]) // Input variables +{ + int variables = *mxGetPr(prhs[0]); + + double* x = (double *)mxCalloc(variables, sizeof(double)); //create solution array + + double* xx = (double *)mxCalloc(variables, sizeof(double)); + double* yy = (double *)mxCalloc(variables, sizeof(double)); + + double** GA = (double **)mxCalloc(variables+1, sizeof(double*)); //create Gauss Array (GA) + for (int i = 0; i <= variables; i++){ + GA[i] = (double *)mxCalloc(variables+1, sizeof(double)); + } + + for(int i=0;i= 0; i--) //back-substitution + { //x is an array whose values correspond to the values of x,y,z.. + x[i] = GA[i][variables]; //make the variable to be calculated equal to the rhs of the last equation + for (j = i + 1; j= 0; i--) //back-substitution + { //x is an array whose values correspond to the values of x,y,z.. + x[i] = GA[i][variables]; //make the variable to be calculated equal to the rhs of the last equation + for (j = i + 1; j z) + { + z = znew; + x = xnew; + y = ynew; + } + else + if (xTOy == 1) + xTOy = 2; + } + + // Output + plhs[0] = mxCreateDoubleScalar(x); + plhs[1] = mxCreateDoubleScalar(y); + plhs[2] = mxCreateDoubleScalar(z); + plhs[3] = mxCreateDoubleScalar(i); +return; +} \ No newline at end of file