Exemple #1
0
        public Vec GetColumn(int index)
        {
            if (index < 0 || index > Rows[0].GetSize())
            {
                throw new IndexOutOfRangeException("index должен быть от 0 до " + Rows[0].GetSize());
            }

            Vec columnVector = new Vec(Rows.Length);

            for (int i = 0; i < Rows.Length; i++)
            {
                columnVector.SetComponent(i, Rows[i].GetComponent(index));
            }

            return(columnVector);
        }
Exemple #2
0
        public Vec MultiplyByVector(Vec vector)
        {
            if (GetСolumnsCount() != vector.GetSize())
            {
                throw new ArgumentException("Количество столбцов матрицы должно быть равно длинне вектора ");
            }

            Vec vectorResult = new Vec(vector.GetSize());

            for (int i = 0; i < vector.GetSize(); i++)
            {
                double sum = 0;

                for (int j = 0; j < Rows.Length; j++)
                {
                    sum += Rows[i].GetComponent(j) * vector.GetComponent(j);
                }

                vectorResult.SetComponent(i, sum);
            }

            return(vectorResult);
        }