/*********************************************************************** * mexskron.c : * Find the matrix presentation of * symmetric kronecker product skron(A,B), where * A,B are symmetric. * * K = mexskron(blk,A,B,sym); * * sym = 1 if A=B * = 0 otherwise * * (ij)-column = 0.5*svec(AUB + BUA)*xij, where * xij = 1/2 if i=j * = 1/sqrt(2) otherwise * U = ei*ej' + ej*ei'. * * SDPT3: version 3.0 * Copyright (c) 1997 by * K.C. Toh, M.J. Todd, R.H. Tutuncu * Last Modified: 2 Feb 01 ***********************************************************************/ #include #include #if !defined(MAX) #define MAX(A, B) ((A) > (B) ? (A) : (B)) #endif #if !defined(r2) #define r2 1.41421356237309504880 /* sqrt(2) */ #endif #if !defined(ir2) #define ir2 0.70710678118654752440 /* 1/sqrt(2) */ #endif /********************************************************** * A, B may not be equal ***********************************************************/ void skron(int n, int maxblksize, double *P, double *Q, double *x1, double *y1, double *x2, double *y2, int r, int c, double *vvtmp) { int idx, i, j, k, rn, cn; double tmp, tmp1, tmp2, tmp3, tmp4; double hf=0.5; rn = r*maxblksize; cn = c*maxblksize; for (k=0; k 1) { mexErrMsgTxt("mexskron: blk can only have 1 row."); } if (mxGetN(prhs[0]) != 2) { mexErrMsgTxt("mexskron: blk must have 2 columns."); } subs[0] = 0; subs[1] = 1; index = mxCalcSingleSubscript(prhs[0],nsubs,subs); blk_cell_pr = mxGetCell(prhs[0],index); numblk = mxGetN(blk_cell_pr); blksizetmp = mxGetPr(blk_cell_pr); blksize = (int*)mxCalloc(numblk,sizeof(int)); for (k=0; k