dsdpschurmatadd.c
Go to the documentation of this file.
#include "dsdpschurmat_impl.h"
#include "dsdpschurmat.h"
#include "dsdpbasictypes.h"
#include "dsdpsys.h"
#define DSDPNoOperationError(a); { DSDPSETERR1(10,"Schur matrix type: %s, Operation not defined\n",(a).dsdpops->matname); }
#define DSDPChkMatError(a,b); { if (b){ DSDPSETERR1(b,"Schur matrix type: %s,\n",(a).dsdpops->matname);} }
#undef __FUNCT__
#define __FUNCT__ "DSDPSchurMatRowColumnScaling"
int DSDPSchurMatRowColumnScaling(DSDPSchurMat M,int row, DSDPVec V, int *nzcols){
int info,m;
double *cols,r=M.schur->r;
DSDPTruth flag;
DSDPFunctionBegin;
info=DSDPVecSet(0.0,V);DSDPCHKERR(info);
info=DSDPVecGetSize(V,&m);DSDPCHKERR(info);
if (row==0){info=DSDPVecZero(V);DSDPCHKERR(info);*nzcols=0;}
else if (row==m-1){
info=DSDPVecZero(V);DSDPCHKERR(info);*nzcols=0;
if (r){info=DSDPVecSetR(V,1.0);DSDPCHKERR(info);*nzcols=1;}
} else if (M.dsdpops->matrownonzeros){
info=DSDPVecGetSize(V,&m);DSDPCHKERR(info);
info=DSDPVecGetArray(V,&cols);DSDPCHKERR(info);
info=(M.dsdpops->matrownonzeros)(M.data,row-1,cols+1,nzcols,m-2); DSDPChkMatError(M,info);
info=DSDPVecRestoreArray(V,&cols);DSDPCHKERR(info);
info=DSDPZeroFixedVariables(M,V);DSDPCHKERR(info);
info=DSDPVecSetC(V,0.0);DSDPCHKERR(info);
if (r){info=DSDPVecSetR(V,1.0);DSDPCHKERR(info);}
info=DSDPIsFixed(M,row,&flag);DSDPCHKERR(info);
if (flag==DSDP_TRUE&&*nzcols>0){info=DSDPVecZero(V);*nzcols=0;DSDPFunctionReturn(0);}
} else {
DSDPNoOperationError(M);
}
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPSchurMatAddRow"
int DSDPSchurMatAddRow(DSDPSchurMat M, int row, double alpha, DSDPVec R){
int info,j,m;
double *v,rr,dd=1e-1*M.schur->dd;
DSDPVec rhs3=M.schur->rhs3;
DSDPTruth flag;
DSDPFunctionBegin;
info=DSDPVecGetSize(R,&m); DSDPCHKERR(info);
if (row==0){
} else if (row==m-1){
info=DSDPVecGetR(R,&rr);DSDPCHKERR(info);
info=DSDPVecAddR(rhs3,alpha*rr);DSDPCHKERR(info);
} else if (M.dsdpops->mataddrow){
info=DSDPVecGetArray(R,&v); DSDPCHKERR(info);
/* v[row]=DSDPMax(0,v[row]); v[row]+=1.0e-15; */
for (j=0;j<m;j++){ if (fabs(v[j]) < 1e-25 && row!=j){ v[j]=0.0;} }
v[row]*=(1.0+dd);
info=DSDPZeroFixedVariables(M,R);DSDPCHKERR(info);
info=DSDPIsFixed(M,row,&flag);DSDPCHKERR(info);
if (flag==DSDP_TRUE){info=DSDPVecSetBasis(R,row);DSDPCHKERR(info);}
info=(M.dsdpops->mataddrow)(M.data,row-1,alpha,v+1,m-2); DSDPChkMatError(M,info);
info=DSDPVecRestoreArray(R,&v); DSDPCHKERR(info);
info=DSDPVecGetR(R,&rr); DSDPCHKERR(info);
info=DSDPVecAddElement(rhs3,row,alpha*rr); DSDPCHKERR(info);
} else {
DSDPNoOperationError(M);
}
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPSchurMatVariableCompute"
int DSDPSchurMatVariableCompute(DSDPSchurMat M, int row, double *rcv){
int info,m,dd=1;
double r=M.schur->r;
DSDPTruth flag;
DSDPFunctionBegin;
info=DSDPVecGetSize(M.schur->rhs3,&m);
if (row==0){ *rcv=0.0;
} else if (row==m-1){
if (r){*rcv=1.0;}
else {*rcv=0.0;}
} else if (M.dsdpops->pmatonprocessor){
info=(M.dsdpops->pmatonprocessor)(M.data,row-1,&dd); DSDPChkMatError(M,info);
if (dd){*rcv=1.0;} else {*rcv=0;}
} else {
info=DSDPSchurMatInParallel(M,&flag);DSDPChkMatError(M,info);
if (flag==DSDP_FALSE){ *rcv=1.0;
} else {
DSDPNoOperationError(M);
}
}
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPSchurMatAddDiagonalElement"
int DSDPSchurMatAddDiagonalElement(DSDPSchurMat M, int row, double dd){
int info,m;
DSDPVec rhs3=M.schur->rhs3;
DSDPFunctionBegin;
info=DSDPVecGetSize(rhs3,&m);DSDPCHKERR(info);
if (dd==0){
} else if (row==0){
} else if (row==m-1){info=DSDPVecAddR(rhs3,dd);
} else if (M.dsdpops->mataddelement){
info=(M.dsdpops->mataddelement)(M.data,row-1,dd); DSDPChkMatError(M,info);
} else {
DSDPNoOperationError(M);
}
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPSchurMatVariableComputeR"
int DSDPSchurMatVariableComputeR(DSDPSchurMat M, double *rcv){
DSDPFunctionBegin;
*rcv=0.0;
if (M.schur->r) *rcv=1.0;
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPSchurMatAddR"
int DSDPSchurMatAddR(DSDPSchurMat M, int row, double dd){
int info;
DSDPFunctionBegin;
if (dd==0){DSDPFunctionReturn(0);}
info=DSDPVecAddElement(M.schur->rhs3,row,dd);DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPSchurMatVariableComputeC"
int DSDPSchurMatVariableComputeC(DSDPSchurMat M, double *rcv){
DSDPFunctionBegin;
*rcv=0.0;
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPSchurMatAddC"
int DSDPSchurMatAddC(DSDPSchurMat M, int row, double dd){
DSDPFunctionBegin;
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPSchurMatDiagonalScaling"
int DSDPSchurMatDiagonalScaling(DSDPSchurMat M, DSDPVec D){
int m,info;
double *vars;
DSDPTruth flag;
DSDPFunctionBegin;
info=DSDPVecSet(1.0,D);DSDPCHKERR(info);
info=DSDPVecGetSize(D,&m);DSDPCHKERR(info);
if (M.dsdpops->pmatlocalvariables){
info=DSDPVecGetArray(D,&vars);DSDPCHKERR(info);
info=(M.dsdpops->pmatlocalvariables)(M.data,vars+1,m-2); DSDPChkMatError(M,info);
info=DSDPVecRestoreArray(D,&vars);DSDPCHKERR(info);
} else {
info=DSDPSchurMatInParallel(M,&flag);DSDPChkMatError(M,info);
if (flag==DSDP_TRUE){
DSDPNoOperationError(M);
}
}
info=DSDPVecSetC(D,0.0);DSDPCHKERR(info);
if (M.schur->r==0){info=DSDPVecSetR(D,0.0);DSDPCHKERR(info);}
info=DSDPZeroFixedVariables(M,D);DSDPCHKERR(info);
DSDPFunctionReturn(0);
}
#undef __FUNCT__
#define __FUNCT__ "DSDPSchurMatAddDiagonal"
int DSDPSchurMatAddDiagonal(DSDPSchurMat M, DSDPVec D){
int m,info;
double *dd;
DSDPFunctionBegin;
if (M.dsdpops->matadddiagonal){
info=DSDPZeroFixedVariables(M,D);DSDPCHKERR(info);
info=DSDPVecGetSize(D,&m); DSDPCHKERR(info);
info=DSDPVecGetArray(D,&dd); DSDPCHKERR(info);
info=(M.dsdpops->matadddiagonal)(M.data,dd+1,m-2); DSDPChkMatError(M,info);
info=DSDPVecAddR(M.schur->rhs3,dd[m-1]);DSDPCHKERR(info);
info=DSDPVecRestoreArray(D,&dd); DSDPCHKERR(info);
} else {
DSDPNoOperationError(M);
}
DSDPFunctionReturn(0);
}
dsdpbasictypes.h
Solver, solution types, termination codes,.
DSDPTruth
DSDPTruth
Boolean variables.
Definition dsdpbasictypes.h:19
DSDP_FALSE
@ DSDP_FALSE
Definition dsdpbasictypes.h:19
DSDP_TRUE
@ DSDP_TRUE
Definition dsdpbasictypes.h:19
DSDPSchurMatInParallel
int DSDPSchurMatInParallel(DSDPSchurMat M, DSDPTruth *flag)
Determine whether M is computed in parallel.
Definition dsdpschurmat.c:149
dsdpschurmat.h
Methods of a Schur Matrix.
dsdpschurmat_impl.h
Function pointers that a Schur complement matrix (dense, sparse, parallel dense) must provide.
DSDPSchurMatVariableCompute
int DSDPSchurMatVariableCompute(DSDPSchurMat M, int row, double *rcv)
Determine with the cone should compute this diagonal element of M and RHS.
Definition dsdpschurmatadd.c:120
DSDPSchurMatVariableComputeR
int DSDPSchurMatVariableComputeR(DSDPSchurMat M, double *rcv)
Add an element to the Schur matrix correponding the variable r.
Definition dsdpschurmatadd.c:181
DSDPSchurMatDiagonalScaling
int DSDPSchurMatDiagonalScaling(DSDPSchurMat M, DSDPVec D)
Get the scaling and nonzero pattern of each diagonal element of the matrix.
Definition dsdpschurmatadd.c:235
DSDPSchurMatAddDiagonalElement
int DSDPSchurMatAddDiagonalElement(DSDPSchurMat M, int row, double dd)
Determine with the cone should compute this diagonal element of M and RHS.
Definition dsdpschurmatadd.c:157
DSDPSchurMatRowColumnScaling
int DSDPSchurMatRowColumnScaling(DSDPSchurMat M, int row, DSDPVec V, int *nzcols)
Get the scaling and nonzero pattern of each column in this row of the matrix.
Definition dsdpschurmatadd.c:33
DSDPSchurMatAddRow
int DSDPSchurMatAddRow(DSDPSchurMat M, int row, double alpha, DSDPVec R)
Add elements to a row of the Schur matrix.
Definition dsdpschurmatadd.c:76
DSDPSchurMatAddDiagonal
int DSDPSchurMatAddDiagonal(DSDPSchurMat M, DSDPVec D)
Add elements to a row of the Schur matrix.
Definition dsdpschurmatadd.c:272
DSDPSchurMatAddR
int DSDPSchurMatAddR(DSDPSchurMat M, int row, double dd)
Add an element to the Schur matrix correponding the variable r.
Definition dsdpschurmatadd.c:198
dsdpsys.h
Error handling, printing, and profiling.
DSDPVec
struct DSDPVec_C DSDPVec
This object hold m+2 variables: a scaling of C, the y variables, and r.
Definition dsdpvec.h:25
DSDPSchurMat_C
Schur complement matrix whose solution is the Newton direction.
Definition dsdpschurmat.h:35