public BicubicInterpolator() { fixedArray[0] = new double[] { 1, 0, 0, 0 }; fixedArray[1] = new double[] { 0, 0, 1, 0 }; fixedArray[2] = new double[] { -3, 3, -2, -1 }; fixedArray[3] = new double[] { 2, -2, 1, 1 }; fixed1 = new Mapack.Matrix(fixedArray); fixed2 = fixed1.Transpose(); coefficient = new Mapack.Matrix(4, 4); }
//function public override double[] propagate(double[] Bids) { Mapack.Matrix BidM = new Matrix(new double[][] { Bids }); //sanity check try { if (Bids.Length != W1.Rows) { throw new Exception("The number of bids and weights does not match"); } } catch (Exception e) { Console.WriteLine(e.Message); } int H = W1.Columns; int M = W1.Rows; int K = W2.Columns; Matrix a1 = W1.Transpose() * BidM.Transpose(); Matrix Z = new Matrix(H, 1); for (int h = 0; h < H; h++) { double d = a1[h, 0]; Z[h, 0] = Math.Tanh(d); } Matrix a2 = W2.Transpose() * Z; double Denominator = 0; for (int k = 0; k < K; k++) { double d = a2[k, 0]; d = Math.Exp(d); Denominator += d; } double[] Probabilities = new double[K]; for (int k = 0; k < K; k++) { double d = a2[k, 0]; d = Math.Exp(d); Probabilities[k] = d / Denominator; } return(Probabilities); }