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


C# AType类代码示例

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


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

示例1: PrepareExpandVector

        private byte[] PrepareExpandVector(AType left)
        {
            // if the left side is User defined function, we throw Valence error.
            // this part belongs to Scan.
            if (left.Type == ATypes.AFunc)
            {
                throw new Error.Valence(ValenceErrorText);
            }

            if (!(left.Type == ATypes.AFloat || left.Type == ATypes.AInteger || left.Type == ATypes.ANull))
            {
                throw new Error.Type(TypeErrorText);
            }

            if (left.Rank > 1)
            {
                throw new Error.Rank(RankErrorText);
            }

            //int element;
            AType scalar;

            byte[] expandVector;

            if (left.TryFirstScalar(out scalar, true))
            {
                expandVector = new byte[] { ExtractExpandArgument(scalar) };
            }
            else
            {
                expandVector = left.Select(item => ExtractExpandArgument(item)).ToArray();
            }

            return expandVector;
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:35,代码来源:Expand.cs

示例2: GetLeadingAxesLength

        private static int GetLeadingAxesLength(AType argument)
        {
            if (!argument.IsNumber)
            {
                throw new Error.Type("Items");
            }

            AType result;
            if (!argument.TryFirstScalar(out result, true))
            {
                throw new Error.Length("Items");
            }


            int number;
            if (!result.ConvertToRestrictedWholeNumber(out number))
            {
                throw new Error.Type("Items");
            }

            if (number != -1 && number < 0)
            {
                throw new Error.Domain("Items");
            }

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

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

示例4: VectorIndexing

        /// <summary>
        /// 
        /// </summary>
        /// <param name="indexers">List containing all of the indexes</param>
        /// <param name="indexpos"></param>
        /// <param name="currentIdx">Array containing the current indexes</param>
        /// <returns></returns>
        public static AType VectorIndexing(this AType input, List<AType> indexers, int indexpos, AType currentIdx, bool isAssign, bool isMemoryMapped)
        {
            if (currentIdx.Length == 0)
            {
                // A Null item found!, select all of the current items
                for (int i = 0; i < input.Length; i++)
                {
                    currentIdx.Add(AInteger.Create(i));
                }
            }

            // Create an array for the results
            AType result = AArray.Create(input.Type);

            // Iterate over the indexes
            foreach (AType index in currentIdx)
            {
                AType item =
                    index.IsArray ?
                    input.VectorIndexing(indexers, indexpos, index, isAssign, isMemoryMapped) :
                    input.SimpleIndex(indexers, indexpos, index, isAssign, isMemoryMapped);

                result.AddWithNoUpdate(item);
            }

            result.UpdateInfo();
            return result;
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:35,代码来源:Utils.cs

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

示例6: GetCutNumber

        private int GetCutNumber(AType right, AType left)
        {
            if (!(left.Type == ATypes.AFloat || left.Type == ATypes.AInteger || left.Type == ATypes.ANull))
            {
                throw new Error.Type(this.TypeErrorText);
            }
            
            AType scalar;
            int cutValue;

            // get the first scalar value with length check on
            if (!left.TryFirstScalar(out scalar, true))
            {
                throw new Error.Nonce(this.NonceErrorText);
            }

            // check if the scalar is a whole number and set the desired count of items
            if (!left.ConvertToRestrictedWholeNumber(out cutValue))
            {
                throw new Error.Type(this.TypeErrorText);
            }

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

            if (right.Rank == 0 && cutValue != 1)
            {
                throw new Error.Rank(RankErrorText);
            }

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

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

示例8: GetIndexes

        private List<AType> GetIndexes(AType left, AType right)
        {
            List<AType> indexes = new List<AType>();

            if (left.IsBox)
            {
                //Ravel left side box array, if rank > 1.
                AType raveled = left.Rank > 1 ? MonadicFunctionInstance.Ravel.Execute(left) : left;

                //length of the left argument greater than the rank of the right argument, raise Rank error.
                if (raveled.Length > right.Rank)
                {
                    throw new Error.Rank(RankErrorText);
                }

                //Nested case: x[0 pick y; 1 pick y; ...; (-1 + #y) pick y]
                for (int i = 0; i < raveled.Length; i++)
                {
                    indexes.Add(DyadicFunctionInstance.Pick.Execute(raveled, AInteger.Create(i)));
                }
            }
            else
            {
                //Simple case: x[y;...;]
                indexes.Add(left);
            }

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

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

示例10: CheckZeroPerZero

 /// <summary>
 /// Checks if the division's arguments are 0
 /// </summary>
 private void CheckZeroPerZero(AType right, AType left)
 {
     if (right.asFloat == 0.0 && left.asFloat == 0.0)
     {
         throw new Error.Domain(DomainErrorText);
     }
 }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:10,代码来源:Divide.cs

示例11: GetDropCounter

        private int GetDropCounter(AType element)
        {
            if (element.Type == ATypes.AFloat || element.Type == ATypes.AInteger)
            {
                AType scalar;

                // Get the first scalar value with length check on
                if (!element.TryFirstScalar(out scalar, true))
                {
                    throw new Error.Nonce(this.NonceErrorText);
                }

                int dropCounter;
                // Check if the scalar is a whole number and set the drop counter
                if (!scalar.ConvertToRestrictedWholeNumber(out dropCounter))
                {
                    throw new Error.Type(this.TypeErrorText);
                }

                return dropCounter;
            }
            else if (element.Type == ATypes.ANull)
            {
                throw new Error.Nonce(this.NonceErrorText);
            }
            else
            {
                throw new Error.Type(this.TypeErrorText);
            }
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:30,代码来源:Drop.cs

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

示例13: Compute

        /// <summary>
        /// Convert Character constant array to symbol array.
        /// </summary>
        /// <param name="argument"></param>
        /// <returns></returns>
        private AType Compute(AType argument)
        {
            //If argument is character constant or character constant vector then we convert it symbol,
            //and cut blanks from end.
            if (argument.Rank <= 1)
            {
                return ASymbol.Create(argument.ToString().TrimEnd());
            }
            else
            {
                AType result = AArray.Create(ATypes.ASymbol);

                foreach (AType item in argument)
                {
                    result.AddWithNoUpdate(Compute(item));
                }

                result.Length = argument.Length;
                result.Shape = new List<int>();
                result.Shape.AddRange(argument.Shape.GetRange(0, argument.Shape.Count - 1));
                result.Rank = argument.Rank - 1;

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

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

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


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