Hi, I'm new to this forum and C#.
I try to make an array that each is the sum of the value of each row in sims array.
It gives me nothing but zero. Please help. TIA.

public double[] ave_S(int M, int N, double S, double sig, double dt, double[,] R, double r)
        {
            double[,] sims = GetSim(M, N, S, sig, dt, R, r); 
            double[] temp = new double[M];

            for (int i = 0; i < M; i++)
            {
                double temp_val = 0;

                for (int j = 0; j < N; j++)
                {
                    temp_val += sims[i, j];
                    
                }
                temp[i] = temp_val;      
                      
            }
            return temp;
        }

Recommended Answers

All 3 Replies

One or more of M, N and/or sims is equal to zero. Or you have the amazing coincidence that the sum of each row is zero.

Check out the parameters you pass to this function and also check the Getsims() function other than them this code has no problem

Thank both of you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.