14 static int ConstMatDestroy(
void*);
15 static int ConstMatView(
void*);
16 static int ConstMatVecVec(
void*,
double[],
int,
double *);
17 static int ConstMatDot(
void*,
double[],
int,
int,
double *);
18 static int ConstMatGetRank(
void*,
int*,
int);
19 static int ConstMatFactor(
void*);
20 static int ConstMatGetEig(
void*,
int,
double*,
double[],
int,
int[],
int*);
21 static int ConstMatRowNnz(
void*,
int,
int[],
int*,
int);
22 static int ConstMatAddRowMultiple(
void*,
int,
double,
double[],
int);
23 static int ConstMatAddMultiple(
void*,
double,
double[],
int,
int);
24 static int ConstMatTest(
void*);
30 #define __FUNCT__ "DSDPGetConstantMat" 31 int DSDPGetConstantMat(
int n,
double value,
char UPLQ,
struct DSDPDataMat_Ops**mops,
void**mmat){
35 AA=(cmat*) malloc(1*
sizeof(cmat));
36 if (AA==NULL)
return 1;
40 info=ConstMatOpsInitialize(&constantmatops);
if(info){
return 1;}
41 if (mops){*mops=&constantmatops;}
42 if (mmat){*mmat=(
void*)AA;}
43 DSDPFunctionReturn(0);
47 static int ConstMatDot(
void* A,
double x[],
int nn,
int n,
double *v){
68 static int ConstMatVecVec(
void* A,
double x[],
int n,
double *v){
77 *v=dtmp*dtmp*AA->cnst;
81 static int ConstMatAddMultiple(
void*A,
double dd,
double vv[],
int nn,
int n){
84 double ddd=dd*AA->cnst;
99 static int ConstMatAddRowMultiple(
void*A,
int nrow,
double dd,
double row[],
int n){
102 double ddd=dd*AA->cnst;
112 static int ConstMatFactor(
void*A){
116 static int ConstMatGetRank(
void *A,
int*rank,
int n){
121 static int ConstMatGetEig(
void*A,
int neig,
double *eig,
double v[],
int n,
int indx[],
int*nind){
124 if (neig!=0)
return 1;
126 for (i=0;i<n;i++){ v[i]=1.0; indx[i]=i;}
127 *eig=AA->cnst; *nind=n;
129 for (i=0;i<n;i++){ v[i]=0.0; }
136 static int ConstMatRowNnz(
void*A,
int row,
int nz[],
int *nnz,
int n){
138 for (i=0;i<n;i++){ nz[i]++; }
143 static int ConstMatFNorm2(
void*AA,
int n,
double *fnorm2){
145 *fnorm2=A->cnst*A->cnst*n*n;
149 static int ConstMatCountNonzeros(
void*A,
int *nnz,
int n){
157 static int ConstMatView(
void* AA){
159 printf(
"Every element of the matrix is the same: %10.8e\n",A->cnst);
163 static int ConstMatTest(
void* AA){
168 static int ConstMatDestroy(
void* A){
173 static const char *datamatname=
"ALL ELEMENTS THE SAME";
176 if (cmatops==NULL)
return 0;
178 cmatops->matfactor1=ConstMatFactor;
179 cmatops->matgetrank=ConstMatGetRank;
180 cmatops->matgeteig=ConstMatGetEig;
181 cmatops->matvecvec=ConstMatVecVec;
182 cmatops->matdot=ConstMatDot;
183 cmatops->mataddrowmultiple=ConstMatAddRowMultiple;
184 cmatops->mataddallmultiple=ConstMatAddMultiple;
185 cmatops->matdestroy=ConstMatDestroy;
186 cmatops->mattest=ConstMatTest;
187 cmatops->matview=ConstMatView;
188 cmatops->matrownz=ConstMatRowNnz;
189 cmatops->matfnorm2=ConstMatFNorm2;
190 cmatops->matnnz=ConstMatCountNonzeros;
192 cmatops->matname=datamatname;
Error handling, printing, and profiling.
int DSDPDataMatOpsInitialize(struct DSDPDataMat_Ops *dops)
Initialize the table of function pointers for SDP Data matrices.
Structure of function pointers that each SDP data matrix type (sparse, dense, constant,...
Table of function pointers that operate on the data matrix.