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


C# MatrixValue.Randomize方法代码示例

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


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

示例1: MatrixBenchmark

        static void MatrixBenchmark()
        {
            Console.WriteLine("Running matrix benchmarks ...");
            //var n = 1000;
            //var m = 1000;

            for (var n = 20; n <= 500; n += 20)
            {
                var m = n;
                var A = new YAMP.MatrixValue(n, m);
                var B = new YAMP.MatrixValue(m, n);
                A.Randomize();
                B.Randomize();

                A[n, m] = YAMP.ScalarValue.One;
                B[m, n] = YAMP.ScalarValue.One;

                var sw = Stopwatch.StartNew();
                var C =  A * B;
                sw.Stop();

                #region Outputs

                //---
                // Output for usual multiplication
                //---
                //Time for n = 20, m = 20 : 22 ms
                //Time for n = 40, m = 40 : 222 ms
                //Time for n = 60, m = 60 : 1328 ms
                //Time for n = 80, m = 80 : 3107 ms
                //Time for n = 100, m = 100 : 8244 ms
                // stop ...

                //---
                // Output for BLAS L3 multiplication (1st order approx.)
                //---
                //Time for n = 20, m = 20 : 7 ms
                //Time for n = 40, m = 40 : 8 ms
                //Time for n = 60, m = 60 : 28 ms
                //Time for n = 80, m = 80 : 51 ms
                //Time for n = 100, m = 100 : 135 ms
                //Time for n = 120, m = 120 : 273 ms
                //Time for n = 140, m = 140 : 281 ms
                //Time for n = 160, m = 160 : 387 ms
                //Time for n = 180, m = 180 : 585 ms
                //Time for n = 200, m = 200 : 845 ms
                //Time for n = 220, m = 220 : 1196 ms
                //Time for n = 240, m = 240 : 1709 ms
                //Time for n = 260, m = 260 : 2318 ms
                //Time for n = 280, m = 280 : 2451 ms
                //Time for n = 300, m = 300 : 2771 ms
                // and so on !

                //---
                /// Output for copying arrays only (required for perf. BLAS L3)
                //---
                //Time for n = 20, m = 20 : 7 ms
                //Time for n = 40, m = 40 : 15 ms
                //Time for n = 60, m = 60 : 20 ms
                //Time for n = 80, m = 80 : 37 ms
                //Time for n = 100, m = 100 : 78 ms
                //Time for n = 120, m = 120 : 158 ms
                //Time for n = 140, m = 140 : 207 ms
                //Time for n = 160, m = 160 : 276 ms
                //Time for n = 180, m = 180 : 411 ms
                //Time for n = 200, m = 200 : 628 ms
                //Time for n = 220, m = 220 : 897 ms
                //Time for n = 240, m = 240 : 1271 ms
                //Time for n = 260, m = 260 : 1703 ms
                //Time for n = 280, m = 280 : 1956 ms
                //Time for n = 300, m = 300 : 1974 ms
                // and so on !

                #endregion

                Console.WriteLine("Time for n = {0}, m = {1} : {2} ms", n, m, sw.ElapsedMilliseconds);
            }

            Console.WriteLine("Finished !");
        }
开发者ID:FlorianRappl,项目名称:YAMP,代码行数:80,代码来源:Benchmarks.cs


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