Esempio n. 1
0
        public void Greater06Find()
        {
            var comparer = new SortedListItemComparer(depth: 6);

            var equal = SampleList.BinaryFindGreater(
                key1: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key1,
                key2: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key2,
                key3: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key3,
                key4: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key4,
                key5: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key5,
                key6: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key6
                );

            var equalRange = SampleList.BinaryFindGreaterRange(
                range: Range.All,
                key1: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key1,
                key2: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key2,
                key3: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key3,
                key4: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key4,
                key5: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key5,
                key6: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key6
                );

            SortedListTestHelper.GreaterTest(comparer, equal, equalRange);
        }
Esempio n. 2
0
 InterpolationSingleDimension(
     double[] t,
     double[] x)
 {
     _samples   = new SampleList(t, x);
     _algorithm = new PolynomialInterpolationAlgorithm();
 }
Esempio n. 3
0
        public void Less07Find()
        {
            var comparer = new SortedListItemComparer(depth: 7);

            var equal = SampleList.BinaryFindLess(
                key1: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key1,
                key2: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key2,
                key3: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key3,
                key4: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key4,
                key5: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key5,
                key6: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key6,
                key7: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key7
                );

            var equalRange = SampleList.BinaryFindLessRange(
                range: Range.All,
                key1: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key1,
                key2: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key2,
                key3: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key3,
                key4: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key4,
                key5: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key5,
                key6: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key6,
                key7: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key7
                );

            SortedListTestHelper.LessTest(comparer, equal, equalRange);
        }
Esempio n. 4
0
 InterpolationSingleDimension(
     IDictionary samples
     )
 {
     _samples   = new SampleList(samples);
     _algorithm = new PolynomialInterpolationAlgorithm();
 }
Esempio n. 5
0
 InterpolationSingleDimension(
     double[] t,
     double[] x,
     IInterpolationAlgorithm algorithm)
 {
     _samples   = new SampleList(t, x);
     _algorithm = algorithm;
 }
Esempio n. 6
0
 InterpolationSingleDimension(
     SampleList samples,
     IInterpolationAlgorithm algorithm)
 {
     _samples = samples;
     _samples.SampleAltered += OnSampleAltered;
     _algorithm              = algorithm;
 }
Esempio n. 7
0
 InterpolationSingleDimension(
     double[] t,
     double[] x,
     InterpolationMode mode)
 {
     _samples   = new SampleList(t, x);
     _algorithm = SelectAlgorithm(mode);
 }
Esempio n. 8
0
 InterpolationSingleDimension(
     SampleList samples,
     InterpolationMode mode)
 {
     _samples = samples;
     _samples.SampleAltered += OnSampleAltered;
     _algorithm              = SelectAlgorithm(mode);
 }
Esempio n. 9
0
 InterpolationSingleDimension(
     SampleList samples
     )
 {
     _samples = samples;
     _samples.SampleAltered += samples_SampleAltered;
     _algorithm              = new PolynomialInterpolationAlgorithm();
 }
        /// <summary>
        /// Returns the sample list representing the last received sample of the given label. Can be redefined in children classes.
        /// </summary>
        /// <param name="label">The label to get the sample.</param>
        /// <returns>A float list representing the sample of the given label.</returns>
        public virtual List <float> GetSample(string label)
        {
            if (SampleList.ContainsKey(label))
            {
                return(SampleList[label].Sample);
            }

            return(new List <float>());
        }
Esempio n. 11
0
        private void SelectItem(string pageName)
        {
            var supportPageElement = SampleList.Items.OfType <System.Xml.XmlElement>()
                                     .First(x => x.Attributes["Page"] != null && x.Attributes["Page"].Value == pageName);

            SampleList.SelectedItem = supportPageElement;

            SampleList.ScrollIntoView(supportPageElement);
        }
        private void DeleteSample(object param)
        {
            var model = param as SampleModel;

            if (model != null)
            {
                SampleList.Remove(model);
            }
        }
