MCPcopy Create free account
hub / github.com/ShahjalalShohag/code-library / pivot

Function pivot

Math/Simplex Algorithm.cpp:117–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115 }
116
117 inline void pivot(int m, int n, int a, int b){ /// Pivoting and exchanging a non-basic variable with a basic variable
118 for (int i = 0; i <= m; i++){
119 if (i != a){
120 for (int j = 0; j <= n; j++){
121 if (j != b){
122 ar[i][j] -= (ar[i][b] * ar[a][j]) / ar[a][b];
123 }
124 }
125 }
126 }
127 for (int j = 0; j <= n; j++){
128 if (j != b) ar[a][j] /= ar[a][b];
129 }
130 for (int i = 0; i <= m; i++){
131 if (i != a) ar[i][b] = -ar[i][b] / ar[a][b];
132 }
133 ar[a][b] = 1.0 / ar[a][b];
134 swap(basis[a], index[b]);
135 }
136 inline long double solve(){ /// simplex core
137 init();
138 int i, j, k, l;

Callers 1

solveFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected