Beispiel #1
0
        static void SecondProblem(VecNd vec, int M)
        {
            int N = vec.Dimension;

            if (bLogging)
            {
                Console.WriteLine(vec.ToString());
            }
            Thread[] threads = new Thread[M];
            for (int i = 0; i < M; i++)
            {
                threads[i] = new Thread(() => {
                    for (int j = i * (N / M); j < (i + 1 != M ? (i + 1) * (N / M) : N); j++)
                    {
                        vec.SetElement(j, Function(vec.Matrix[j], multiplier));
                    }
                });
                threads[i].Start();
                threads[i].Join();
            }
            if (bLogging)
            {
                Console.WriteLine(vec.ToString());
            }
        }
        public VecNd Copy()
        {
            VecNd result = new VecNd(N);

            Array.Copy(this.mtx, result.mtx, N);
            return(result);
        }
        public VecNd RandomInt(int from, int to)
        {
            Random random = new Random();
            VecNd  result = new VecNd(N);

            for (int i = 0; i < N; i++)
            {
                result.mtx[i] = random.Next(from, to);
            }
            return(result);
        }
Beispiel #4
0
        static void FirstProblem(VecNd vec)
        {
            int N = vec.Dimension;

            if (bLogging)
            {
                Console.WriteLine(vec.ToString());
            }
            for (int i = 0; i < vec.Dimension; i++)
            {
                vec.SetElement(i, Function(vec.Matrix[i], multiplier));
            }
            if (bLogging)
            {
                Console.WriteLine(vec.ToString());
            }
        }