0

I have a matrix which is 2 by 11 which I need to concatenate to a m by 11 matrix. Currently I have an event which triggers this operation. I am quite new to C# and haven't done some matrix manipulation so the answer may be very simple.

private double[,] A;

private void Window_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
    {
        //variables xk,yk,zk ... assigned here
        double[,] a = { { xk, yk, zk, 1, 0, 0, 0, 0, xkxp, ykxp, zkxp }, { 0, 0, 0, 0, xk, yk, zk, 1, xkyp, ykyp, zkyp} };
        if (A == null)
        {
           //On the first event A will be null
            A = a;
        }
        else
        {
            //Concatenate A and a here
            a.CopyTo(A, A.Length);
        }
    }

Would it be easier if I broke variable "a" into two separate rows? What is the indexing that I need to use?

The A matrix needs to stay or become a double[,] for the operation that I apply to it. The operation doesn't need to happen till the matrix is 'complete' at the end of the program. I thought about just creating an array and then reshaping at the end but I'm not sure how to do this.

4

1 回答 1

1

我认为在这种情况下您需要手动执行此操作。但是,由于您要在矩阵末尾添加空行,这应该不难。如果您将矩阵声明为(示例)

double[][] a = new[] { new double[7], new double[7]  };

您甚至可以单独处理行。

我建议您编写(或使用)特定的矩阵类,而不是使用普通的双精度数组。然后,您可以向该类添加所需的功能。

于 2013-10-22T11:45:05.707 回答