9#define SDPConeVecCheck(a,b) {if (a.dim != b.dim) return 1; if (a.dim>0 && (a.val==NULL || b.val==NULL) ) return 2;}
13#define __FUNCT__ "SDPConeVecCreate"
19 DSDPCALLOC2(&(V->val),
double,n,&info);DSDPCHKERR(info);
27#define __FUNCT__ "SDPConeVecDestroy"
31 DSDPFREE(&(*V).val,&info);DSDPCHKERR(info);
41#define __FUNCT__ "SDPConeVecView"
51 for (i=0; i<V.dim; i++){
52 printf(
"%3.3e ",V.val[i]);
59#define __FUNCT__ "SDPConeVecZero"
70 memset((
void*)v,0,n*
sizeof(
double));
76#define __FUNCT__ "SDPConeVecNormalize"
88 if (vnorm==0){
return 1;}
95#define __FUNCT__ "SDPConeVecCopy"
106 double *val1=v1.val,*val2=v2.val;
107 SDPConeVecCheck(v1,v2);
109 memcpy(val2,val1,n*
sizeof(
double));
116#define __FUNCT__ "SDPConeVecDot"
126 ffinteger ione=1, nn=V1.dim;
127 double *v1=V1.val,*v2=V2.val;
128 *ans=ddot(&nn,v1,&ione,v2,&ione);
129 if (*ans!=*ans)
return 1;
135#define __FUNCT__ "SDPConeVecNorm2"
144 ffinteger ione=1,nn=VV.dim;
146 dd=dnrm2(&nn,v,&ione);
148 if (*vnorm!=*vnorm)
return 1;
153#define __FUNCT__ "SDPConeVecScale"
162 ffinteger ione=1,nn=VV.dim;
164 dscal(&nn,&alpha,v,&ione);
169#define __FUNCT__ "SDPConeVecAXPY"
179 ffinteger ione=1,nn=x.dim;
180 double *yy=y.val,*xx=x.val;
181 if (alpha==0)
return 0;
182 daxpy(&nn,&alpha,xx,&ione,yy,&ione);
187#define __FUNCT__ "SDPConeVecDuplicate"
197 info = SDPConeVecCreate(n ,V2);DSDPCHKERR(info);
203#define __FUNCT__ "SDPConeVecSet"
217 memset((
void*)val,0,n*
sizeof(
double));
227#define __FUNCT__ "DSDPIndexInitialize"
237 DSDPFunctionReturn(0);
240#define __FUNCT__ "DSDPIndexCreate"
251 DSDPCALLOC2(&is,
int,n+1,&info);
253 DSDPFunctionReturn(0);
257#define __FUNCT__ "DSDPIndexDestroy"
267 DSDPFREE(&IS->indx,&info);DSDPCHKERR(info);
268 DSDPFunctionReturn(0);
272#define __FUNCT__ "DSDPIndexView"
282 printf(
"Index Set with %d indices.\n",IS.indx[0]);
283 for (i=0;i<IS.indx[0];i++){
284 printf(
" %d",IS.indx[i+1]);
287 DSDPFunctionReturn(0);
DSDP uses BLAS and LAPACK for many of its operations.
Error handling, printing, and profiling.
int SDPConeVecAXPY(double alpha, SDPConeVec x, SDPConeVec y)
Add a multiple of X to Y.
int SDPConeVecDuplicate(SDPConeVec V1, SDPConeVec *V2)
Allocate another vector with the same structure as the first.
int SDPConeVecNorm2(SDPConeVec VV, double *vnorm)
Compute the Euclidean norm.
int SDPConeVecCopy(SDPConeVec v1, SDPConeVec v2)
Copy v1 to v2.
int DSDPIndexDestroy(DSDPIndex *IS)
Deallocate memory.
int SDPConeVecView(SDPConeVec V)
Print the elements of the vector.
int DSDPIndexCreate(int n, DSDPIndex *IS)
Allocate array for indices.
int DSDPIndexView(DSDPIndex IS)
Print indices.
int SDPConeVecScale(double alpha, SDPConeVec VV)
Compute the Euclidean norm.
int SDPConeVecZero(SDPConeVec V)
Zero the elements of the vector.
int SDPConeVecDot(SDPConeVec V1, SDPConeVec V2, double *ans)
Inner product of two vectors.
int SDPConeVecNormalize(SDPConeVec V)
Scale the vector to norm of 1.
int SDPConeVecSet(double alpha, SDPConeVec V)
Set each element of vector to this number.
int DSDPIndexInitialize(DSDPIndex *IS)
Set structure pointers to 0.
Each block of the SDPCone has two vectors of appropriate size.
Vector whose length corresponds to dimension of a block in a cone.