예제 #1
0
 public void RealDotProduct()
 {
     using (var vector1 = DataVector32.NewRealTimeVectorFromConstant(2, 3))
         using (var vector2 = DataVector32.NewRealTimeVectorFromConstant(5, 3))
         {
             var result = vector1.RealDotProduct(vector2);
             result.Should().BeApproximately((float)(5 * 2 * 3), (float)1e-6);
         }
 }
예제 #2
0
 public void MapInplace()
 {
     using (var vector = DataVector32.NewRealTimeVectorFromConstant(2, 5))
     {
         vector.MapInplace((f, p) => 2 * f);
         vector[0].Should().BeApproximately(4.0f, 1e-15f);
         vector[1].Should().BeApproximately(4.0f, 1e-15f);
     }
 }
예제 #3
0
 public void ExceptionTest()
 {
     using (var vector1 = DataVector32.NewRealTimeVectorFromConstant(2, 10))
         using (var vector2 = DataVector32.NewRealTimeVectorFromConstant(2, 11))
         {
             Action invalidMultiplication = () => vector1.Multiply(vector2);
             invalidMultiplication.ShouldThrow <VectorMustHaveTheSameSizeException>();
         }
 }
예제 #4
0
 public void RealStatistics()
 {
     using (var vector1 = DataVector32.NewRealTimeVectorFromConstant(2, 3))
     {
         var result = vector1.RealStatistics();
         result.Average.Should().BeApproximately(2.0f, (float)1e-6);
         result.Sum.Should().BeApproximately(6.0f, (float)1e-6);
     }
 }
예제 #5
0
 public void SplitInto()
 {
     using (var vector1 = DataVector32.NewRealTimeVectorFromConstant(2, 4))
         using (var vector2 = DataVector32.NewRealTimeVectorFromConstant(2, 4))
             using (var vector3 = DataVector32.NewRealTimeVectorFromConstant(2, 4))
             {
                 vector1.SplitInto(new[] { vector2, vector3 });
                 vector2.Length.Should().Be(2);
                 vector3.Length.Should().Be(2);
             }
 }
예제 #6
0
 public void MapAggregate()
 {
     using (var vector = DataVector32.NewRealTimeVectorFromConstant(2, 5))
     {
         var result = vector.MapAggregate(
             (f, p) => new MyStruct {
             value = 2 * f
         },
             (a, b) => new MyStruct {
             value = a.value + b.value
         });
         result.value.Should().Be(2 * 2 * 5);
     }
 }
예제 #7
0
 public void AddRealValue()
 {
     using (var vector = DataVector32.NewRealTimeVectorFromConstant(2, 10))
     {
         vector.IsComplex.Should().BeFalse();
         vector.Length.Should().Be(10);
         vector.Points.Should().Be(10);
         vector.AllocatedLength.Should().Be(10);
         vector.Domain.Should().Be(VectorDomain.Time);
         vector[0].Should().BeApproximately(2.0f, 1e-15f);
         vector.Add(3);
         vector[0].Should().BeApproximately(5.0f, 1e-15f);
     }
 }
예제 #8
0
 public void PrepareOpsAndExecuteOnVector()
 {
     using (var ops = new PreparedOps1F32())
         using (var vector = DataVector32.NewRealTimeVectorFromConstant(2, 10))
         {
             ops.AddOps((v) =>
             {
                 v.AddReal(1.0f);
                 v.MultiplyReal(3.0f);
             });
             ops.Exec((DataVector32)vector);
             vector[0].Should().Be(9.0f);
         }
 }