Esempio n. 13
0
    public void TestList()
    {
        var sample = new SampleList
        {
            Fields = { "b", "c" }
        };
        var count = sample.Fields.Count;

        Assert.Equal(2, count);
    }
Esempio n. 14
0
 InterpolationSingleDimension(
     SampleList samples,
     InterpolationMode mode,
     int maximumOrder)
 {
     _samples = samples;
     _samples.SampleAltered += OnSampleAltered;
     _algorithm              = SelectAlgorithm(mode);
     _algorithm.MaximumOrder = maximumOrder;
 }
Esempio n. 15
0
        Init(SampleList samples)
        {
            if (null == samples)
            {
                throw new ArgumentNullException("samples");
            }

            _samples        = samples;
            _effectiveOrder = Math.Min(_maximumOrder, samples.Count);
        }
Esempio n. 16
0
        protected void SampleEdit()
        {
            var hideSampleList = SampleList.Where(s => !s.IsSelected).ToList();

            this.SampleList = hideSampleList;
            //this.SampleList.Remove(selectSample);

            SetDetailClear();
            // FooterMessage = "Select sample : " + this.SampleList.Count();
        }
Esempio n. 17
0
 InterpolationSingleDimension(
     double[] t,
     double[] x,
     InterpolationMode mode,
     int maximumOrder)
 {
     _samples   = new SampleList(t, x);
     _algorithm = SelectAlgorithm(mode);
     _algorithm.MaximumOrder = maximumOrder;
 }
 private async void Search()
 {
     if (!string.IsNullOrEmpty(SearchSample.ToString()))
     {
         SampleList.Where(a => a.Id == SearchSample);
     }
     else
     {
         MessageSearch = "Debe ingresar un Número";
     }
 }
        /// <summary>
        /// Adds the given label to the <see cref="SampleList"/> dictionary if it is not present.
        /// </summary>
        /// <param name="label">The label to be added.</param>
        public virtual void UpdateSampleDictionaries(string label)
        {
            lock (SampleLocks)
            {
                if (ContainsSample(label))
                {
                    return;
                }

                SampleList.Add(label, new UdpSample());
                SampleLocks.Add(label, new object());
            }
        }
        private void DateSelectSampleList()
        {
            if (this._sampleList == null || !this._sampleList.Any())
            {
                this.SampleList = Dao.SampleDao.GetSamples().ToList();
            }

            var datePicSelectSampleList = SampleList.Where(s => this._fromDatePick <= DateTime.Parse(s.DATEONLY) &&
                                                           DateTime.Parse(s.DATEONLY) <= this._toDatePick)
                                          .ToList();

            this.SampleList = datePicSelectSampleList;
            SetDetailClear();
        }
        public void GreaterOrEqual01Find()
        {
            var comparer = new SortedListItemComparer(depth: 1);

            var equal = SampleList.BinaryFindGreaterOrEqual(
                key1: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key1
                );

            var equalRange = SampleList.BinaryFindGreaterOrEqualRange(
                range: Range.All,
                key1: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key1
                );

            SortedListTestHelper.GreaterOrEqualTest(comparer, equal, equalRange);
        }
Esempio n. 22
0
        public void IRID119_PolynomialExtrapolatePositiveDirection()
        {
            double[] x = new double[] { -6.060771484, -5.855378418, -1.794238281, -1.229428711, 0.89935791, 2.912121582, 4.699230957, 4.788347168, 7.728830566, 11.70989502 };
            double[] y = new double[] { 0.959422052, 0.959447861, 0.959958017, 0.960028946, 0.960323274, 0.960636258, 0.960914195, 0.960928023, 0.96138531, 0.962004483 };

            PolynomialInterpolationAlgorithm pia = new PolynomialInterpolationAlgorithm(10);
            SampleList sl = new SampleList(10);

            for (int i = 0; i < 10; i++)
            {
                sl.Add(x[i], y[i]);
            }

            pia.Prepare(sl);
            Assert.That(pia.Extrapolate(12), NumericIs.AlmostEqualTo(0.9622, 1e-3), "extrapolate(12)");
        }
