예제 #1
0
파일: Propagator.cs 프로젝트: njmube/public
    public void Connect(Cell output, params Cell[] inputs)
    {
      this.inputs = inputs ?? new Cell[0];
      this.output = output;

      foreach (var input in this.inputs)
        input.ValueChanged += async (_, __) => await ApplyAsync();

      // try applying immediately, in case the inputs already have values or there are no inputs
      ApplyAsync().Wait();
    }
예제 #2
0
        public SqrtMachine()
        {
            x = new Cell();
              g = new Cell();
              h = new Cell();

              var temp1 = new Cell();
              var temp2 = new Cell();
              var two = new Cell();

              var divider1 = new Propagator(arr => (double) arr[0] / (double) arr[1]);
              var adder = new Propagator(arr => (double) arr[0] + (double) arr[1]);
              var constant = new Propagator(arr => 2.0);
              var divider2 = new Propagator(arr => (double) arr[0] / (double) arr[1]);

              divider1.Connect(temp1, x, g);
              adder.Connect(temp2, temp1, g);
              constant.Connect(two);
              divider2.Connect(h, temp2, two);
        }