MCPcopy Create free account
hub / github.com/Singular/Singular / compute

Method compute

kernel/numeric/mpr_numeric.cc:1095–1260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1093}
1094
1095void simplex::compute()
1096{
1097 int i,ip,ir,is,k,kh,kp,m12,nl1,nl2;
1098 int *l1,*l2,*l3;
1099 mprfloat q1, bmax;
1100
1101 if ( m != (m1+m2+m3) )
1102 {
1103 // error: bad input
1104 error(WarnS("simplex::compute: Bad input constraint counts!");)
1105 icase=-2;
1106 return;
1107 }
1108
1109 l1= (int *) omAlloc0( (n+1) * sizeof(int) );
1110 l2= (int *) omAlloc0( (m+1) * sizeof(int) );
1111 l3= (int *) omAlloc0( (m+1) * sizeof(int) );
1112
1113 nl1= n;
1114 for ( k=1; k<=n; k++ ) l1[k]=izrov[k]=k;
1115 nl2=m;
1116 for ( i=1; i<=m; i++ )
1117 {
1118 if ( LiPM[i+1][1] < 0.0 )
1119 {
1120 // error: bad input
1121 error(WarnS("simplex::compute: Bad input tableau!");)
1122 error(Warn("simplex::compute: in input Matrix row %d, column 1, value %f",i+1,LiPM[i+1][1]);)
1123 icase=-2;
1124 // free mem l1,l2,l3;
1125 omFreeSize( (void *) l3, (m+1) * sizeof(int) );
1126 omFreeSize( (void *) l2, (m+1) * sizeof(int) );
1127 omFreeSize( (void *) l1, (n+1) * sizeof(int) );
1128 return;
1129 }
1130 l2[i]= i;
1131 iposv[i]= n+i;
1132 }
1133 for ( i=1; i<=m2; i++) l3[i]= 1;
1134 ir= 0;
1135 if (m2+m3)
1136 {
1137 ir=1;
1138 for ( k=1; k <= (n+1); k++ )
1139 {
1140 q1=0.0;
1141 for ( i=m1+1; i <= m; i++ ) q1+= LiPM[i+1][k];
1142 LiPM[m+2][k]= -q1;
1143 }
1144
1145 do
1146 {
1147 simp1(LiPM,m+1,l1,nl1,0,&kp,&bmax);
1148 if ( bmax <= SIMPLEX_EPS && LiPM[m+2][1] < -SIMPLEX_EPS )
1149 {
1150 icase= -1; // no solution found
1151 // free mem l1,l2,l3;
1152 omFreeSize( (void *) l3, (m+1) * sizeof(int) );

Callers 5

loSimplexFunction · 0.80
inHullMethod · 0.80
vDistanceMethod · 0.80
mn_mx_MinkowskiSumMethod · 0.80
RCMethod · 0.80

Calls 4

errorFunction · 0.85
WarnSFunction · 0.85
omAlloc0Function · 0.85
WarnFunction · 0.85

Tested by

no test coverage detected