Esempio n. 23
0
        protected virtual void Initialize(ISensorManager i_Parent)
        {
            if (i_Parent == null)
            {
                return;
            }

            Samples    = new SampleList(this);
            TimeStamps = new SampleList(this);
            Alarm      = new SensorAlarm(this);

            InitializeParent(i_Parent);
            InitializeCalibration();

            Samples.OnSampleAdded    += ParentSensorManager.SampleAdded;
            TimeStamps.OnSampleAdded += ParentSensorManager.TimeStampAdded;
        }
Esempio n. 24
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAddSample_Click(object sender, DirectEventArgs e)
        {
            try
            {
                var sample = new SampleList();

                var arrDepartment = hdfDepartment.Text.Split(new[] { ',' }, StringSplitOptions.None);
                sample.Name        = txtSampleName.Text;
                sample.CreatedBy   = CurrentUser.User.UserName;
                sample.CreatedDate = DateTime.Now;
                sample.Note        = txtSampleNote.Text;
                if (e.ExtraParams["command"] == "edit")
                {
                    sample.Id = int.Parse("0" + hdfIDSample.Text);

                    foreach (var t in arrDepartment)
                    {
                        if (!string.IsNullOrEmpty(t))
                        {
                            sample.DepartmentId = Convert.ToInt32(t);
                        }
                        SampleListServices.Update(sample);
                    }
                }
                else
                {
                    foreach (var t in arrDepartment)
                    {
                        if (!string.IsNullOrEmpty(t))
                        {
                            sample.DepartmentId = Convert.ToInt32(t);
                        }
                        SampleListServices.Create(sample);
                    }
                }
                wdSample.Hide();
                grp_SampleList.Reload();
            }
            catch (Exception ex)
            {
                Dialog.ShowError("" + ex.Message);
            }
        }
        public void LessOrEqual03Find()
        {
            var comparer = new SortedListItemComparer(depth: 3);

            var equal = SampleList.BinaryFindLessOrEqual(
                key1: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key1,
                key2: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key2,
                key3: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key3
                );

            var equalRange = SampleList.BinaryFindLessOrEqualRange(
                range: Range.All,
                key1: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key1,
                key2: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key2,
                key3: SortedReadOnlyListSampleSourceArray.ExistingItemExample.Key3
                );

            SortedListTestHelper.LessOrEqualTest(comparer, equal, equalRange);
        }
Esempio n. 26
0
        protected void SampleDelete()
        {
            string messageBoxText = "Are you sure you want to delete selected data?";
            string caption        = "Delete sample";

            // Display message box
            if (ShowConfirmDialog(messageBoxText, caption))
            {
                var deleteSampleList = SampleList.Where(s => s.IsSelected)
                                       .Select(s => (long)s.ID)
                                       .ToArray();
                // Console.WriteLine("delete sample");

                // リスト更新(DBから更新すると、Hideのものが復活するのでViewの中で完結させる)
                var res = Dao.SampleDao.DeleteSample(deleteSampleList);
                SampleEdit();
                return;
            }
            // Console.WriteLine("Delete Cancel");
        }
Esempio n. 27
0
        private void DisplaySamples()
        {
            var x      = 0;
            var y      = 0;
            var width  = 38;
            var height = 50;
            var space  = 2;

            // list of keys in the right order
            var sampleList = new SampleList();

            this.groupBoxKeys.Controls.Clear();

            sampleList.OrderBy(c => c.Position).ToList().ForEach(p =>
            {
                var sample = _samples
                             .Where(c => c.NoteName == p.NoteName && c.NoteType == p.KeyType && c.Octave == p.Octave)
                             .First();

                if (sample.NoteType == KeyType.Natural)
                {
                    AddSample(
                        sample,
                        new Point(x += (width + space), y + 30 + space),
                        new Size(width, height),
                        Color.White,
                        Color.Black);
                }
                else
                {
                    AddSample(sample,
                              new Point(x += (width + space), y),
                              new Size(width, height),
                              Color.Black,
                              Color.White);
                }
            });
        }
