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


C# AType.Clone方法代码示例

本文整理汇总了C#中AType.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# AType.Clone方法的具体用法?C# AType.Clone怎么用?C# AType.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AType的用法示例。


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

示例1: CreateLaminateJob

        /// <summary>
        /// </summary>
        /// <param name="right"></param>
        /// <param name="left"></param>
        private LaminateJobInfo CreateLaminateJob(AType right, AType left)
        {
            LaminateJobInfo laminateInfo =
                new LaminateJobInfo(left.Length != 0 ? left.Type : right.Type);
            
            if (left.IsArray && !right.IsArray)
            {
                laminateInfo.Left = left.Clone();
                laminateInfo.Right = DyadicFunctionInstance.Reshape.Execute(right, left.Shape.ToAArray());
            }
            else if (!left.IsArray && right.IsArray)
            {
                laminateInfo.Right = right.Clone();
                laminateInfo.Left = DyadicFunctionInstance.Reshape.Execute(left, right.Shape.ToAArray());
            }
            else
            {
                laminateInfo.Right = right.Clone();
                laminateInfo.Left = left.Clone();
            }

            // check if the types are same

            if (right.Type != left.Type)
            {
                if (left.Type == ATypes.AFloat && right.Type == ATypes.AInteger)
                {
                    right = right.ConvertToFloat();
                }
                else if (left.Type == ATypes.AInteger && right.Type == ATypes.AFloat)
                {
                    left = left.ConvertToFloat();
                }
                else if (!(Utils.IsSameGeneralType(left, right) 
                    || left.Type == ATypes.ANull || right.Type == ATypes.ANull))
                {
                    throw new Error.Type(TypeErrorText);
                }
            }

            // check the length, shape and rank
            if (laminateInfo.Left.Rank != laminateInfo.Right.Rank)
            {
                throw new Error.Rank(RankErrorText);
            }

            if (!laminateInfo.Left.Shape.SequenceEqual(laminateInfo.Right.Shape))
            {
                throw new Error.Length(LengthErrorText);
            }

            if (laminateInfo.Left.Rank >= 9 || laminateInfo.Right.Rank >= 9)
            {
                throw new Error.MaxRank(MaxRankErrorText);
            }

            return laminateInfo;
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:62,代码来源:Laminate.cs

示例2: 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

示例3: 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

示例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: 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

示例6: Compute

        private AType Compute(AType right, int dropCounter)
        {
            if (right.IsArray && dropCounter == 0)
            {
                return right.Clone();
            }

            AType result = AArray.Create(ATypes.AType);

            if (right.IsArray)
            {
                if (right.Length - Math.Abs(dropCounter) > 0)
                {
                    if (dropCounter > 0)
                    {
                        for (int i = dropCounter; i < right.Length; i++)
                        {
                            result.AddWithNoUpdate(right[i].Clone());
                        }
                    }
                    else
                    {
                        for (int i = 0; i < right.Length + dropCounter; i++)
                        {
                            result.AddWithNoUpdate(right[i].Clone());
                        }
                    }
                    result.Length = right.Length - Math.Abs(dropCounter);
                    result.Shape = new List<int>() { result.Length };
                    
                    if (right.Rank > 1)
                    {
                        result.Shape.AddRange(right.Shape.GetRange(1, right.Shape.Count - 1));
                    }

                    result.Rank = right.Rank;
                    result.Type = result[0].Type;
                }
                else
                {
                    result.Type = right.MixedType() ? ATypes.ANull : right.Type;
                }
            }
            else
            {
                if (dropCounter == 0)
                {
                    result.Add(right.Clone());
                    result.Length = 1;
                    result.Shape = new List<int>() { 1 };
                    result.Type = right.Type;
                }
                else
                {
                    result.Type = right.MixedType() ? ATypes.ANull : right.Type;
                }
            }
            return result;
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:59,代码来源:Drop.cs

示例7: Execute

 /// <summary>
 /// Transpose reduction to Transpose Axes.
 /// As follows: (rot iota rho rho x) flip x
 /// </summary>
 /// <param name="argument"></param>
 /// <returns></returns>
 public override AType Execute(AType argument, Aplus environment)
 {
     if (argument.IsArray)
     {
         AType transposeVector = Enumerable.Range(0, argument.Rank).Reverse().ToAArray();
         return DyadicFunctionInstance.TransposeAxis.Execute(argument, transposeVector);
     }
     else
     {
         return argument.Clone();
     }
 }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:18,代码来源:Transpose.cs

示例8: Alsf

        internal static AType Alsf(Aplus environment, AType input)
        {
            if (input.Rank > 1)
            {
                throw new Error.Rank("_alsf");
            }

            if (input.IsSlotFiller())
            {
                return input.Clone();
            }

            return (input.IsArray) ? ArrayInput(input) : NotArrayInput(input);
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:14,代码来源:Alsf.cs

示例9: Execute

        public override AType Execute(AType argument, Aplus environment = null)
        {
            if (argument.Type == ATypes.ANull)
            {
                return argument.Clone();
            }

            if (!argument.SimpleSymbolArray())
            {
                throw new Error.Type(TypeErrorText);
            }

            if (argument.Rank > 8)
            {
                throw new Error.MaxRank(MaxRankErrorText);
            }

            return Walk(argument);
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:19,代码来源:SeparateSymbols.cs

示例10: Execute

        public override AType Execute(AType argument, Aplus environment = null)
        {
            if (argument.SimpleArray())
            {
                //The argument is simple array/scalar and not mapped we clone it! 
                return argument.IsMemoryMappedFile ?
                    argument :
                    argument.Clone();
            }
            else
            {
                if (!argument.NestedArray())
                {
                    throw new Error.Domain(DomainErrorText);
                }

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

示例11: Execute

        public override AType Execute(AType right, AType left, Aplus environment = null)
        {
            AType result;
            int[] rotateVector = PrepareRotateVector(right, left);
            
            if (right.Rank == 0)
            {
                // if the right argument is scalar, we clone it
                result = right.Clone();
            }
            else if (right.Rank > 2)
            {
                result = TransformAndCompute(right, rotateVector);
            }
            else
            {
                result = Compute(right, rotateVector);
            }

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

示例12: SeparateSymbol

        /// <summary>
        /// Separate symbol constant by definiton.
        /// </summary>
        /// <param name="argument"></param>
        /// <returns></returns>
        private AType SeparateSymbol(AType argument)
        {
            AType result = AArray.Create(ATypes.ASymbol);
            string symbol = argument.asString;
            int index = symbol.LastIndexOf('.');

            if (index != -1)
            {
                result.AddWithNoUpdate(ASymbol.Create(symbol.Substring(0, index)));
                result.AddWithNoUpdate(ASymbol.Create(symbol.Substring(index + 1)));
            }
            else
            {
                result.AddWithNoUpdate(ASymbol.Create(""));
                result.AddWithNoUpdate(argument.Clone());
            }

            result.Length = 2;
            result.Shape = new List<int>() { 2 };
            result.Rank = 1;

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

示例13: Execute

        public override AType Execute(AType argument, Aplus environment = null)
        {
            if (argument.IsArray)
            {
                AType result = AArray.Create(ATypes.AArray);

                for (int i = argument.Length - 1;  i >= 0;  i--)
                {
                    result.AddWithNoUpdate(argument[i].Clone());
                }

                result.Length = argument.Length;
                result.Shape = new List<int>(argument.Shape);
                result.Rank = argument.Rank;
                result.Type = result.Length > 0 ? result[0].Type : ATypes.ANull;

                return result;
            }
            else
            {
                return argument.Clone();
            }
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:23,代码来源:Reverse.cs

示例14: ConvertToInt

        private AType ConvertToInt(AType argument)
        {
            AType result;

            switch (argument.Type)
            {
                case ATypes.AInteger:
                    result = argument.Clone();
                    break;
                case ATypes.AFloat:
                    result = ConvertFloatToInt(argument);
                    break;
                case ATypes.AChar:
                    result = ConvertCharToInt(argument, false);
                    break;
                case ATypes.ASymbol:
                    result = ConvertSymToInt(argument);
                    break;
                default:
                    throw new Error.Domain(this.DomainErrorText);
            }

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

示例15: PerformIndexAssign

        private static void PerformIndexAssign(AType target, AType value)
        {
            if (target.Rank > 0)
            {
                for (int i = 0; i < target.Length; i++)
                {
                    PerformIndexAssign(target[i], value.IsArray ? value[i] : value);
                }
            }
            else
            {
                AValue result;

                if (target.Type == value.Type)
                {
                    result = value.Clone().Data;
                }
                else if (target.Type == ATypes.AInteger && value.Type == ATypes.AFloat)
                {
                    int number;
                    if (!value.ConvertToRestrictedWholeNumber(out number))
                    {
                        throw new Error.Type("assign");
                    }

                    result = AInteger.Create(number).Data;
                }
                else if (target.Type == ATypes.AFloat && value.Type == ATypes.AInteger)
                {
                    result = AFloat.Create(value.asInteger).Data;
                }
                else
                {
                    throw new Error.Type("Assign");
                }

                if (target.IsMemoryMappedFile)
                {
                    ((IMapped)target.Data).Update(result);
                }
                else
                {
                    target.Data = result;
                }
            }
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:46,代码来源:Utils.cs


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