#ifndef MATLAB_FUNC #define MATLAB_FUNC #include "gamma_alg_global.h" namespace Matlab { PiecePoly mkpp(arma::rowvec breaks, arma::mat coefs, arma::rowvec d = arma::rowvec()); /* function v=ppval(pp,xx) * PPVAL Evaluate piecewise polynomial. * V = PPVAL(PP,XX) returns the value, at the entries of XX, of the * piecewise polynomial f contained in PP, as constructed by PCHIP, SPLINE, * INTERP1, or the spline utility MKPP. */ arma::mat ppval(arma::mat xx, PiecePoly pp); /* peakSearch.m => calValues.m => calFcnEval.m => polyval.m * function [y, delta] = polyval(p,x,S,mu) */ arma::mat polyval(arma::mat p, arma::mat x, arma::mat S = arma::mat(0, 1), arma::mat mu = arma::mat(0, 1)); /* polyval.m => filter.m ----Built-in function * Y = FILTER(B,A,X) filters the data in vector X with the filter described * by vectors A and B to create the filtered data Y. */ void filter(arma::mat& y, arma::mat B, arma::mat A, arma::mat X, arma::uword n); /* POLYDER Differentiate polynomial. * POLYDER(P) returns the derivative of the polynomial whose * coefficients are the elements of vector P. */ void polyder(arma::mat &a, arma::mat &b, int nargout, arma::mat u, arma::mat v = arma::mat(0, 1) ); // function [p,S,mu] = polyfit(x,y,n) arma::colvec polyfit(arma::colvec x, arma::colvec y , int n); /* REALMIN Smallest positive floating point number. * x = realmin is the smallest positive normalized double precision floating * point number on this computer. Anything smaller underflows or is an IEEE * "denormal". * * REALMIN('double') is the same as REALMIN with no arguments. * * REALMIN('single') is the smallest positive normalized single precision * floating point number on this computer. */ double realmin(QString type = QString("double")); int fix(double x); arma::mat fix(arma::mat dataMat); /*Y = ERF(X) is the error function for each element of X. X must be real. * The error function is defined as: * erf(x) = 2/sqrt(pi) * integral from 0 to x of exp(-t^2) dt. */ arma::mat m_erf(arma::mat x); //function output = spline(x,y,xx) arma::mat spline(arma::mat x, arma::mat y, arma::mat xx); PiecePoly spline(arma::mat x, arma::mat y); //function [x,y,sizey,endslopes] = chckxy(x,y) void chckxy(arma::mat &x, arma::mat& y, arma::rowvec &sizey, arma::mat& endslopes, int nargout); /* function pc = pwch(x,y,s,dx,divdif) * PWCH Piecewise cubic Hermite interpolation * * PC = PWCH(X,Y,S) returns the ppform of the piecewise cubic Hermite * interpolant f to the given data values Y and the given slopes S * at the given data sites X. X must be a vector, and S must be of the same * size as Y. * If Y is a vector, then it must be of the same length as X and will be * resized if necessary to be a row vector. * If Y is a matrix, then size(Y,2) must equal length(X). * * With d equal to size(Y,1), the piecewise cubic Hermite interpolant f to * these data is the d-valued piecewise cubic function with breaks at the * data sites X that satisfies * * f(X(j)) = Y(:,j), Df(X(j)) = S(:,j), j=1:length(X) . * * PC = PWCH(X,Y,S,DX,DIVDIF) also asks for DX := diff(X) and DIVDIF := * diff(Y,1,2)./DX . */ PiecePoly pwch(arma::mat x, arma::mat y, arma::mat s, arma::mat dx = arma::mat(0,0), arma::mat divdif = arma::mat(0,0)); /* function [res1,res2] = spdiags(arg1,arg2,arg3,arg4) * SPDIAGS Sparse matrix formed from diagonals. * SPDIAGS, which generalizes the function "diag", deals with three * matrices, in various combinations, as both input and output. * * [B,d] = SPDIAGS(A) extracts all nonzero diagonals from the m-by-n * matrix A. B is a min(m,n)-by-p matrix whose columns are the p * nonzero diagonals of A. d is a vector of length p whose integer * components specify the diagonals in A. * * B = SPDIAGS(A,d) extracts the diagonals specified by d. * A = SPDIAGS(B,d,A) replaces the diagonals of A specified by d with * the columns of B. The output is sparse. * A = SPDIAGS(B,d,m,n) creates an m-by-n sparse matrix from the * columns of B and places them along the diagonals specified by d. * * Roughly, A, B and d are related by * for k = 1:p * B(:,k) = diag(A,d(k)) * end */ void spdiags(arma::mat &res1, arma::mat &res2, arma::mat arg1, arma::mat arg2 = arma::mat(0,0), int arg3 = 0, int arg4 = 0); } #endif // MATLAB_FUNC