/// <summary> Column-wise assembly using addValues</summary>
        /// <param name="nu">Maximum bandwidth on each column
        /// </param>
        /// <returns> Dense representation (not a direct copy)
        /// </returns>
        public static double[,] addsAssembleColumnMatrix(IElementalAccessMatrix A, int nu)
        {
            int n = A.RowCount, m = A.ColumnCount;

            double[,] data = new double[n, m];
            //			for (int i = 0; i < n; i++)
            //			{
            //				data[i] = new double[m];
            //			}
            System.Random r = new System.Random();

            for (int i = 0; i < m; ++i)
            {
                int[] row = TesterUtilities.getIntArray(nu, r), col = TesterUtilities.getIntArray(m, r);
                double[,] entry = TesterUtilities.getDoubleArray(row.Length, col.Length, r);
                for (int ii = 0; ii < row.Length; ++ii)
                {
                    for (int jj = 0; jj < col.Length; ++jj)
                    {
                        data[row[ii], col[jj]] += entry[ii, jj];
                    }
                }
                A.AddValues(row, col, entry);
            }

            return(data);
        }
Exemple #2
0
        private void assemble(IElementalAccessMatrix A, IElementalAccessVector b, double K, double f)
        {
            int    n = b.Length - 1;
            double h = 1.0 / ((double)n);

            double[,] Ae = new double[, ] {
                { K / h, (-K) / h }, { (-K) / h, K / h }
            };
            double[] be = new double[] { f *h / 2.0, f *h / 2.0 };

            for (int i = 0; i < n; ++i)
            {
                int[] ind = new int[] { i, i + 1 };
                A.AddValues(ind, ind, Ae);
                b.AddValues(ind, be);
            }
        }