示例#1
0
        public void CustomOpSupportsLambda()
        {
            var            x = T.Scalar <float>("x");
            Scalar <float> y = CustomOp.Create("myCustomSinus", a => (float)Math.Sin(a), x);
            var            f = T.Function(x, y);

            AssertAreCoherents(a => (float)Math.Sin(a), f);
        }
示例#2
0
        public void CustomOpSupportsStatic()
        {
            var            x = T.Scalar <float>("x");
            Scalar <float> y = CustomOp.Create("myCustomCosinus", Cos, x);
            var            f = T.Function(x, y);

            AssertAreCoherents(Cos, f);
        }
示例#3
0
        public void CustomOpCanBeDerivated()
        {
            var x = T.Scalar <float>("x");

            Scalar <float> y = CustomOp.Create("myCustomSinus",
                                               f: a => (float)Math.Sin(a),
                                               df_dx: (a, b) => CustomOp.Create("myCustomCosinus", Cos, a),
                                               x: x
                                               );

            // f = d/dx(sin(x)) = cos(x)
            var f = T.Function(x, T.Grad(y, x));

            AssertAreCoherents(Cos, f);
        }