10 #define DSDPNoOperationError(a); { DSDPSETERR1(1,"Dual natrix type: %s, Operation not defined\n",(a).dsdpops->matname);} 11 #define DSDPChkDMatError(a,b); { if (b){ DSDPSETERR1(b,"Dual natrix type: %s,\n",(a).dsdpops->matname);} } 13 static int sdpdualsolve=0,sdpdualinvert=0;
16 #define __FUNCT__ "DSDPDualMatEventZero" 17 int DSDPDualMatEventZero(
void){
19 sdpdualinvert=0;sdpdualsolve=0;
20 DSDPFunctionReturn(0);
24 #define __FUNCT__ "DSDPDualMatEventInitialize" 25 int DSDPDualMatEventInitialize(
void){
27 if (sdpdualsolve==0){DSDPEventLogRegister(
"SDP SSolve",&sdpdualsolve);}
28 DSDPFunctionReturn(0);
32 #define __FUNCT__ "DSDPDualMatGetType" 36 DSDPFunctionReturn(0);
40 #define __FUNCT__ "DSDPDualMatSetData" 54 info=DSDPDualMatTest(*S);DSDPCHKERR(info);
55 DSDPFunctionReturn(0);
59 #define __FUNCT__ "DSDPDualMatDestroy" 68 if ( S && (*S).dsdpops && (*S).dsdpops->matdestroy){
69 info=((*S).dsdpops->matdestroy)((*S).matdata); DSDPChkDMatError(*S,info);
76 DSDPFunctionReturn(0);
80 #define __FUNCT__ "DSDPDualMatGetSize" 90 if (S.dsdpops->matgetsize){
91 info=(S.dsdpops->matgetsize)(S.matdata,n); DSDPChkDMatError(S,info);
93 DSDPNoOperationError(S);
95 DSDPFunctionReturn(0);
99 #define __FUNCT__ "DSDPDualMatGetArray" 100 int DSDPDualMatGetArray(
DSDPDualMat S,
double **v,
int *n){
103 if (S.dsdpops->matgetarray){
104 info=(S.dsdpops->matgetarray)(S.matdata,v,n); DSDPChkDMatError(S,info);
109 DSDPFunctionReturn(0);
114 #define __FUNCT__ "DSDPDualMatLogDeterminant" 125 if (S.dsdpops->matlogdet){
126 info=(S.dsdpops->matlogdet)(S.matdata,logdet); DSDPChkDMatError(S,info);
128 DSDPNoOperationError(S);
130 DSDPFunctionReturn(0);
134 #define __FUNCT__ "DSDPDualMatView" 143 if (S.dsdpops->matview){
144 info=(S.dsdpops->matview)(S.matdata); DSDPChkDMatError(S,info);
146 DSDPNoOperationError(S);
148 DSDPFunctionReturn(0);
153 #define __FUNCT__ "DSDPDualMatSetArray" 164 if (S.dsdpops->matseturmat){
167 info=(S.dsdpops->matseturmat)(S.matdata,ss,nn,n); DSDPChkDMatError(S,info);
170 DSDPNoOperationError(S);
172 DSDPFunctionReturn(0);
177 #define __FUNCT__ "DSDPDualMatInvert" 190 if (S.dsdpops->matinvert){
191 info=(S.dsdpops->matinvert)(S.matdata); DSDPChkDMatError(S,info);
193 DSDPNoOperationError(S);
196 DSDPFunctionReturn(0);
200 #define __FUNCT__ "DSDPDualMatInverseAdd" 213 if (S.dsdpops->matinverseadd){
216 info=(S.dsdpops->matinverseadd)(S.matdata,alpha,ss,nn,n); DSDPChkDMatError(S,info);
219 DSDPNoOperationError(S);
221 DSDPFunctionReturn(0);
226 #define __FUNCT__ "DSDPDualMatInverseMultiply" 240 DSDPEventLogBegin(sdpdualsolve);
241 if (S.dsdpops->matinversemultiply){
242 info=SDPConeVecGetSize(X,&n); DSDPCHKERR(info);
243 info=SDPConeVecGetArray(B,&bb); DSDPCHKERR(info);
244 info=SDPConeVecGetArray(X,&xx); DSDPCHKERR(info);
245 info=(S.dsdpops->matinversemultiply)(S.matdata,IS.indx+1,IS.indx[0],bb,xx,n); DSDPChkDMatError(S,info);
246 info=SDPConeVecRestoreArray(X,&xx); DSDPCHKERR(info);
247 info=SDPConeVecRestoreArray(B,&bb); DSDPCHKERR(info);
249 DSDPNoOperationError(S);
251 DSDPEventLogEnd(sdpdualsolve);
252 DSDPFunctionReturn(0);
257 #define __FUNCT__ "DSDPDualMatCholeskySolveForward" 271 if (S.dsdpops->matsolveforward){
272 info=SDPConeVecGetSize(X,&n); DSDPCHKERR(info);
273 info=SDPConeVecGetArray(B,&bb); DSDPCHKERR(info);
274 info=SDPConeVecGetArray(X,&xx); DSDPCHKERR(info);
275 info=(S.dsdpops->matsolveforward)(S.matdata,bb,xx,n); DSDPChkDMatError(S,info);
276 info=SDPConeVecRestoreArray(X,&xx); DSDPCHKERR(info);
277 info=SDPConeVecRestoreArray(B,&bb); DSDPCHKERR(info);
279 DSDPNoOperationError(S);
281 DSDPFunctionReturn(0);
285 #define __FUNCT__ "DSDPDualMatDualMatCholeskySolveBackward" 299 if (S.dsdpops->matsolvebackward){
300 info=SDPConeVecGetSize(X,&n); DSDPCHKERR(info);
301 info=SDPConeVecGetArray(B,&bb); DSDPCHKERR(info);
302 info=SDPConeVecGetArray(X,&xx); DSDPCHKERR(info);
303 info=(S.dsdpops->matsolvebackward)(S.matdata,bb,xx,n); DSDPChkDMatError(S,info);
304 info=SDPConeVecRestoreArray(X,&xx); DSDPCHKERR(info);
305 info=SDPConeVecRestoreArray(B,&bb); DSDPCHKERR(info);
307 DSDPNoOperationError(S);
309 DSDPFunctionReturn(0);
313 #define __FUNCT__ "DSDPDualMatCholeskyFactor" 324 if (S.dsdpops->matcholesky){
325 info=(S.dsdpops->matcholesky)(S.matdata,&flag); DSDPChkDMatError(S,info);
327 DSDPNoOperationError(S);
331 DSDPFunctionReturn(0);
336 #define __FUNCT__ "DSDPDualMatCholeskyForwardMultiply" 350 if (S.dsdpops->matforwardmultiply){
351 info=SDPConeVecGetSize(B,&n); DSDPCHKERR(info);
352 info=SDPConeVecGetArray(B,&bb); DSDPCHKERR(info);
353 info=SDPConeVecGetArray(X,&xx); DSDPCHKERR(info);
354 info=(S.dsdpops->matforwardmultiply)(S.matdata,bb,xx,n); DSDPChkDMatError(S,info);
355 info=SDPConeVecRestoreArray(X,&xx); DSDPCHKERR(info);
356 info=SDPConeVecRestoreArray(B,&bb); DSDPCHKERR(info);
358 DSDPNoOperationError(S);
360 DSDPFunctionReturn(0);
363 #define __FUNCT__ "DSDPDualMatCholeskyBackwardMultiply" 377 if (S.dsdpops->matbackwardmultiply){
378 info=SDPConeVecGetSize(B,&n); DSDPCHKERR(info);
379 info=SDPConeVecGetArray(B,&bb); DSDPCHKERR(info);
380 info=SDPConeVecGetArray(X,&xx); DSDPCHKERR(info);
381 info=(S.dsdpops->matbackwardmultiply)(S.matdata,bb,xx,n); DSDPChkDMatError(S,info);
382 info=SDPConeVecRestoreArray(X,&xx); DSDPCHKERR(info);
383 info=SDPConeVecRestoreArray(B,&bb); DSDPCHKERR(info);
385 DSDPNoOperationError(S);
387 DSDPFunctionReturn(0);
390 #define __FUNCT__ "DSDPDualMatIsFull" 401 if (S.dsdpops->matfull){
402 info=(S.dsdpops->matfull)(S.matdata,&flag); DSDPChkDMatError(S,info);
404 DSDPNoOperationError(S);
407 DSDPFunctionReturn(0);
411 #define __FUNCT__ "DSDPDataMatCheck" 414 DSDPFunctionReturn(0);
417 static const char* dualmatname=
"NOT SET YET";
424 if (sops==NULL)
return 0;
428 sops->matsolveforward=0;
429 sops->matsolvebackward=0;
431 sops->matinverseadd=0;
432 sops->matinversemultiply=0;
433 sops->matforwardmultiply=0;
434 sops->matbackwardmultiply=0;
440 sops->matname=dualmatname;
448 #define __FUNCT__ "DSDPDualMatTest" 452 if (S.dsdpops==0 || S.dsdpops==&dsdpdualmatopsdefault){
453 }
else if (S.dsdpops->mattest){
454 info=(S.dsdpops->mattest)(S.matdata); DSDPChkDMatError(S,info);
460 DSDPFunctionReturn(0);
465 #define __FUNCT__ "DSDPDualMatInitialize" 476 DSDPFunctionReturn(0);
int DSDPDualMatSetData(DSDPDualMat *S, struct DSDPDualMat_Ops *ops, void *data)
Set the opaque pointer and function pointers to the matrix.
int DSDPDualMatIsFull(DSDPDualMat S, DSDPTruth *full)
Factor the matrix.
DSDPTruth
Boolean variables.
int DSDPDualMatDestroy(DSDPDualMat *S)
Free the matrix structure.
int DSDPDualMatOpsInitialize(struct DSDPDualMat_Ops *sops)
Set pointers to null.
The interface between the SDPCone and the matrix S.
int DSDPVMatGetArray(DSDPVMat X, double **v, int *nn)
Get the array that stores the matrix.
int DSDPDualMatInverseMultiply(DSDPDualMat S, DSDPIndex IS, SDPConeVec B, SDPConeVec X)
Multiply the inverse by a vector or solve the system of equations.
Error handling, printing, and profiling.
int DSDPDualMatInverseAdd(DSDPDualMat S, double alpha, DSDPVMat T)
Add a multiple of the inverse to T.
int DSDPVMatGetSize(DSDPVMat X, int *n)
Get number of rows and columns.
int DSDPVMatRestoreArray(DSDPVMat X, double **v, int *nn)
Restore the array that stores the matrix.
int DSDPDualMatView(DSDPDualMat S)
Print the matrix.
int DSDPDualMatCholeskySolveBackward(DSDPDualMat S, SDPConeVec B, SDPConeVec X)
Backward triangular solve.
Vector whose length corresponds to dimension of a block in a cone.
Table of function pointers that operate on the S matrix.
int DSDPDualMatCholeskyBackwardMultiply(DSDPDualMat S, SDPConeVec B, SDPConeVec X)
Multiply by triangular matrix.
int DSDPDualMatCholeskySolveForward(DSDPDualMat S, SDPConeVec B, SDPConeVec X)
Forward triangular solve.
int DSDPDualMatInitialize(DSDPDualMat *S)
Set pointers to null.
int DSDPDualMatGetSize(DSDPDualMat S, int *n)
Free the matrix structure.
int DSDPDualMatInvert(DSDPDualMat S)
Invert the matrix.
int DSDPDualMatCholeskyFactor(DSDPDualMat S, DSDPTruth *psdefinite)
Factor the matrix.
int DSDPDualMatLogDeterminant(DSDPDualMat S, double *logdet)
Free the matrix structure.
Represents an S matrix for one block in the semidefinite cone.
int DSDPDualMatCholeskyForwardMultiply(DSDPDualMat S, SDPConeVec B, SDPConeVec X)
Multiply by triangular matrix.
int DSDPDualMatSetArray(DSDPDualMat S, DSDPVMat T)
Print the matrix.
Structure of function pointers that each symmetric positive definite matrix type (dense, sparse) must implement.
Dense symmetric matrix for one block in the semidefinite cone.