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

📄 mexexpand_71.c

📁 这事很不错的半定规划matlab软件,this is the important software of SDP.
💻 C
字号:
/***********************************************************************
* mexexpand.c : C mex file 
*
*   z = mexexpand(blk,x); 
* 
*   Input: blk   = [n1, n2, ..., nk]
*
*   Output: [x1 x1...x1  x2 x2 ... x2 .... xk xk ...xk]'    
*            n1          n2                nk
*
* SDPT3: version 3.0
* Copyright (c) 1997 by
* K.C. Toh, M.J. Todd, R.H. Tutuncu
* Last Modified: 2 Feb 01   
***********************************************************************/

#include <math.h>
#include <mex.h>

#if !defined(MAX)
#define  MAX(A, B)   ((A) > (B) ? (A) : (B))
#endif

/**********************************************************
* 
***********************************************************/
void mexFunction(
      int nlhs,   mxArray  *plhs[], 
      int nrhs,   const mxArray  *prhs[] )

{    
     double   *blksize, *x, *z; 
     int      k, l, blkdim, numblk, cols, idx;

/* CHECK FOR PROPER NUMBER OF ARGUMENTS */

   if (nrhs != 2){
      mexErrMsgTxt("mexexpand: requires 2 input arguments."); }
   if (nlhs > 1){ 
      mexErrMsgTxt("mexexpand: requires 1 output argument."); }

/* CHECK THE DIMENSIONS */

    numblk = MAX(mxGetM(prhs[0]),mxGetN(prhs[0])); 
    blksize = mxGetPr(prhs[0]);
    cols = 0; 
    for (k=0; k<numblk; k++) { 
        cols = cols + (int)blksize[k]; 
    } 
    x = mxGetPr(prhs[1]); 
    if (MAX(mxGetM(prhs[1]),mxGetN(prhs[1])) != numblk) {
        mexErrMsgTxt("mexexpand: size of blk and x incompatible."); }
    plhs[0] = mxCreateDoubleMatrix(cols,1,mxREAL); 
    z = mxGetPr(plhs[0]);    

    idx = 0; 
    for (k=0; k<numblk; k++) { 
       blkdim = (int)blksize[k]; 
       for (l=0; l<blkdim; l++) { z[idx] = x[k]; idx++; }
    }
    return;
 }
/**********************************************************/

⌨️ 快捷键说明

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