示例#1
0
        public void TestIf()
        {
            // There is no such thing as a logical literal
            const double trueDouble  = 42;
            const double falseDouble = 666;

            var input    = Declare <MValue>("input");
            var output   = Declare <double>("output");
            var function = CompileFunction <Func <MValue, double> >(
                input, output,
                new If(input,
                       new Literal(output, trueDouble),
                       new Literal(output, falseDouble)));

            Assert.AreEqual(trueDouble, function(MFullArray <double> .CreateScalar(1)));
            Assert.AreEqual(falseDouble, function(MFullArray <double> .CreateScalar(0)));
            Assert.AreEqual(falseDouble, function(MFullArray <double> .CreateRowVector(0, 0, 1, 0)));
            Assert.AreEqual(trueDouble, function(MFullArray <double> .CreateRowVector(1, 1, 1, 1)));
        }
示例#2
0
文件: MStrings.cs 项目: Sable/McCli
 public static MFullArray <char> FromString(string str)
 {
     Contract.Requires(str != null);
     return(MFullArray <char> .CreateRowVector(str.ToCharArray()));
 }