⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vech.c

📁 利用matlab软件进行程序设计的GARCH以及多元GARCH模型的源程序工具箱。
💻 C
字号:
/* Change this to reflect the apropriate header file */
#include "mex.h"
#include <math.h>

/*
* vech.c
* This is a helper function and is part of the UCSD_MVGARCH toolbox
* You can compile it and should work on any platform.
*
* Author: Kevin Sheppard
* kevin.sheppard@economics.ox.ac.uk
* Revision: 2    Date: 12/31/2001
*/
void vech(double *parameters, double *matrix,int m)
{
	int i, j, step;
	int count=0;
	for (i=0;i<m;i++){
		step=i*m;
		for (j=i;j<m;j++){
			*(parameters+count)=*(matrix+step+j);
		count++;
		}
	}
}


/* The gateway routine */
void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
	double *parameters, *matrix;
	int mrows,ncols, outsize;

	/*  Check for proper number of arguments. */
	if(nrhs!=1)
		mexErrMsgTxt("One inputs required.");
	if(nlhs!=1)
		mexErrMsgTxt("One output required.");

	/*  Create a pointer to the input matrices . */
	matrix = mxGetPr(prhs[0]);


	/*  Get the dimensions of the matrix input ht to make an output matrix. */
	mrows  = mxGetM(prhs[0]);
	ncols  = mxGetN(prhs[0]);

	if(ncols!=mrows)
		mexErrMsgTxt("Square Matrix required.");


	/*  Set the output pointer to the output matrix. */
	outsize = mrows*(mrows+1)/2;
	plhs[0] = mxCreateDoubleMatrix(outsize , 1 , mxREAL);

	/*  Create a C pointer to a copy of the output matrix. */
	parameters = mxGetPr(plhs[0]);


	/*  Call the C subroutine. */
	vech(parameters, matrix, mrows);

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -