当前位置: 首页>>代码示例>>C#>>正文


C# System.Function类代码示例

本文整理汇总了C#中System.Function的典型用法代码示例。如果您正苦于以下问题:C# Function类的具体用法?C# Function怎么用?C# Function使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Function类属于System命名空间,在下文中一共展示了Function类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: JakobiMatrix

        public static Matrix JakobiMatrix(Vector x, Function[] f, double precision)
        {
            if ((f.Length > 0) && (x.Length > 0) && (precision > 0))
            {

                Matrix J = new Matrix(f.Length, x.Length);
                Vector temp = x.Clone() as Vector;

                for (int counter1 = 0; counter1 < J.Height; counter1++)
                {
                    for (int counter2 = 0; counter2 < J.Width; counter2++)
                    {
                        temp[counter2] += precision;

                        J[counter1][counter2] = (f[counter1](temp) - f[counter1](x)) / precision;

                        temp[counter2] -= precision;
                    }
                }

                return J;
            }
            else
            {
                throw new IncorrectIncomingDataException("Dimensions of delegates or vectors or precision are incorrect.");
            }
        }
开发者ID:rtym,项目名称:Computing-Math,代码行数:27,代码来源:DiffrerntialOperators.cs

示例2: VerificationException

 /// <summary>
 /// Creates a new verification exception
 /// </summary>
 /// <param name="message">The message</param>
 /// <param name="function">The function being verified</param>
 /// <param name="instruction">The instruction being verified</param>
 /// <param name="index">The index of the instruction</param>
 public VerificationException(string message, Function function, Instruction instruction, int index)
     : base($"{index}: {message}")
 {
     this.Function = function;
     this.Instruction = instruction;
     this.InstructionIndex = index;
 }
开发者ID:svenslaggare,项目名称:XONEVirtualMachine,代码行数:14,代码来源:Verifier.cs

示例3: BuildDeclarations

 private static void BuildDeclarations(Namespace @namespace, IEnumerable<Declarations.Declaration> declarations)
 {
     foreach(var declaration in declarations)
         declaration.Match()
             .With<NamespaceDeclaration>(ns =>
             {
                 var childNamespace = new Namespace(ns.Syntax, @namespace, ns.Name);
                 @namespace.Add(childNamespace);
                 BuildDeclarations(childNamespace, ns.Members);
             })
             .With<ClassDeclaration>(@classDecl =>
             {
                 var syntax = @classDecl.Syntax.Single(); // TODO handle partial classes
                 var @class = new Class(syntax, @namespace, syntax.Accessibility, @classDecl.Name);
                 @namespace.Add(@class);
             })
             .With<FunctionDeclaration>(@functionDeclaration =>
             {
                 var syntax = @functionDeclaration.Syntax.Single(); // TODO handle overloads
                 var function = new Function(syntax, @namespace, syntax.Accessibility, @functionDeclaration.Name);
                 @namespace.Add(function);
             })
             // TODO handle ambigouous declarations
             .Exhaustive();
 }
开发者ID:adamant-deprecated,项目名称:AdamantExploratoryCompiler,代码行数:25,代码来源:PackageSemanticsBuilder.cs

示例4: FixGetterSetter

      public static void FixGetterSetter(this Type type)
      {         
         var methods = type.GetInstanceMethodNames(); 

         foreach(string methname in methods)
         {
            if(methname.StartsWith("get_"))
            {
               string propname = methname.Substring(4);
               bool has_setter = methods.Contains("set_"+propname);

               Function fget = new Function("",string.Format("return this.get_{0}();",propname));
               Function fset = new Function("value",string.Format("this.set_{0}(value);",propname));
               
               if(has_setter)
               {
                  defineprop(type, propname,fget,fset);
               }
               else
               {
                  definepropreadonly(type, propname, fget);
               }
            }
         }
      }
开发者ID:uddesh,项目名称:Saltarelle.AngularJS,代码行数:25,代码来源:FixGetterSetter.cs

示例5: FunctionInliner

 public FunctionInliner(Function root)
 {
     _root = root;
     _funStack.Push(root);
     _sim = new ScopedIdentifierManager(true);
     _locals = new CacheDictionary<Tuple<Function, IStorableLiteral>, IStorableLiteral>(CreateLocal);
 }
