Example #1
0
        /// <summary> Assembly using addValues</summary>
        /// <param name="nu">Maximum number of entries
        /// </param>
        /// <returns> Dense representation (not a direct copy)
        /// </returns>
        public static double[] addsAssembleVector(IElementalAccessVector x, int nu)
        {
            int n = x.Length;

            double[]      data = new double[n];
            System.Random r    = new System.Random();

            int[]    ind = TesterUtilities.getIntArray(nu, r);
            double[] arr = TesterUtilities.getDoubleArray(ind.Length, r);
            for (int i = 0; i < ind.Length; ++i)
            {
                data[ind[i]] += arr[i];
            }
            x.AddValues(ind, arr);
            return(data);
        }
Example #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);
            }
        }