dsdpdsmat.c
Go to the documentation of this file.
#include "dsdpdsmat_impl.h"
#include "dsdpdsmat.h"
#include "dsdpsys.h"
#define DSDPNoOperationError(a); { DSDPSETERR1(1,"Delta S Matrix type: %s, Operation not defined\n",(a).dsdpops->matname); }
#define DSDPChkMatError(a,b); { if (b){ DSDPSETERR1(b,"Delta S Matrix type: %s,\n",(a).dsdpops->matname); } }
#undef __FUNCT__
#define __FUNCT__ "DSDPDSMatGetType"
int DSDPDSMatGetType(DSDPDSMat A, int *id){
DSDPFunctionBegin;
*id=A.dsdpops->id;
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPDSMatSetData"
int DSDPDSMatSetData(DSDPDSMat *M, struct DSDPDSMat_Ops* ops, void*data){
int info;
DSDPFunctionBegin;
(*M).dsdpops=ops;
(*M).matdata=data;
info=DSDPDSMatTest(*M); DSDPChkMatError(*M,info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPDSMatGetSize"
int DSDPDSMatGetSize(DSDPDSMat A,int*n){
int info;
DSDPFunctionBegin;
if (A.dsdpops->matgetsize){
info=(A.dsdpops->matgetsize)(A.matdata,n); DSDPChkMatError(A,info);
} else {
DSDPNoOperationError(A);
}
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPDSMatDestroy"
int DSDPDSMatDestroy(DSDPDSMat *A){
int info;
DSDPFunctionBegin;
if (!(*A).dsdpops){ return 0;}
if ((*A).dsdpops->matdestroy){
info=((*A).dsdpops->matdestroy)((*A).matdata); DSDPChkMatError(*A,info);
} else {
/* DSDPNoOperationError(1); */
}
info=DSDPDSMatInitialize(A); DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPDSMatView"
int DSDPDSMatView(DSDPDSMat A){
int info;
if (A.dsdpops->matview){
info=(A.dsdpops->matview)(A.matdata); DSDPChkMatError(A,info);
} else {
printf("No viewer available for matrix type: %s",A.dsdpops->matname);
}
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPDSMatZeroEntries"
int DSDPDSMatZeroEntries(DSDPDSMat A){
int info;
DSDPFunctionBegin;
if (A.dsdpops->matzeroentries){
info=(A.dsdpops->matzeroentries)(A.matdata); DSDPChkMatError(A,info);
} else {
DSDPNoOperationError(A);
}
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPDSMatSetArray"
int DSDPDSMatSetArray(DSDPDSMat A, DSDPVMat T){
int info,n,nn;
double *ds;
DSDPFunctionBegin;
if (A.dsdpops->matseturmat){
info=DSDPVMatGetSize(T,&n);DSDPCHKERR(info);
info=DSDPVMatGetArray(T, &ds, &nn); DSDPCHKERR(info);
info=(A.dsdpops->matseturmat)(A.matdata,ds,nn,n); DSDPChkMatError(A,info);
info=DSDPVMatRestoreArray(T, &ds, &nn); DSDPCHKERR(info);
} else {
DSDPNoOperationError(A);
}
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPDSMatMult"
int DSDPDSMatMult(DSDPDSMat A, SDPConeVec X, SDPConeVec Y){
int n,info;
double *x,*y;
DSDPFunctionBegin;
if (A.dsdpops->matmult){
info=SDPConeVecGetArray(X,&x); DSDPCHKERR(info);
info=SDPConeVecGetArray(Y,&y); DSDPCHKERR(info);
info=SDPConeVecGetSize(Y,&n); DSDPCHKERR(info);
info=(A.dsdpops->matmult)(A.matdata,x,y,n); DSDPChkMatError(A,info);
info=SDPConeVecRestoreArray(X,&x); DSDPCHKERR(info);
info=SDPConeVecRestoreArray(Y,&y); DSDPCHKERR(info);
} else {
DSDPNoOperationError(A);
}
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPDSVecVec"
int DSDPDSMatVecVec(DSDPDSMat A, SDPConeVec X, double *vAv){
int n,info;
double *x;
DSDPFunctionBegin;
if (A.dsdpops->matvecvec){
info=SDPConeVecGetArray(X,&x); DSDPCHKERR(info);
info=SDPConeVecGetSize(X,&n); DSDPCHKERR(info);
info=(A.dsdpops->matvecvec)(A.matdata,x,n,vAv); DSDPChkMatError(A,info);
info=SDPConeVecRestoreArray(X,&x); DSDPCHKERR(info);
} else {
DSDPNoOperationError(A);
}
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPDSMatCheck"
int DSDPDSMatCheck(DSDPDSMat DS,SDPConeVec W1,SDPConeVec W2,DSDPVMat T){
DSDPFunctionBegin;
DSDPFunctionReturn(0);
}
static struct DSDPDSMat_Ops dsdpmatops2;
static const char* dsmatname="NOT SET YET";
#undef __FUNCT__
#define __FUNCT__ "DSDPDSMatOpsInitialize"
int DSDPDSMatOpsInitialize(struct DSDPDSMat_Ops*aops){
aops->matseturmat=0;
aops->matview=0;
aops->matdestroy=0;
aops->matgetsize=0;
aops->matzeroentries=0;
aops->matmult=0;
aops->mattest=0;
aops->matvecvec=0;
aops->id=0;
aops->matname=dsmatname;
return 0;
}
#undef __FUNCT__
#define __FUNCT__ "DSDPDSMatTest"
int DSDPDSMatTest(DSDPDSMat A){
int info;
DSDPFunctionBegin;
if (A.dsdpops==0 || A.dsdpops==&dsdpmatops2){
} else if (A.dsdpops->mattest){
DSDPLogInfo(0,120,"Start to set DS Matrix\n");
info=(A.dsdpops->mattest)(A.matdata); DSDPChkMatError(A,info);
DSDPLogInfo(0,120,"Done set DS Matrix\n");
} else {
/*
DSDPNoOperationError(A);
*/
}
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPDSMatInitialize"
int DSDPDSMatInitialize(DSDPDSMat *B){
int info;
DSDPFunctionBegin;
info=DSDPDSMatOpsInitialize(&dsdpmatops2); DSDPCHKERR(info);
info=DSDPDSMatSetData(B, &dsdpmatops2, 0); DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
DSDPDSMatVecVec
int DSDPDSMatVecVec(DSDPDSMat A, SDPConeVec X, double *vAv)
Compute the product x' A x.
Definition dsdpdsmat.c:181
DSDPDSMatSetArray
int DSDPDSMatSetArray(DSDPDSMat A, DSDPVMat T)
Set values into the matrix.
Definition dsdpdsmat.c:130
DSDPDSMatView
int DSDPDSMatView(DSDPDSMat A)
Print the matrix.
Definition dsdpdsmat.c:92
DSDPDSMatSetData
int DSDPDSMatSetData(DSDPDSMat *M, struct DSDPDSMat_Ops *ops, void *data)
Set the opaque pointer and function pointers to the matrix.
Definition dsdpdsmat.c:31
DSDPDSMatOpsInitialize
int DSDPDSMatOpsInitialize(struct DSDPDSMat_Ops *aops)
Set pointers to null.
Definition dsdpdsmat.c:214
DSDPDSMatGetSize
int DSDPDSMatGetSize(DSDPDSMat A, int *n)
Set the opaque pointer and function pointers to the matrix.
Definition dsdpdsmat.c:50
DSDPDSMatDestroy
int DSDPDSMatDestroy(DSDPDSMat *A)
Free the data structure.
Definition dsdpdsmat.c:70
DSDPDSMatZeroEntries
int DSDPDSMatZeroEntries(DSDPDSMat A)
Zero the entries in the matrix.
Definition dsdpdsmat.c:110
DSDPDSMatMult
int DSDPDSMatMult(DSDPDSMat A, SDPConeVec X, SDPConeVec Y)
Set values into the matrix.
Definition dsdpdsmat.c:154
DSDPDSMatInitialize
int DSDPDSMatInitialize(DSDPDSMat *B)
Set pointers to null.
Definition dsdpdsmat.c:254
dsdpdsmat.h
The interface between the SDPCone and the Delta S matrix.
dsdpdsmat_impl.h
Structure of function pointers that each SDP Delta S matrix type (sparse, dense, diagonal,...
dsdpsys.h
Error handling, printing, and profiling.
DSDPVMatGetArray
int DSDPVMatGetArray(DSDPVMat X, double **v, int *nn)
Get the array that stores the matrix.
Definition dsdpxmat.c:211
DSDPVMatGetSize
int DSDPVMatGetSize(DSDPVMat X, int *n)
Get number of rows and columns.
Definition dsdpxmat.c:65
DSDPVMatRestoreArray
int DSDPVMatRestoreArray(DSDPVMat X, double **v, int *nn)
Restore the array that stores the matrix.
Definition dsdpxmat.c:233
DSDPDSMat_C
Symmetric Delta S matrix for one block in the semidefinite cone.
Definition dsdpdsmat.h:23
DSDPDSMat_Ops
Symmetric Delta S matrix for one block in the semidefinite cone.
Definition dsdpdsmat_impl.h:15
DSDPVMat_C
Dense symmetric matrix for one block in the semidefinite cone.
Definition dsdpxmat.h:17
SDPConeVec_C
Vector whose length corresponds to dimension of a block in a cone.
Definition sdpconevec.h:13