Esempio n. 28
0
        public static List <SampleList> refreshSample()
        {
            List <SampleList> sample = new List <SampleList>();

            string path = getPath();

            DateTime date = DateTime.Now;

            string[] directory = Directory.GetDirectories(path);              //Считываем имена директорий

            for (int i = 0; i < directory.Length; i++)                        //Перебираем директории
            {
                string[] directoryEntries = Directory.GetFiles(directory[i]); //Читаем имена файлов в текущей директории

                for (int j = 0; j < directoryEntries.Length; j++)             // Перебираем файлы внутри дирректории
                {
                    //Читаем DATE.DAT
                    if (directoryEntries[j].Contains("DATE.DAT"))
                    {
                        SampleList sampleList = new SampleList();

                        StreamReader file     = new StreamReader(directoryEntries[j]);
                        string       datetemp = file.ReadLine();
                        DateTime.TryParseExact(datetemp, "yyyy/M/d_H:m", CultureInfo.InvariantCulture, DateTimeStyles.None, out date);

                        sampleList.Date = date;
                        sampleList.Path = directory[i];
                        sample.Add(sampleList);
                    }
                }

                //MessageBox.Show(Convert.ToString(directory[i]));
            }

            return(sample);
        }
Esempio n. 29
0
        public WelcomeForm()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            FileInfo   fi = new FileInfo("samples/samples.xml");
            SampleList sl = SampleList.FromXml(fi.FullName);

            foreach (Sample s in sl.Samples)
            {
                ListViewItem lvi = new ListViewItem(new string[] { s.Name, s.Description });
                lvi.Tag = new Uri(new Uri(fi.FullName), s.File);
                listView1.Items.Add(lvi);
            }

            startW = wtc.Width;
            startH = wtc.Height;

//			NewFileWizard nfw=new NewFileWizard();
//			welcomeTabPage2.Controls.Add(nfw);
//			nfw.Dock=DockStyle.Fill;
        }
Esempio n. 30
0
        public void AddSample(Sample sample)
        {
            if (!HasGender && sample.Gender != Sample.Genders.NEUTRAL)
            {
                throw new Exception("Cannot add sample with gender to non-gendered samples");
            }

            if (HasGender)
            {
                if (sample.Gender == Sample.Genders.MALE || sample.Gender == Sample.Genders.NEUTRAL)
                {
                    SampleList.Add(sample);
                }

                if (sample.Gender == Sample.Genders.FEMALE || sample.Gender == Sample.Genders.NEUTRAL)
                {
                    FemaleSampleList.Add(sample);
                }
            }
            else
            {
                SampleList.Add(sample);
            }
        }
Esempio n. 31
0
 /// <summary>
 /// Initializes a new instance of the InterpolationSingleDimension class,
 /// with samples from a sample list and selects an algorithm that fits the chosen interpolation mode.
 /// </summary>
 /// <param name="samples">Sample Points.</param>
 /// <param name="mode">Interpolation Mode.</param>
 public InterpolationSingleDimension(
     SampleList samples,
     InterpolationMode mode)
 {
     _samples = samples;
     _samples.SampleAltered += OnSampleAltered;
     _algorithm = SelectAlgorithm(mode);
 }
Esempio n. 32
0
 public void TestSpaces()
 {
     var jd = new JsonDeserializer();
     var w = new SampleList();
     jd.FromString(w, "{   \t\t\n\n\n\r \"E\":   \t\t\n\n[  \n\t\n\t]    }");
     Assert.AreEqual(0, w.E.Count);
 }
