Esempio n. 1
0
        public void PartitionOfUnity()
        {
            var k = new double[] { 0, 0, 0, 1, 2, 3, 4, 4, 5, 5, 5 };
            Func <int, int, Func <double, double> > N = (i, p) => BSpline.Basis(k, i: i, p: p);
            var us    = Generate.LinearSpaced(100, 0, 4.9999);
            var p     = 2;
            var order = p + 1;

            foreach (var u in us)
            {
                var i = BSpline.KnotSpanFor(k, u);
                Enumerable.Range(i - p, order).Sum(j => N(j, p)(u)).Should().BeApproximately(1.0, 1e-5);
            }
        }
Esempio n. 2
0
 public void BSplineKnotSearchShortWork()
 {
     {
         var k = new double[] { 0, 0, 0, 1, 2, 3, 4, 4, 5, 5, 5 };
         BSpline.KnotSpanFor(k, 0).Should().Be(2);
         BSpline.KnotSpanFor(k, 0.5).Should().Be(2);
         BSpline.KnotSpanFor(k, 1).Should().Be(3);
         BSpline.KnotSpanFor(k, 2).Should().Be(4);
         BSpline.KnotSpanFor(k, 5).Should().Be(10);
     }
     {
         var k = new double[] { 0, 0, 1, 1 };
         BSpline.KnotSpanFor(k, 0).Should().Be(1);
         BSpline.KnotSpanFor(k, 0.5).Should().Be(1);
         BSpline.KnotSpanFor(k, 1).Should().Be(3);
     }
 }