开发者ID:venusdharan,项目名称:systemsharp,代码行数:7,代码来源:FunctionInlining.cs

示例6: Call

        private Ref Call(Function function)
        {
            try
            {
                foreach(var statement in function.Body)
                {
                    var returnValue = Execute(statement);
                    if(returnValue != null)
                        // TODO check that the reference ownership and mutablilty match the return type
                        // TODO constrain value to return type
                        // TODO constrain integer values to bits of return type
                        return returnValue;
                }

                // Reached end without return
                if(function.ReturnType.Type is VoidType)
                    return voidReference.Borrow();

                throw new InterpreterPanicException("Reached end of function without returning value");
            }
            catch(InterpreterPanicException ex)
            {
                ex.AddCallStack(function.QualifiedName());
                throw;
            }
        }
开发者ID:adamant-deprecated,项目名称:AdamantExploratoryCompiler,代码行数:26,代码来源:AdamantInterpreter.cs

示例7: TestInvalidMain

        public void TestInvalidMain()
        {
            using (var container = new Win64Container())
            {
                var intType = container.VirtualMachine.TypeProvider.GetPrimitiveType(PrimitiveTypes.Int);

                var mainFunc = new Function(
                    new FunctionDefinition("main", new List<VMType>() { intType }, intType),
                    new List<Instruction>()
                    {
                        new Instruction(OpCodes.LoadInt, 0),
                        new Instruction(OpCodes.Ret)
                    },
                    new List<VMType>());

                try
                {
                    container.LoadAssembly(Assembly.SingleFunction(mainFunc));
                    Assert.Fail("Expected invalid main to not pass.");
                }
                catch (Exception e)
                {
                    Assert.AreEqual("Expected the main function to have the signature: 'main() Int'.", e.Message);
                }
            }
        }
开发者ID:svenslaggare,项目名称:XONEVirtualMachine,代码行数:26,代码来源:TestFunctions.cs

示例8: Window

		///
		/// <summary> * Create a window function for a given sample size. This preallocates
		/// * resources appropriate to that block size.
		/// *  </summary>
		/// * <param name="size"> The number of samples in a block that we will
		/// *                      be asked to transform. </param>
		/// * <param name="function"> The window function to use. Function.RECTANGULAR
		/// *                      effectively means no transformation. </param>
		///
		public Window(int size, Function function)
		{
			blockSize = size;

			// Create the window function as an array, so we do the
			// calculations once only. For RECTANGULAR, leave the kernel as
			// null, signalling no transformation.
			kernel = function == Function.RECTANGULAR ? null : new double[size];

			switch (function)
			{
				case Function.RECTANGULAR:
					// Nothing to do.
					break;
				case Function.BLACKMAN_HARRIS:
					makeBlackmanHarris(kernel, size);
					break;
				case Function.GAUSS:
					makeGauss(kernel, size);
					break;
				case Function.WEEDON_GAUSS:
					makeWeedonGauss(kernel, size);
					break;
			}
		}
开发者ID:LuckyLuik,项目名称:AudioVSTToolbox,代码行数:34,代码来源:Window.cs

示例9: CreateFunctionImportMappingCommand

 internal CreateFunctionImportMappingCommand(EntityContainerMapping em, Function function, string createFuncImpCmdId)
     : base(PrereqId)
 {
     ContainerMapping = em;
     Function = function;
     _createFuncImpCmdId = createFuncImpCmdId;
 }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:7,代码来源:CreateFunctionImportMappingCommand.cs