Esempio n. 33
0
        public void TestList()
        {
            var bs = new BinarySerializer();
            bs.Options.TagMode = TagMode.Names;
            var bd = new BinaryDeserializer();
            bd.Options.TagMode = TagMode.Names;

            var v0 = new SampleList { E = new List<string> { "a", "b", "c" } };
            var result0 = bs.ToBytes(v0);
            Assert.AreEqual(
                "20 01 00 " + XS(typeof(SampleList)) + " 01 00 " +
                XS("E", RoughType.Sequence) + " " + XS(RoughType.String) +
                " 01 00 03 00 00 00 " + XS("a", "b", "c") + " 00 00",
                XS(result0));
            var w0 = new SampleList();
            bd.FromBytes(w0, result0);
            CollectionAssert.AreEqual(v0.E, w0.E);

            var v1 = new SampleTree { Value = 11, Children = new List<SampleTree>() };
            var result1 = bs.ToBytes(v1);
            Assert.AreEqual(
                "20 02 00 " + XS(typeof(SampleTree)) + " 02 00 " +
                XS("Value", RoughType.Int, "Children", RoughType.Sequence) + " " + XS(RoughType.Record) +
                " 01 00 0B 00 00 00 02 00 00 00 00 00 00 00",
                XS(result1));
            Assert.AreEqual("20 02 00 01 00 0B 00 00 00 02 00 00 00 00 00 00 00", XS(bs.ToBytes(v1)));
            var w1 = new SampleTree();
            bd.FromBytes(w1, result1);
            Assert.AreEqual(0, w1.Children.Count);

            var v2 = new SampleTree {
                Value = 11,
                Children = new List<SampleTree> {
                    new SampleTree {
                        Value = 12,
                        Children = new List<SampleTree>(),
                    },
                    new SampleTree {
                        Value = 13,
                    }
                }
            };
            var result2 = bs.ToBytes(v2);
            Assert.AreEqual(
                "20 02 00 01 00 0B 00 00 00 02 00 02 00 00 00 " +
                "02 00 01 00 0C 00 00 00 02 00 00 00 00 00 00 00 " +
                "02 00 01 00 0D 00 00 00 02 00 FF FF FF FF 00 00 00 00",
                XS(result2));
            SampleTree w2 = new SampleTree();
            bd.FromBytes(w2, result2);
            Assert.AreEqual(v2.Value, w2.Value);
            Assert.AreEqual(v2.Children.Count, w2.Children.Count);
            Assert.AreEqual(v2.Children[0].Value, w2.Children[0].Value);
            Assert.AreEqual(v2.Children[1].Children, w2.Children[1].Children);

            Assert.AreEqual(
                "20 03 00 " + XS(typeof(SampleEmptyList)) + " 01 00 " +
                XS("E", RoughType.Sequence) + " " + XS(RoughType.String) + " 00 00",
                XS(bs.ToBytes(new SampleEmptyList())));
            Assert.AreEqual(
                "20 03 00 01 00 FF FF FF FF 00 00",
                XS(bs.ToBytes(new SampleEmptyList { E = null })));
        }
Esempio n. 34
0
 /// <summary>
 /// Initializes a new instance of the InterpolationSingleDimension class,
 /// with samples from points (t, x(t)).
 /// </summary>
 /// <remarks>
 /// Uses the <see cref="PolynomialInterpolationAlgorithm"/>.
 /// </remarks>
 /// <param name="t">keys t, where x=f(t) or (t,x).</param>
 /// <param name="x">values x, where x=f(t) or (t,x).</param>
 public InterpolationSingleDimension(
     double[] t,
     double[] x)
 {
     _samples = new SampleList(t, x);
     _algorithm = new PolynomialInterpolationAlgorithm();
 }
