// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; class MainClass { private static void Simplex(double[,] d, double[] x) { double[,] dd = new double[d.GetLength(0),d.GetLength(1)]; int lastrow = d.GetLength(0) - 1; int lastcol = d.GetLength(1) - 1; for(;;) { int q = 0; for(int i=0; i= 0) break; int p = 0; while(d[p,lastcol]/d[p,q] <= 0) { p++; if(p>lastrow) throw new Exception("Mo solution"); } for(int j=p; j= 0 && d[j,lastcol]/d[j,q] <= d[p,lastcol]/d[p,q]) p=j; for(int j=0; j<=lastrow; j++) { for(int i=0; i<=lastcol; i++) { if(j!=p) dd[j,i] = d[j,i] - d[p,i]*d[j,q]/d[p,q]; else dd[j,i] = d[j,i]/d[p,q]; } } d = (double[,])dd.Clone(); } for(int i=0; i