示例10: CreateSimpleFunction

        //TODO: get this near functiontest. This is not a general function.
        public static IFunction CreateSimpleFunction(IFunctionStore store)
        {
            var function = new Function("test");

            store.Functions.Add(function);

            // initialize schema
            IVariable x = new Variable<double>("x", 3);
            IVariable y = new Variable<double>("y", 2);
            IVariable f1 = new Variable<double>("f1");

            function.Arguments.Add(x);
            function.Arguments.Add(y);
            function.Components.Add(f1);


            // write some data
            var xValues = new double[] {0, 1, 2};
            var yValues = new double[] {0, 1};
            var fValues = new double[] {100, 101, 102, 103, 104, 105};

            function.SetValues(fValues,
                               new VariableValueFilter<double>(x, xValues),
                               new VariableValueFilter<double>(y, yValues),
                               new ComponentFilter(f1));
            return function;
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:28,代码来源:TestHelper.cs

示例11: EventBubbleCorerctlyForFunctionWithReducedArgument

        [Category(TestCategory.Jira)] //TOOLS-4934
        public void EventBubbleCorerctlyForFunctionWithReducedArgument()
        {
            IFunction function = new Function
                                     {
                                         Arguments = {new Variable<int>("x1"), new Variable<int>("x2")},
                                         Components = {new Variable<int>("f")}
                                     };

            function[0, 1] = new[] {1};
            function[0, 2] = new[] {2};
            function[1, 1] = new[] {3};
            function[1, 2] = new[] {4};

            var arg1 = function.Arguments[0];

            var filteredFunction = function.Filter(new VariableValueFilter<int>(arg1, 0), new VariableReduceFilter(arg1));
            
            int called = 0;

            filteredFunction.ValuesChanged += (s, e) => called++;

            function[0, 2] = 3; //set value

            Assert.AreEqual(1, called);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:26,代码来源:FunctionTest.cs

示例12: ClassifyOperator

        public static CXXOperatorArity ClassifyOperator(Function function)
        {
            if (function.Parameters.Count == 1)
                return CXXOperatorArity.Unary;

            return CXXOperatorArity.Binary;
        }
开发者ID:jijamw,项目名称:CppSharp,代码行数:7,代码来源:Utils.cs

示例13: CheckDefaultParametersForAmbiguity

        private static bool CheckDefaultParametersForAmbiguity(Function function, Function overload)
        {
            var commonParameters = Math.Min(function.Parameters.Count, overload.Parameters.Count);

            var i = 0;
            for (; i < commonParameters; ++i)
            {
                var funcParam = function.Parameters[i];
                var overloadParam = overload.Parameters[i];

                if (!funcParam.QualifiedType.Equals(overloadParam.QualifiedType))
                    return false;
            }

            for (; i < function.Parameters.Count; ++i)
            {
                var funcParam = function.Parameters[i];
                if (!funcParam.HasDefaultValue)
                    return false;
            }

            for (; i < overload.Parameters.Count; ++i)
            {
                var overloadParam = overload.Parameters[i];
                if (!overloadParam.HasDefaultValue)
                    return false;
            }

            if (function.Parameters.Count > overload.Parameters.Count)
                overload.ExplicitlyIgnore();
            else
                function.ExplicitlyIgnore();

            return true;
        }
开发者ID:daxiazh,项目名称:CppSharp,代码行数:35,代码来源:CheckAmbiguousFunctions.cs

示例14: WriteFunctionTitle

		protected void WriteFunctionTitle( StreamWriter stream, Function function )
		{
			stream.Write( "//-----------------------------------------------------------------------------" );
			stream.WriteLine( "// Function Name: " + function.Name );
			stream.WriteLine( "//Function Desc: " + function.Description );
			stream.WriteLine( "//-----------------------------------------------------------------------------" );
		}
开发者ID:ryan-bunker,项目名称:axiom3d,代码行数:7,代码来源:ProgramWriter.cs

示例15: invokeInternal

        /**
         * Formats nicer error messages for the junit output
         */
        private static double invokeInternal(Function target, ValueEval[] args, int srcCellRow, int srcCellCol)
        {
            ValueEval EvalResult = null;
            try
            {
                EvalResult = target.Evaluate(args, srcCellRow, (short)srcCellCol);
            }
            catch (NotImplementedException e)
            {
                throw new NumericEvalEx("Not implemented:" + e.Message);
            }

            if (EvalResult == null)
            {
                throw new NumericEvalEx("Result object was null");
            }
            if (EvalResult is ErrorEval)
            {
                ErrorEval ee = (ErrorEval)EvalResult;
                throw new NumericEvalEx(formatErrorMessage(ee));
            }
            if (!(EvalResult is NumericValueEval))
            {
                throw new NumericEvalEx("Result object type (" + EvalResult.GetType().Name
                        + ") is invalid.  Expected implementor of ("
                        + typeof(NumericValueEval).Name + ")");
            }

            NumericValueEval result = (NumericValueEval)EvalResult;
            return result.NumberValue;
        }
开发者ID:JnS-Software-LLC,项目名称:npoi,代码行数:34,代码来源:NumericFunctionInvoker.cs


注:本文中的System.Function类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。