Web服务乘以2个2D矩阵

时间:2011-06-21 17:19:51

标签: c# web-services

我写的方法乘以2矩阵:

[WebMethod]
    public void MultiplyMatrix(double[,] _A,double[,] _B,int _n,int _m,int _r, out double[,] C)
    {
        int n, m, r;
        n = _n;
        m = _m;
        r = _r;
        double[,] A = new double[n,m];
        double[,] B = new double[m,r];
        C = new double[n,r];
        A = _A;
        B = _B;
        try 
        {
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < r; j++)
                {
                    for (int k = 0; k < m; k++)
                    {
                        C[i, j] += A[i, k] * B[k, j];   
                    }
                }
            }
        }
            catch(IndexOutOfRangeException){}
    }

我想知道在方法中MultiplyMatrix应该是参数输出双[,] C还是我犯了错误?

感谢任何消化:)

1 个答案:

答案 0 :(得分:2)

如果你只是返回一件事就会返回一个值。

即:

public double[,]  MultiplyMatrix(
                                  double[,] _A,
                                  double[,] _B,
                                  int _n,
                                  int _m,
                                  int _r,)