dsdpadddatamat.c
Go to the documentation of this file.
#include "dsdpdatamat.h"
#include "dsdpsys.h"
#include "dsdp5.h"
extern int DSDPGetZeroDataMatOps(struct DSDPDataMat_Ops**);
extern int DSDPGetConstantMat(int,double,char,struct DSDPDataMat_Ops**,void**);
extern int DSDPGetVechMat(int,int,double,const int[], const double[],int, struct DSDPDataMat_Ops**,void**);
extern int DSDPGetVecUMat(int,int,double,const int[], const double[],int, struct DSDPDataMat_Ops**,void**);
extern int DSDPGetIdentityDataMatP(int,double,struct DSDPDataMat_Ops**,void**);
extern int DSDPGetIdentityDataMatF(int,double,struct DSDPDataMat_Ops**,void**);
extern int DSDPGetDMat(int,double,double[],struct DSDPDataMat_Ops**,void**);
extern int DSDPGetR1PMat(int,double,int,const int[],const double[],int,struct DSDPDataMat_Ops**,void**);
extern int DSDPGetR1UMat(int,double,int,const int[],const double[],int,struct DSDPDataMat_Ops**,void**);
extern int SDPConeAddDataMatrix(SDPCone,int, int, int, char, struct DSDPDataMat_Ops*, void*);
extern int SDPConeSetRMatrix(SDPCone,int,int,char,struct DSDPDataMat_Ops*,void*);
#undef __FUNCT__
#define __FUNCT__ "SDPConeAddASparseVecMat"
int SDPConeAddASparseVecMat(SDPCone sdpcone,int blockj, int vari, int n,
double alpha, int ishift,
const int ind[], const double val[], int nnz){
int info;
char UPLQ;
void* dmat=0;
struct DSDPDataMat_Ops* dmatops=0;
DSDPFunctionBegin;
info=SDPConeGetStorageFormat(sdpcone,blockj,&UPLQ); DSDPCHKERR(info);
DSDPLogInfo(0,20,"Set sparse matrix: Block: %d, Variable %d, size: %d, Nonzeros: %d .\n",blockj,vari,n,nnz);
switch (UPLQ){
case 'P':
info=DSDPGetVechMat(n,ishift,alpha,ind,val,nnz,&dmatops,&dmat); DSDPCHKERR(info);
break;
case 'U':
info=DSDPGetVecUMat(n,ishift,alpha,ind,val,nnz,&dmatops,&dmat); DSDPCHKERR(info);
break;
}
info=SDPConeAddDataMatrix(sdpcone,blockj,vari,n,UPLQ,dmatops,dmat); DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "SDPConeAddSparseVecMat"
/* Needed for backward compatibility */
int SDPConeAddSparseVecMat(SDPCone sdpcone,int blockj, int vari, int n,
int ishift,const int ind[], const double val[], int nnz){
int info;
DSDPFunctionBegin;
info= SDPConeAddASparseVecMat(sdpcone,blockj,vari,n,
1.0,ishift,ind,val,nnz);DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "SDPConeSetASparseVecMat"
int SDPConeSetASparseVecMat(SDPCone sdpcone,int blockj, int vari, int n,
double alpha,int ishift,
const int ind[], const double val[], int nnz){
int info;
DSDPFunctionBegin;
info=SDPConeRemoveDataMatrix(sdpcone,blockj,vari); DSDPCHKERR(info);
info=SDPConeAddASparseVecMat(sdpcone,blockj,vari,n,alpha,ishift,ind,val,nnz); DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "SDPConeSetSparseVecMat"
/* Needed for backward compatibility */
int SDPConeSetSparseVecMat(SDPCone sdpcone,int blockj, int vari, int n,
int ishift,const int ind[], const double val[], int nnz){
int info;
DSDPFunctionBegin;
info=SDPConeSetASparseVecMat(sdpcone,blockj,vari,n,1.0,ishift,ind,val,nnz); DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "SDPConeAddADenseVecMat"
int SDPConeAddADenseVecMat(SDPCone sdpcone,int blockj, int vari,int n,
double alpha,double val[], int nnz){
int info;
char UPLQ;
void* dmat=0;
struct DSDPDataMat_Ops* dmatops=0;
DSDPFunctionBegin;
info=SDPConeGetStorageFormat(sdpcone,blockj,&UPLQ); DSDPCHKERR(info);
DSDPLogInfo(0,20,"Set dense matrix: Block: %d, Variable %d, size: %d, Nonzeros: %d .\n",blockj,vari,n,nnz);
switch (UPLQ){
case 'P':
info=DSDPGetDMat(n,alpha,val,&dmatops,&dmat); DSDPCHKERR(info);
break;
case 'U':
DSDPSETERR(1,"Dense U Mat type does not exist.\n");
break;
}
info=SDPConeAddDataMatrix(sdpcone,blockj,vari,n,UPLQ,dmatops,dmat); DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "SDPConeAddDenseVecMat"
/* Needed for backward compatibility */
int SDPConeAddDenseVecMat(SDPCone sdpcone,int blockj, int vari,int n,
double val[], int nnz){
int info;
DSDPFunctionBegin;
info=SDPConeAddADenseVecMat(sdpcone,blockj,vari,n,1.0,val,nnz); DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "SDPConeSetADenseVecMat"
int SDPConeSetADenseVecMat(SDPCone sdpcone,int blockj, int vari,int n,
double alpha,double val[], int nnz){
int info;
DSDPFunctionBegin;
info=SDPConeRemoveDataMatrix(sdpcone,blockj,vari); DSDPCHKERR(info);
info=SDPConeAddADenseVecMat(sdpcone,blockj,vari,n,alpha,val,nnz); DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "SDPConeSetDenseVecMat"
/* Needed for backward compatibility */
int SDPConeSetDenseVecMat(SDPCone sdpcone,int blockj, int vari,int n,
double val[], int nnz){
int info;
DSDPFunctionBegin;
info=SDPConeSetADenseVecMat(sdpcone,blockj,vari,n,1.0,val,nnz); DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "SDPConeAddIdentity"
int SDPConeAddIdentity(SDPCone sdpcone, int blockj,int vari, int n,
double val){
int info;
char UPLQ;
struct DSDPDataMat_Ops* identitymatops=0;
void* imat=0;
DSDPFunctionBegin;
DSDPLogInfo(0,20,"Set identity matrix: Block: %d, Variable %d, size: %d, Multiple: %4.4e .\n",blockj,vari,n,val);
info=SDPConeGetStorageFormat(sdpcone,blockj,&UPLQ); DSDPCHKERR(info);
switch (UPLQ){
case 'P':
info=DSDPGetIdentityDataMatP(n,val,&identitymatops,&imat);DSDPCHKERR(info);
break;
case 'U':
info=DSDPGetIdentityDataMatF(n,val,&identitymatops,&imat);DSDPCHKERR(info);
break;
}
info=SDPConeAddDataMatrix(sdpcone,blockj,vari,n,UPLQ,identitymatops,imat); DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "SDPConeSetIdentity"
int SDPConeSetIdentity(SDPCone sdpcone, int blockj, int vari, int n,
double val){
int info;
DSDPFunctionBegin;
info=SDPConeRemoveDataMatrix(sdpcone,blockj,vari); DSDPCHKERR(info);
info=SDPConeAddIdentity(sdpcone,blockj,vari,n,val); DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "SDPConeAddConstantMat"
int SDPConeAddConstantMat(SDPCone sdpcone,int blockj, int vari, int n,
double value){
int info;
char UPLQ;
struct DSDPDataMat_Ops* constantmatops=0;
void* smat=0;
DSDPFunctionBegin;
DSDPLogInfo(0,20,"Add allsame matrix: Block: %d, Variable %d, size: %d, Elements: %4.4e .\n",blockj,vari,n,value);
info=SDPConeGetStorageFormat(sdpcone,blockj,&UPLQ); DSDPCHKERR(info);
switch (UPLQ){
case 'P':
info=DSDPGetConstantMat(n,value,UPLQ,&constantmatops,&smat);DSDPCHKERR(info);
break;
case 'U':
info=DSDPGetConstantMat(n,value,UPLQ,&constantmatops,&smat);DSDPCHKERR(info);
break;
}
info=SDPConeAddDataMatrix(sdpcone,blockj,vari,n,UPLQ,constantmatops,smat); DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "SDPConeSetConstantMat"
int SDPConeSetConstantMat(SDPCone sdpcone,int blockj, int vari, int n,
double value){
int info;
DSDPFunctionBegin;
info=SDPConeRemoveDataMatrix(sdpcone,blockj,vari); DSDPCHKERR(info);
info=SDPConeAddConstantMat(sdpcone,blockj,vari,n,value); DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "SDPConeSetZeroMat"
int SDPConeSetZeroMat(SDPCone sdpcone,int blockj, int vari, int n){
int info;
char UPLQ;
struct DSDPDataMat_Ops* zeromatops=0;
DSDPFunctionBegin;
DSDPLogInfo(0,20,"Add zero matrix: Block: %d, Variable %d, size: %d .\n",blockj,vari,n);
info=DSDPGetZeroDataMatOps(&zeromatops); DSDPCHKERR(info);
info=SDPConeGetStorageFormat(sdpcone,blockj,&UPLQ); DSDPCHKERR(info);
info=SDPConeRemoveDataMatrix(sdpcone,blockj,vari); DSDPCHKERR(info);
info=SDPConeAddDataMatrix(sdpcone,blockj,vari,n,UPLQ,zeromatops,0); DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "SDPConeSetRIdentity"
int SDPConeSetRIdentity(SDPCone sdpcone,int blockj, int n, double rr){
int info;
char UPLQ;
struct DSDPDataMat_Ops* identitymatops=0;
void* imat=0;
DSDPFunctionBegin;
info=SDPConeGetStorageFormat(sdpcone,blockj,&UPLQ); DSDPCHKERR(info);
switch (UPLQ){
case 'P':
info=DSDPGetIdentityDataMatP(n,rr,&identitymatops,&imat);DSDPCHKERR(info); break;
case 'U':
info=DSDPGetIdentityDataMatF(n,rr,&identitymatops,&imat);DSDPCHKERR(info); break;
default:
break;
}
info=SDPConeSetRMatrix(sdpcone,blockj,n,UPLQ,identitymatops,imat); DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "SDPConeAddARankOneMat"
int SDPConeAddARankOneMat(SDPCone sdpcone,int blockj, int vari, int n,
double alpha, int ishift,const int ind[], const double val[], int nnz){
int info;
char UPLQ;
void* dmat=0;
struct DSDPDataMat_Ops* dmatops=0;
DSDPFunctionBegin;
info=SDPConeGetStorageFormat(sdpcone,blockj,&UPLQ); DSDPCHKERR(info);
DSDPLogInfo(0,20,"Set sparse matrix: Block: %d, Variable %d, size: %d, Nonzeros: %d .\n",blockj,vari,n,nnz);
switch (UPLQ){
case 'P':
info=DSDPGetR1PMat(n,alpha,ishift,ind,val,nnz,&dmatops,&dmat); DSDPCHKERR(info);
break;
case 'U':
info=DSDPGetR1UMat(n,alpha,ishift,ind,val,nnz,&dmatops,&dmat); DSDPCHKERR(info);
break;
}
info=SDPConeAddDataMatrix(sdpcone,blockj,vari,n,UPLQ,dmatops,dmat); DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "SDPConeSetARankOneMat"
int SDPConeSetARankOneMat(SDPCone sdpcone,int blockj, int vari, int n,
double alpha, int ishift,const int ind[], const double val[], int nnz){
int info;
DSDPFunctionBegin;
info=SDPConeRemoveDataMatrix(sdpcone,blockj,vari); DSDPCHKERR(info);
info=SDPConeAddARankOneMat(sdpcone,blockj,vari,n,alpha,ishift,ind,val,nnz); DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPSetDataMatZero"
int DSDPSetDataMatZero(DSDPDataMat *A){
int info;
struct DSDPDataMat_Ops* zeromatops=0;
DSDPFunctionBegin;
info=DSDPGetZeroDataMatOps(&zeromatops); DSDPCHKERR(info);
info=DSDPDataMatSetData(A,zeromatops,0);DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
dsdp5.h
The API to DSDP for those applications using DSDP as a subroutine library.
DSDPGetVecUMat
int DSDPGetVecUMat(int, int, double, const int[], const double[], int, struct DSDPDataMat_Ops **, void **)
Given data in full symmetric format, create a sparse matrix usuable by DSDP.
Definition vechu.c:454
DSDPGetR1UMat
int DSDPGetR1UMat(int, double, int, const int[], const double[], int, struct DSDPDataMat_Ops **, void **)
Create a rank one matrix usuable by DSDP in full symmetric format.
Definition rmmat.c:101
SDPConeSetRMatrix
int SDPConeSetRMatrix(SDPCone, int, int, char, struct DSDPDataMat_Ops *, void *)
Add identity to dual matrix.
Definition dsdpadddata.c:181
DSDPGetVechMat
int DSDPGetVechMat(int, int, double, const int[], const double[], int, struct DSDPDataMat_Ops **, void **)
Given data in packed symmetric format, create a sparse matrix usuable by DSDP.
Definition vech.c:460
DSDPGetIdentityDataMatF
int DSDPGetIdentityDataMatF(int, double, struct DSDPDataMat_Ops **, void **)
Create a sparse matrix usuable by DSDP in full symmetric format.
Definition identity.c:69
SDPConeSetRIdentity
int SDPConeSetRIdentity(SDPCone sdpcone, int blockj, int n, double rr)
Add identify matrix to dual matrix.
Definition dsdpadddatamat.c:438
DSDPSetDataMatZero
int DSDPSetDataMatZero(DSDPDataMat *A)
Make a data matrix a zero matrix.
Definition dsdpadddatamat.c:537
DSDPGetIdentityDataMatP
int DSDPGetIdentityDataMatP(int, double, struct DSDPDataMat_Ops **, void **)
Create a sparse matrix usuable by DSDP in packed symmetric format.
Definition identity.c:44
DSDPGetR1PMat
int DSDPGetR1PMat(int, double, int, const int[], const double[], int, struct DSDPDataMat_Ops **, void **)
Create a rank one matrix usuable by DSDP in packed symmetric format.
Definition rmmat.c:77
DSDPDataMatSetData
int DSDPDataMatSetData(DSDPDataMat *A, struct DSDPDataMat_Ops *ops, void *data)
Set the opaque pointer and function pointers to the matrix.
Definition dsdpdatamat.c:25
dsdpdatamat.h
The interface between the SDPCone and the data matrices.
dsdpsys.h
Error handling, printing, and profiling.
DSDPDataMat_C
Symmetric data matrix for one block in the semidefinite cone.
Definition dsdpdatamat.h:15
DSDPDataMat_Ops
Table of function pointers that operate on the data matrix.
Definition dsdpdatamat_impl.h:15
SDPCone_C
Internal structure for semidefinite cone.
Definition dsdpsdp.h:80