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

C# AType类代码示例

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

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



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


示例16: Compute

        /// <summary>
        /// Partition count.
        /// </summary>
        /// <param name="argument"></param>
        /// <returns></returns>
        private AType Compute(AType argument, byte[] vector)
        {
            AType result = AArray.Create(ATypes.AArray);

            // If argument is () than result is ().
            result.Type = (argument.Type == ATypes.ANull) ? ATypes.ANull : ATypes.AInteger;

            if (vector.Length > 0)
            {
                int length = 1;
                int counter = 0;

                for (int i = 1; i < vector.Length; i++)
                {
                    counter++;

                    if (vector[i] == 1)
                    {
                        length++;
                        result.AddWithNoUpdate(AInteger.Create(counter));
                        counter = 0;
                    }
                }

                counter++;
                result.AddWithNoUpdate(AInteger.Create(counter));

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

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


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


示例18: PrepareVariables

        /// <summary>
        /// Prepare the left side and determine the cellshape.
        /// </summary>
        /// <param name="left"></param>
        /// <param name="right"></param>
        private CalculationArguments PrepareVariables(AType left, AType right)
        {
            // Error if the arguments:
            //  - are boxes
            //  - or not of the same type and:
            //    - not numbers
            //    - or one of them is a Null
            if (left.IsBox || right.IsBox ||
                (left.Type != right.Type &&
                !(Utils.DifferentNumberType(left, right) || left.Type == ATypes.ANull || right.Type == ATypes.ANull)
            ))
            {
                throw new Error.Type(TypeErrorText);
            }

            CalculationArguments arguments = new CalculationArguments()
            {
                Interval = left,
                CellShape = (left.Rank > 1 && left.Length > 0) ? left[0].Shape : new List<int>()
            };

            if (right.Rank < arguments.CellShape.Count)
            {
                throw new Error.Rank(RankErrorText);
            }

            return arguments;
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:33,代码来源:Bins.cs


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


示例20: CreateMemmoryMappedFile

        /// <summary>
        /// Create a memory-mapped file with the given path and argument.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="argument"></param>
        public void CreateMemmoryMappedFile(string path, AType argument)
        {
            GC.Collect();
            GC.WaitForPendingFinalizers();

            string memoryMappedFileName = EncodeName(path);
            MemoryMappedFile memoryMappedFile;

            try
            {
                memoryMappedFile = MemoryMappedFile.CreateFromFile(
                    new FileStream(path, FileMode.Create),
                    memoryMappedFileName,
                    MappedFile.ComputeSize(argument),
                    MemoryMappedFileAccess.ReadWrite,
                    new MemoryMappedFileSecurity(),
                    HandleInheritability.Inheritable,
                    false
                );

            }
            catch (Exception)
            {
                throw new Error.Invalid("MemoryMappedFile");
            }

            MappedFile mappedFile = new MappedFile(memoryMappedFile);

            mappedFile.Create(argument);
            mappedFile.Dispose();
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:36,代码来源:MemoryMappedFileManager.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# AVPixelFormat类代码示例发布时间:2022-05-24
下一篇:
C# ASTPair类代码示例发布时间: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