• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Aplus类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: WalkItems

        /// <summary>
        /// 
        /// </summary>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <param name="env"></param>
        private AType WalkItems(AType left, AType right, Aplus env)
        {
            AType result;
            if (left.Rank > 1)
            {
                result = AArray.Create(ATypes.AArray);
                foreach (AType a in left)
                {
                    result.Add(WalkItems(a, right, env));
                }
            }
            else if (right.Rank > 1)
            {
                result = AArray.Create(ATypes.AArray);
                foreach (AType b in right)
                {
                    result.Add(WalkItems(left, b, env));
                }
            }
            else
            {
                result = Calculate(left, right, env);
            }

            return result;
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:32,代码来源:InnerProduct.cs


示例2: Execute

        public override AType Execute(AType rightArgument, AType leftArgument, Aplus environment = null)
        {
            if (leftArgument.Type != ATypes.AInteger)
            {
                throw new Error.Type(this.TypeErrorText);
            }

            AType left = Function.Monadic.MonadicFunctionInstance.Ravel.Execute(leftArgument);
            AType right = Function.Monadic.MonadicFunctionInstance.Ravel.Execute(rightArgument);

            AType result;

            switch (CheckVector(left))
            {
                case State.NullFound:
                    // Found a zero in the list, create an emtpy list with correct shape
                    result = CreateResult(left, right);
                    result.Shape = new List<int>(left.Select(item => { return item.asInteger; }));
                    result.Rank = result.Shape.Count;
                    result.Length = result.Shape[0];
                    break;
                case State.DomainError:
                    throw new Error.Domain(this.DomainErrorText);
                case State.MaxRankError:
                    throw new Error.MaxRank(this.MaxRankErrorText);

                default:
                case State.OK:
                    result = CreateResult(left, right);
                    break;
            }

            return result;
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:34,代码来源:Reshape.cs


示例3: AplusScope

        public AplusScope(AplusScope parent,
            string name,
            Aplus runtime = null,
            DLR.ParameterExpression runtimeParam = null,
            DLR.ParameterExpression moduleParam = null,
            DLR.LabelTarget returnTarget = null,
            bool isEval = false,
            bool isMethod = false,
            bool isAssignment = false)
        {
            this.parent = parent;
            this.name = name;
            this.runtime = runtime;
            this.runtimeParam = runtimeParam;
            this.moduleParam = moduleParam;

            this.returnTarget = returnTarget;

            this.variables = new Dictionary<string, DLR.ParameterExpression>();

            this.callbackInfo = new CallbackInfoStorage();

            this.iseval = isEval;

            this.ismethod = isMethod;
            this.isAssignment = isAssignment;

            InheritProperties(parent);
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:29,代码来源:AplusScope.cs


示例4: Execute

        public override AType Execute(AType argument, Aplus environment)
        {
            AType result;

            if (argument.SimpleArray())
            {
                result = argument.IsMemoryMappedFile ? argument : argument.Clone();
            }
            else
            {
                if (!argument.NestedArray())
                {
                    throw new Error.Domain(DomainErrorText);
                }

                switch (argument.Rank)
                {
                    case 0:
                        result = MonadicFunctionInstance.Disclose.Execute(argument);
                        break;
                    case 1:
                        result = NestedVector(argument);
                        break;
                    default:
                        throw new Error.Rank(RankErrorText);
                }
            }

            return result;
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:30,代码来源:Raze.cs


示例5: StringSearchandReplace

        internal static AType StringSearchandReplace(Aplus environment, AType replaceWith, AType replaceWhat, AType replaceIn)
        {
            if (replaceIn.Type != ATypes.AChar || replaceWhat.Type != ATypes.AChar || replaceWith.Type != ATypes.AChar)
            {
                throw new Error.Type("_ssr");
            }

            string withString = Monadic.MonadicFunctionInstance.Ravel.Execute(replaceWith, environment).ToString();
            string whatString = Monadic.MonadicFunctionInstance.Ravel.Execute(replaceWhat, environment).ToString();
            AType argument = (withString.Length == whatString.Length)
                ? replaceIn.Clone() : Monadic.MonadicFunctionInstance.Ravel.Execute(replaceIn, environment);

            Queue<string> rows = new Queue<string>();
            ExtractRows(argument, rows);

            Queue<string> replacedRows = new Queue<string>();

            foreach (string item in rows)
            {
                string replaced = item.Replace(whatString, withString);
                replacedRows.Enqueue(replaced);
            }

            AType result = BuildAType(replacedRows, argument.Shape);
            return result;

        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:27,代码来源:StringSearchandReplace.cs


示例6: Execute

        public AType Execute(AType function, AType n, AType right, AType left, Aplus environment = null)
        {
            if (!(function.Data is AFunc))
            {
                throw new Error.NonFunction("Rank");
            }

            AFunc func = (AFunc)function.Data;

            if (!func.IsBuiltin)
            {
                if (func.Valence - 1 != 2)
                {
                    throw new Error.Valence("Rank");
                }
            }

            int[] rankSpecifier = GetRankSpecifier(n, left, right, environment);
            RankJobInfo rankInfo = new RankJobInfo(rankSpecifier, func);

            AType result = Walker(left, right, environment, rankInfo);

            if (rankInfo.FloatConvert && result.IsArray)
            {
                result.ConvertToFloat();
            }

            return result;
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:29,代码来源:Rank.cs


示例7: Import

        public static AType Import(Aplus environment, AType argument)
        {
            if (argument.Type != ATypes.AChar)
            {
                throw new Error.Type("sys.imp");
            }

            if (argument.Rank > 1)
            {
                throw new Error.Rank("sys.imp");
            }

            List<byte> toConvert = new List<byte>();

            if (argument.Rank == 0)
            {
                throw new Error.Domain("sys.imp"); // One character can't be a valid message.
            }

            foreach (AType item in argument)
            {
                toConvert.Add((byte)item.asChar);
            }

            return SysImp.Instance.Import(toConvert.ToArray());
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:26,代码来源:ContextSys.cs


示例8: Execute

        public override AType Execute(AType right, AType left, Aplus environment = null)
        {
            bool resultFromBox;

            AType result = Compute(environment, right, left, out resultFromBox);
            return result;
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:7,代码来源:Pick.cs


示例9: AssignExecute

        public PickAssignmentTarget AssignExecute(AType right, AType left, Aplus environment = null)
        {
            bool resultFromBox;

            AType result = Compute(environment, right, left, out resultFromBox);
            return new PickAssignmentTarget(result, resultFromBox);
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:7,代码来源:Pick.cs


示例10: GetNumber

        private int GetNumber(AType argument, AType n, Aplus environment)
        {
            if (n.Type != ATypes.AInteger)
            {
                throw new Error.Type("Rank");
            }

            int length = n.Shape.Product();

            if (length > 3)
            {
                throw new Error.Length("Rank");
            }

            AType raveledArray = MonadicFunctionInstance.Ravel.Execute(n, environment);
            int result = raveledArray[0].asInteger;

            if (result < 0)
            {
                result = Math.Max(0, argument.Rank - Math.Abs(result));
            }
            else
            {
                result = Math.Min(result, argument.Rank);
            }

            return result;
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:28,代码来源:Rank.cs


示例11: GetPath

        /// <summary>
        /// Gets the absolute path for the supplied <see cref="pathArgument"/>.
        /// </summary>
        /// <remarks>
        /// The search for the file relies on the APATH environment variable.
        /// </remarks>
        /// <param name="environment"></param>
        /// <param name="pathArgument">Must be a Char or Symbol type.</param>
        /// <param name="expectedExtension"></param>
        /// <returns>The absolute path for the file or if not found null.</returns>
        internal static string GetPath(Aplus environment, AType pathArgument, string expectedExtension)
        {
            string path = GetFullPathOrValue(pathArgument, environment);
            string resultPath = null;

            if (path != null && !Path.IsPathRooted(path))
            {
                string apath = Environment.GetEnvironmentVariable("APATH", EnvironmentVariableTarget.User);
                string absolutePath;

                foreach (string item in apath.Split(';'))
                {
                    absolutePath = Path.Combine(item, path);

                    if (!Path.IsPathRooted(absolutePath))
                    {
                        absolutePath = Path.GetFullPath(absolutePath);
                    }

                    if (FileSearch(absolutePath, expectedExtension, out resultPath))
                    {
                        break;
                    }
                }
            }
            else
            {
                FileSearch(path, expectedExtension, out resultPath);
            }

            return resultPath;
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:42,代码来源:Util.cs


示例12: InitContext

        public static void InitContext(Aplus environment)
        {
            AipcService service = new AipcService(environment);
            service.StartNetworkLoop();

            environment.SetService<AipcService>(service);
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:7,代码来源:ContextI.cs


示例13: PermissiveIndexingSubIndex

        private static AType PermissiveIndexingSubIndex(
            AType index, AType array, AType defaultItem, Aplus environment)
        {
            AType result = AArray.Create(array.Type);

            if (index.IsArray)
            {
                for (int i = 0; i < index.Length; i++)
                {
                    result.Add(PermissiveIndexingSubIndex(index[i], array, defaultItem, environment));
                }
            }
            else if (index.asInteger > array.Length - 1 || index.asInteger < 0)
            {
                if (defaultItem.Rank == 0 && array[0].Rank != 0)
                {
                    result = DyadicFunctionInstance.Reshape.Execute(defaultItem, array[0].Shape.ToAArray(), environment);
                }
                else
                {
                    result = defaultItem;
                }
            }
            else
            {
                result = array[index];
            }

            return result;
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:30,代码来源:PermissiveIndexing.cs


示例14: Execute

        public override AType Execute(AType right, AType left, Aplus environment = null)
        {
            if (left.Rank < 1 || right.Rank < 1)
            {
                throw new Error.Rank(this.RankErrorText);
            }

            if (left.Shape[left.Shape.Count - 1] != right.Shape[0])
            {
                throw new Error.Length(this.LengthErrorText);
            }

            // Calculate the axes for the right argument: (-1 rot iota rho rho right)
            AType targetAxes = DyadicFunctionInstance.Rotate.Execute(
                Enumerable.Range(0, right.Rank).ToAArray(), AInteger.Create(-1), environment);

            AType transposedRight = DyadicFunctionInstance.TransposeAxis.Execute(right, targetAxes, environment);

            AType result = WalkItems(left, transposedRight, environment);

            // by observation it seems that the reference implementation always returns float
            // we behave the same
            result.ConvertToFloat();

            if (result.Length == 0)
            {
                result.Shape = new List<int>(left.Shape.GetRange(0, left.Shape.Count - 1));
                if (right.Shape.Count > 1)
                {
                    result.Shape.AddRange(right.Shape.GetRange(1, right.Shape.Count - 1));
                }
            }
            
            return result;
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:35,代码来源:InnerProduct.cs


示例15: Execute

        public AType Execute(AType functionScalar, AType argument, Aplus environment = null)
        {
            //'Disclose' the function from functionscalar.
            AFunc function = (AFunc)functionScalar.NestedItem.Data;

            //Convert method to the correspond function format.
            if (function.IsBuiltin)
            {
                Func<Aplus, AType, AType, AType> primitiveFunction =
                    (Func<Aplus, AType, AType, AType>)function.Method;

                return primitiveFunction(environment, argument, null);
            }
            else
            {
                //If function is user defined, we check the valance.
                if (function.Valence - 1 != 1)
                {
                    throw new Error.Valence("Apply");
                }

                //Convert method to the correspond function format.
                Func<Aplus, AType, AType> userDefinedFunction =
                    (Func<Aplus, AType, AType>)function.Method;

                return userDefinedFunction(environment, argument);
            }
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:28,代码来源:Apply.cs


示例16: Execute

        public override AType Execute(AType right, AType left, Aplus environment = null)
        {
            int desiredCount = PrepareDesiredCount(left);
            AType items = PrepareInputItems(right);

            return Compute(items, desiredCount);
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:7,代码来源:Take.cs


示例17: Execute

        public override AType Execute(AType argument, Aplus environment = null)
        {
            SetVariables(argument);

            AType result;

            //First dimension equal with zero case (as Null).
            if (argument.Length == 0)
            {
                result = argument.Clone();
                result.Type = this.type;
            }
            else
            {
                //Accepted types are float and integer.
                if (argument.Type != ATypes.AFloat && argument.Type != ATypes.AInteger)
                {
                    throw new Error.Type(TypeErrorText);
                }

                result = argument.IsArray ? ScanAlgorithm(argument) : PreProcess(argument);
            }

            return result;
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:25,代码来源:Scan.cs


示例18: Items

        internal static AType Items(Aplus environment, AType memoryMappedFileName, AType number)
        {
            string resultPath = Util.GetPath(environment, memoryMappedFileName, ".m");

            if (resultPath == null)
            {
                throw new Error.Domain("Items");
            }

            int newLeadingAxesLength = GetLeadingAxesLength(number);

            if (newLeadingAxesLength == -1)
            {
                return environment.MemoryMappedFileManager.GetLeadingAxesLength(resultPath);
            }
            else
            {
                if (environment.MemoryMappedFileManager.ExistMemoryMappedFile(resultPath))
                {
                    throw new Error.Invalid("Items");
                }

                return environment.MemoryMappedFileManager.ExpandOrDecrease(resultPath, newLeadingAxesLength);
            }
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:25,代码来源:Items.cs


示例19: SetVariable

        /// <summary>
        /// Constructs a DLR Expression tree representing setting a variable inside a context.
        /// </summary>
        /// <param name="runtime"></param>
        /// <param name="variableContainer">The container where the lookup should be performed</param>
        /// <param name="contextParts">
        /// Contains 2 strings:
        ///  1. The name of the context
        ///  2. The name of the variable inside the context
        /// </param>
        /// <param name="value">Expression containing the value of the variable</param>
        /// <remarks>
        /// The returned DLR Expression tree will try to fetch the context inside the container.
        /// If the context does not exists, this will result an exception.
        /// If the exception occured, the context will be created inside the catch block.
        /// After this the context surely exists, so we can simply set the variable to the provided value.
        /// 
        /// </remarks>
        /// <returns>>Expression tree for setting a value for the given context parts</returns>
        internal static DLR.Expression SetVariable(Aplus runtime, DLR.Expression variableContainer, string[] contextParts, DLR.Expression value)
        {
            // Get the context
            DLR.Expression getContext =
                DLR.Expression.TryCatch(
                    DLR.Expression.Dynamic(
                        runtime.GetMemberBinder(contextParts[0]),
                        typeof(object),
                        variableContainer
                    ),
                    DLR.Expression.Catch(
                // Context not found, create one!
                        typeof(Error.Value),
                        DLR.Expression.Dynamic(
                            runtime.SetMemberBinder(contextParts[0]),
                            typeof(object),
                            variableContainer,
                            DLR.Expression.Constant(new ScopeStorage())
                        )
                    )
                );

            DLR.Expression setVariable = DLR.Expression.Dynamic(
                runtime.SetMemberBinder(contextParts[1]),
                typeof(object),
                getContext,
                value
            );
            return setVariable;
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:49,代码来源:VariableHelper.cs


示例20: Execute

        public override AType Execute(AType right, AType left, Aplus environment = null)
        {
            // First we check if one side is an ANull
            if (right.Type == ATypes.ANull)
            {
                return AArray.Create(left.Type, left.Clone());
            }
            else if (left.Type == ATypes.ANull)
            {
                return AArray.Create(right.Type, right.Clone());
            }

            // Type check
            if(!Utils.IsSameGeneralType(left, right))
            {
                throw new Error.Type(this.TypeErrorText);
            }

            AType result = CreateResult(right, left);

            // Convert to float if one of the arguments is an AFloat and the other is an AInteger
            if (Utils.DifferentNumberType(left, right))
            {
                result.ConvertToFloat();
            }

            return result;
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:28,代码来源:Catenate.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# App类代码示例发布时间:2022-05-24
下一篇:
C# ApiResponse类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap