Exemplo n.º 1
0
        /// <summary>
        /// 返回与x矩阵同名的零方阵
        /// </summary>
        /// <param name="s">行列数</param>
        /// <param name="x">命名阵</param>
        /// <returns>返回的矩阵</returns>
        public static Matrix Zeros(int s, MNode[,] x)
        {
            ArrayList f = new ArrayList();

            for (int i = 0; i < s * s; f.Add(0), i++)
            {
                ;
            }
            return(Matrix.GenerateMatrix(s, f, x));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 返回与x矩阵同名的随机方阵
        /// </summary>
        /// <param name="s">行列数</param>
        /// <param name="n">命名阵</param>
        /// <returns>返回生成的矩阵</returns>
        public static Matrix Random(int s, MNode[,] n)
        {
            long tick = System.DateTime.Now.Ticks;

            //Random ran = new Random((int)(tick & 0xffffffffL) | (int)(tick >> 32));
            System.Random rand = new System.Random((int)(tick & 0xffffffffL) | (int)(tick >> 32));
            ArrayList     f    = new ArrayList();

            //for(int i = 0; i < s * s; f.Add(2 * rand.NextDouble() - 1), i++);
            for (int i = 0; i < s * s; f.Add(rand.NextDouble()), i++)
            {
                ;
            }
            //for (int i = 0; i < s * s; System.Console.Write(f[i]+"  "), i++);
            //System.Console.WriteLine();
            return(Matrix.GenerateMatrix(s, f, n));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 返回以n阵命名的单位阵
        /// </summary>
        /// <param name="s">行列数</param>
        /// <param name="n">命名阵</param>
        /// <returns>返回生成的单位阵</returns>
        public static Matrix Eye(int s, MNode[,] n)
        {
            ArrayList f = new ArrayList();
            int       x = 0;

            for (int i = 0; i < s * s; i++)
            {
                if (i == (s + 1) * x)
                {
                    f.Add(1);
                    x++;
                }
                else
                {
                    f.Add(0);
                }
            }
            return(Matrix.GenerateMatrix(s, f, n));
        }