9 #define DSDPNoOperationError(a); { DSDPSETERR1(1,"X Matrix type: %s, Operation not defined. Perhaps no X matrix has been set.\n",(a).dsdpops->matname); }
10 #define DSDPChkMatError(a,b); { if (b){ DSDPSETERR1(b,"X Matrix type: %s,\n",(a).dsdpops->matname);} }
12 static int sdpxmatevent=0;
15 #define __FUNCT__ "DSDPVMatEventZero"
16 int DSDPVMatEventZero(
void){
19 DSDPFunctionReturn(0);
23 #define __FUNCT__ "DSDPVMatEventInitialize"
24 int DSDPVMatEventInitialize(
void){
26 if (sdpxmatevent==0){DSDPEventLogRegister(
"SDP X+vv'",&sdpxmatevent);}
27 DSDPFunctionReturn(0);
31 #define __FUNCT__ "DSDPVMatSetData"
45 DSDPFunctionReturn(0);
49 #define __FUNCT__ "DSDPVMatGetType"
50 int DSDPVMatGetType(
DSDPVMat X,
int *
id){
53 DSDPFunctionReturn(0);
58 #define __FUNCT__ "DSDPVMatGetSize"
68 if (X.dsdpops->matgetsize){
69 info=(X.dsdpops->matgetsize)(X.matdata,n); DSDPChkMatError(X,info);
75 DSDPFunctionReturn(0);
80 #define __FUNCT__ "DSDPVMatDestroy"
89 if (!(*X).dsdpops){
return 0;}
90 if ((*X).dsdpops->matdestroy){
91 info=((*X).dsdpops->matdestroy)((*X).matdata); DSDPChkMatError(*X,info);
96 DSDPFunctionReturn(0);
101 #define __FUNCT__ "DSDPVMatView"
109 if (X.dsdpops->matview){
110 info=(X.dsdpops->matview)(X.matdata); DSDPChkMatError(X,info);
112 printf(
"No viewer available for matrix type: %d",X.dsdpops->id);
114 DSDPFunctionReturn(0);
119 #define __FUNCT__ "DSDPVMatZeroEntries"
128 if (X.dsdpops->matzeroentries){
129 info=(X.dsdpops->matzeroentries)(X.matdata); DSDPChkMatError(X,info);
131 DSDPNoOperationError(X);
133 DSDPFunctionReturn(0);
138 #define __FUNCT__ "DSDPVMatScaleDiagonal"
150 if (X.dsdpops->matscalediagonal){
151 info=(X.dsdpops->matscalediagonal)(X.matdata,dscale); DSDPChkMatError(X,info);
153 DSDPNoOperationError(X);
155 DSDPFunctionReturn(0);
159 #define __FUNCT__ "DSDPVMatShiftDiagonal"
169 if (X.dsdpops->matshiftdiagonal){
170 info=(X.dsdpops->matshiftdiagonal)(X.matdata,dadd); DSDPChkMatError(X,info);
172 DSDPNoOperationError(X);
174 DSDPFunctionReturn(0);
179 #define __FUNCT__ "DSDPVMatNormF2"
190 if (X.dsdpops->matfnorm2){
192 info=(X.dsdpops->matfnorm2)(X.matdata,n,normf2); DSDPChkMatError(X,info);
195 DSDPNoOperationError(X);
197 DSDPFunctionReturn(0);
202 #define __FUNCT__ "DSDPVMatGetArray"
214 if (X.dsdpops->matgeturarray){
215 info=(X.dsdpops->matgeturarray)(X.matdata,v,nn); DSDPChkMatError(X,info);
220 DSDPFunctionReturn(0);
224 #define __FUNCT__ "DSDPVMatRestoreArray"
236 if (X.dsdpops->matrestoreurarray){
237 info=(X.dsdpops->matrestoreurarray)(X.matdata,v,nn); DSDPChkMatError(X,info);
242 DSDPFunctionReturn(0);
247 #define __FUNCT__ "DSDPVMatMinEigenvalue"
252 if (X.dsdpops->matmineig){
253 info=SDPConeVecGetSize(W1,&n); DSDPCHKERR(info);
254 info=SDPConeVecGetArray(W1,&w); DSDPCHKERR(info);
255 info=SDPConeVecGetArray(W2,&iwork); DSDPCHKERR(info);
256 info=(X.dsdpops->matmineig)(X.matdata,w,iwork,n,mineig); DSDPChkMatError(X,info);
257 info=SDPConeVecRestoreArray(W1,&w); DSDPCHKERR(info);
258 info=SDPConeVecRestoreArray(W2,&iwork); DSDPCHKERR(info);
260 DSDPNoOperationError(X);
262 DSDPFunctionReturn(0);
267 #define __FUNCT__ "DSDPVMatAddOuterProduct"
279 DSDPEventLogBegin(sdpxmatevent);
280 info=SDPConeVecGetSize(V,&n); DSDPCHKERR(info);
281 if (X.dsdpops->mataddouterproduct){
282 info=SDPConeVecGetArray(V,&v); DSDPCHKERR(info);
283 info=(X.dsdpops->mataddouterproduct)(X.matdata,alpha,v,n); DSDPChkMatError(X,info);
284 info=SDPConeVecRestoreArray(V,&v); DSDPCHKERR(info);
286 DSDPNoOperationError(X);
288 DSDPEventLogEnd(sdpxmatevent);
289 DSDPFunctionReturn(0);
293 #define __FUNCT__ "DSDPVMatMult"
305 info=SDPConeVecGetSize(Y,&n); DSDPCHKERR(info);
306 if (X.dsdpops->matmult){
307 info=SDPConeVecGetArray(Z,&z); DSDPCHKERR(info);
308 info=SDPConeVecGetArray(Y,&y); DSDPCHKERR(info);
309 info=(X.dsdpops->matmult)(X.matdata,z,y,n); DSDPChkMatError(X,info);
310 info=SDPConeVecRestoreArray(Z,&z); DSDPCHKERR(info);
311 info=SDPConeVecRestoreArray(Y,&y); DSDPCHKERR(info);
313 DSDPNoOperationError(X);
315 DSDPFunctionReturn(0);
319 #define __FUNCT__ "DSDPVMatCheck"
329 double *xx,eig,eps=1e-13,one=1.0;
330 double fnorm0,fnorm1,fnorm2,fnorm3,fnorm4;
337 if (fabs(fnorm0)>eps){ printf(
"Check DSDPVMatZero of DSDPVMatNorm\n");}
342 if (fabs(fnorm1-n*n)>eps) printf(
"Check DSDPVMatZero()\n");
345 for (i=0;i<nn;i++){xx[i]=1.0;}
348 if (fabs(fnorm2-n*n)>eps) printf(
"Check DSDPXGetArray()\n");
363 info=DSDPVMatMinEigenvalue(X,W1,W2,&eig);DSDPCHKERR(info);
364 if (fabs(fnorm0)>eps) printf(
"Check DSDPVMatZero()\n");
365 DSDPFunctionReturn(0);
369 static const char *urmatname=
"NOT SET YET";
371 #define __FUNCT__ "DSDPVMatOpsInitialize"
379 aops->matzeroentries=0;
381 aops->mataddouterproduct=0;
383 aops->matgeturarray=0;
384 aops->matrestoreurarray=0;
388 aops->matshiftdiagonal=0;
389 aops->matscalediagonal=0;
391 aops->matname=urmatname;
396 #define __FUNCT__ "DSDPVMatTest"
405 if (X.dsdpops==0 || X.dsdpops==&dsdpmatops2){
406 }
else if (X.dsdpops->mattest){
407 info=(X.dsdpops->mattest)(X.matdata); DSDPChkMatError(X,info);
413 DSDPFunctionReturn(0);
418 #define __FUNCT__ "DSDPVMatInitialize"
429 DSDPFunctionReturn(0);
433 #define __FUNCT__ "DSDPVMatExist"
442 if (X.dsdpops && X.dsdpops!=&dsdpmatops2) *flag=1;
444 DSDPFunctionReturn(0);