Esempio n. 35
0
        public void TestList()
        {
            var js = new JsonSerializer();
            js.JsonOptions.Indent = "";
            js.Options.TagMode = TagMode.Names;
            var jd = new JsonDeserializer();
            jd.Options.TagMode = TagMode.Names;

            var v0 = new SampleList { E = new List<string> { "a", "b", "c" } };
            var result0 = js.ToString(v0);
            Assert.AreEqual("{\n\"E\":[\n\"a\",\n\"b\",\n\"c\"\n]\n}", result0);
            var w0 = new SampleList();
            jd.FromString(w0, result0);
            CollectionAssert.AreEqual(v0.E, w0.E);

            var v1 = new SampleTree { Value = 11, Children = new List<SampleTree>() };
            Assert.AreEqual("{\n\"Value\":11,\n\"Children\":[]\n}", js.ToString(v1));
            var w1 = new SampleTree();
            jd.FromString(w1, js.ToString(v1));
            Assert.AreEqual(0, w1.Children.Count);

            var v2 = new SampleTree {
                Value = 11,
                Children = new List<SampleTree> {
                    new SampleTree {
                        Value = 12,
                        Children = new List<SampleTree>(),
                    },
                    new SampleTree {
                        Value = 13,
                    }
                }
            };
            var result2 = js.ToString(v2);
            Assert.AreEqual(
                "{\n\"Value\":11,\n\"Children\":[\n" +
                "{\n\"Value\":12,\n\"Children\":[]\n},\n" +
                "{\n\"Value\":13,\n\"Children\":null\n}\n" +
                "]\n}",
                result2);
            SampleTree w2 = new SampleTree();
            jd.FromString(w2, result2);
            Assert.AreEqual(v2.Value, w2.Value);
            Assert.AreEqual(v2.Children.Count, w2.Children.Count);
            Assert.AreEqual(v2.Children[0].Value, w2.Children[0].Value);
            Assert.AreEqual(v2.Children[1].Children, w2.Children[1].Children);

            Assert.AreEqual("{\n}", js.ToString(new SampleEmptyList()));
            Assert.AreEqual("{\n\"E\":null\n}", js.ToString(new SampleEmptyList { E = null }));
        }
Esempio n. 36
0
File: Speed.cs Progetto: klenin/Yuzu
        public void TestProtobufNetLongListStr()
        {
            var list1 = new SampleList { E = new List<string>() };
            for (int i = 0; i < 100000; ++i)
                list1.E.Add(i.ToString());

            var ms = new MemoryStream();
            ProtoBuf.Serializer.Serialize(ms, list1);
            Assert.IsTrue(ms.Length > 0);

            ms.Position = 0;
            var list2 = ProtoBuf.Serializer.Deserialize<SampleList>(ms);
            Assert.AreEqual(list1.E.Count, list2.E.Count);
        }
Esempio n. 37
0
 /// <summary>
 /// Initializes a new instance of the InterpolationSingleDimension class,
 /// with samples from a dictionary.
 /// </summary>
 /// <remarks>
 /// Uses the <see cref="PolynomialInterpolationAlgorithm"/>.
 /// </remarks>
 /// <param name="samples">Sample Points.</param>
 public InterpolationSingleDimension(IDictionary samples)
 {
     _samples = new SampleList(samples);
     _algorithm = new PolynomialInterpolationAlgorithm();
 }
Esempio n. 38
0
 /// <summary>
 /// Initializes a new instance of the InterpolationSingleDimension class,
 /// with samples from points (t, x(t)) and selects an algorithm that fits the chosen interpolation mode with the given order.
 /// </summary>
 /// <param name="t">keys t, where x=f(t) or (t,x).</param>
 /// <param name="x">values x, where x=f(t) or (t,x).</param>
 /// <param name="mode">Interpolation Mode.</param>
 /// <param name="maximumOrder">Maximum Interpolation Order.</param>
 public InterpolationSingleDimension(
     double[] t,
     double[] x,
     InterpolationMode mode,
     int maximumOrder)
 {
     _samples = new SampleList(t, x);
     _algorithm = SelectAlgorithm(mode);
     _algorithm.MaximumOrder = maximumOrder;
 }
Esempio n. 39
0
 /// <summary>
 /// Initializes a new instance of the InterpolationSingleDimension class,
 /// with samples from a sample list and uses the specified algorithm.
 /// </summary>
 /// <param name="samples">Sample Points.</param>
 /// <param name="algorithm">Interpolation Algorithm.</param>
 public InterpolationSingleDimension(
     SampleList samples,
     IInterpolationAlgorithm algorithm)
 {
     _samples = samples;
     _samples.SampleAltered += OnSampleAltered;
     _algorithm = algorithm;
 }
