Example #1
0
        internal StateSolver(IStateCalculation calculation, IMeasurements parent, Block[] blocks)
        {
            this.calculation = calculation;
            this.parent      = parent;
            count            = calculation.State.Length;
            state            = calculation.State;
            der = calculation.Derivation;
            List <IMeasurement> l = new List <IMeasurement>();
            int k = 0;

            for (int i = 0; i < blocks.Length; i++)
            {
                Block  block = blocks[i];
                string name  = block.Name;
                name = name.Replace("/", " ") + "_";
                string dname = "D_" + name;
                for (int j = 0; j < block.Dim; j++)
                {
                    int[]         mm   = new int[] { k };
                    Func <object> f    = () => state[mm[0]];
                    Func <object> deri = () => der[mm[0]];
                    ++k;
                    Measurement           m  = new Measurement(deri, dname + j);
                    MeasurementDerivation md = new MeasurementDerivation(f, m, name + j);
                    l.Add(md);
                }
            }
            mea = l.ToArray();
        }
Example #2
0
 bool LoadText()
 {
     try
     {
         calculation = CodeCreator.CreateInterface(text, out input, out output, out blocks);
         state       = calculation.State;
         ass[0]      = new StateSolver(calculation, this, blocks);
         CreateOutput();
         links.Clear();
         CreateConstants();
         return(true);
     }
     catch (Exception)
     {
     }
     return(false);
 }