URGENT! PLEASE HELP! returning a 2-D matrix after processing

http://www.cplusplus.com/ico/forum_default.png

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
typedef double (*Matrix)[imax][jmax];

Matrix xboundary(){
    Matrix xx;
    double x[imax][jmax];
    int i;
    
    x[0][jmax-1]=xmin;
    x[0][0]=xmin;
    
    for (i=1;i<imax;i++){
        x[i][jmax-1]=x[i-1][jmax-1]+((xmax-xmin)/(imax-1));

    }
    
    for (i=1;i<11;i++){
        x[i][0]=x[i-1][0]+(0-xmin/(11-1));
        if ((x[i][0]) > -0.0001 )
            x[i][0]=0;

    }
    
    
    for (i=11;i<31;i++){
        x[i][0]=x[i-1][0] + 0.05;
    }
    
    
    for (i=31;i<41;i++){
        x[i][0]=x[i-1][0]+((xmax-1)/(41-31));
    }
    
    xx=&x; // I know this is completely wrong but would like to return 'x'
    
    
    return xx;
    
}



All I want to do is be able to Return "x" in some way. I know I m doing it completely wrong but any kind of help would be appreciated. Thanks
Last edited on
You could pass the 2d array in as a parameter. Or you could define a Matrix class. In C++11, the move semantics will allow you to return such an object with very little overhead.
Topic archived. No new replies allowed.