Esempio n. 40
0
 /// <summary>
 /// Initializes a new instance of the InterpolationSingleDimension class,
 /// with samples from points (t, x(t)) and uses the specified algorithm.
 /// </summary>
 /// <param name="t">keys t, where x=f(t) or (t,x).</param>
 /// <param name="x">values x, where x=f(t) or (t,x).</param>
 /// <param name="algorithm">Interpolation Algorithm.</param>
 public InterpolationSingleDimension(
     double[] t,
     double[] x,
     IInterpolationAlgorithm algorithm)
 {
     _samples = new SampleList(t, x);
     _algorithm = algorithm;
 }
Esempio n. 41
0
        bool _dirty = true; // delay preparation until first evaluation

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the InterpolationSingleDimension class,
        /// with samples from a sample list.
        /// </summary>
        /// <remarks>
        /// Uses the <see cref="PolynomialInterpolationAlgorithm"/>.
        /// </remarks>
        /// <param name="samples">Sample Points.</param>
        public InterpolationSingleDimension(SampleList samples)
        {
            _samples = samples;
            _samples.SampleAltered += OnSampleAltered;
            _algorithm = new PolynomialInterpolationAlgorithm();
        }
Esempio n. 42
0
 void OnSampleAltered(
     object sender,
     SampleList.SampleAlteredEventArgs e)
 {
     _dirty = true; // require new preparation
 }
        /// <summary>
        /// Precompute/optimize the algorithm for the given sample set.
        /// </summary>
        /// <param name="samples">Sample points t and values x(t).</param>
        public void Init(SampleList samples)
        {
            if(null == samples)
            {
                throw new ArgumentNullException("samples");
            }

            _samples = samples;
            _effectiveOrder = Math.Min(_maximumOrder, samples.Count);
        }
Esempio n. 44
0
 /// <summary>
 /// Initializes a new instance of the InterpolationSingleDimension class,
 /// with samples from points (t, x(t)) and selects an algorithm that fits the chosen interpolation mode.
 /// </summary>
 /// <param name="t">keys t, where x=f(t) or (t,x).</param>
 /// <param name="x">values x, where x=f(t) or (t,x).</param>
 /// <param name="mode">Interpolation Mode.</param>
 public InterpolationSingleDimension(
     double[] t,
     double[] x,
     InterpolationMode mode)
 {
     _samples = new SampleList(t, x);
     _algorithm = SelectAlgorithm(mode);
 }
Esempio n. 45
0
 /// <summary>
 /// Initializes a new instance of the InterpolationSingleDimension class,
 /// with samples from a sample list and selects an algorithm that fits the chosen interpolation mode with the given order.
 /// </summary>
 /// <param name="samples">Sample Points.</param>
 /// <param name="mode">Interpolation Mode.</param>
 /// <param name="maximumOrder">Maximum Interpolation Order.</param>
 public InterpolationSingleDimension(
     SampleList samples,
     InterpolationMode mode,
     int maximumOrder)
 {
     _samples = samples;
     _samples.SampleAltered += OnSampleAltered;
     _algorithm = SelectAlgorithm(mode);
     _algorithm.MaximumOrder = maximumOrder;
 }
Esempio n. 46
0
File: Speed.cs Progetto: klenin/Yuzu
        public void TestJsonLongListStr()
        {
            var list1 = new SampleList { E = new List<string>() };
            for (int i = 0; i < 100000; ++i)
                list1.E.Add(i.ToString());

            var js = new JsonSerializer();
            var result1 = js.ToString(list1);
            Assert.IsTrue(result1 != "");

            var list2 = new SampleList();
            var jd = new JsonDeserializer();
            jd.FromString(list2, result1);
            Assert.AreEqual(list1.E.Count, list2.E.Count);

            var jdg = new SampleList_JsonDeserializer();
            var list3 = (SampleList)jdg.FromString(result1);
            Assert.AreEqual(list1.E.Count, list3.E.Count);
        }