sw/benchmarks/src/ocean.c
// nearest-neigbour Jacobi computation with 9-point Moore neigbourhood
nearest-neigbour Jacobi computation with 9-point Moore neigbourhood
nearest - neigbour Jacobi computation with 9 - point Moore neigbourhood
void jacobian(double **result, double **x, double **y, double factor, 
    int lastrow, int lastcol)
{
    int i, j;
    for (i=1; i<=lastrow; i++) {
        for (j=1; j<=lastcol; j++) {
    	    result[i][j] = factor *
    	        ( (y[i  ][j-1] +y[i+1][j-1] -y[i  ][j+1] -y[i+1][j+1]) * 
    	    	    (x[i+1][j  ] -x[i  ][j  ])
    		+ (y[i-1][j-1] +y[i  ][j-1] -y[i-1][j+1] -y[i  ][j+1]) *
    		    (x[i  ][j  ] -x[i-1][j  ])
    		+ (y[i+1][j  ] +y[i+1][j+1] -y[i-1][j  ] -y[i-1][j+1]) *
    		    (x[i  ][j+1] -x[i  ][j  ])
    		+ (y[i+1][j-1] +y[i+1][j  ] -y[i-1][j-1] -y[i-1][j  ]) *
    		    (x[i  ][j  ] -x[i  ][j-1])
    		+ (y[i+1][j  ] -y[i  ][j+1]) * (x[i+1][j+1] -x[i  ][j  ])
    		+ (y[i  ][j-1] -y[i-1][j  ]) * (x[i  ][j  ] -x[i-1][j-1])
    		+ (y[i  ][j+1] -y[i-1][j  ]) * (x[i-1][j+1] -x[i  ][j  ])
    		+ (y[i+1][j  ] -y[i  ][j-1]) * (x[i  ][j  ] -x[i+1][j-1]));
        }
    }
}
void jacobian ( double * * result , double * * x , double * * y , double factor , int lastrow , int lastcol ) { int i , j ; for ( i = 1 ; i <= lastrow ; i ++ ) { for ( j = 1 ; j <= lastcol ; j ++ ) { result [ i ] [ j ] = factor * ( ( y [ i ] [ j - 1 ] + y [ i + 1 ] [ j - 1 ] - y [ i ] [ j + 1 ] - y [ i + 1 ] [ j + 1 ] ) * ( x [ i + 1 ] [ j ] - x [ i ] [ j ] ) + ( y [ i - 1 ] [ j - 1 ] + y [ i ] [ j - 1 ] - y [ i - 1 ] [ j + 1 ] - y [ i ] [ j + 1 ] ) * ( x [ i ] [ j ] - x [ i - 1 ] [ j ] ) + ( y [ i + 1 ] [ j ] + y [ i + 1 ] [ j + 1 ] - y [ i - 1 ] [ j ] - y [ i - 1 ] [ j + 1 ] ) * ( x [ i ] [ j + 1 ] - x [ i ] [ j ] ) + ( y [ i + 1 ] [ j - 1 ] + y [ i + 1 ] [ j ] - y [ i - 1 ] [ j - 1 ] - y [ i - 1 ] [ j ] ) * ( x [ i ] [ j ] - x [ i ] [ j - 1 ] ) + ( y [ i + 1 ] [ j ] - y [ i ] [ j + 1 ] ) * ( x [ i + 1 ] [ j + 1 ] - x [ i ] [ j ] ) + ( y [ i ] [ j - 1 ] - y [ i - 1 ] [ j ] ) * ( x [ i ] [ j ] - x [ i - 1 ] [ j - 1 ] ) + ( y [ i ] [ j + 1 ] - y [ i - 1 ] [ j ] ) * ( x [ i - 1 ] [ j + 1 ] - x [ i ] [ j ] ) + ( y [ i + 1 ] [ j ] - y [ i ] [ j - 1 ] ) * ( x [ i ] [ j ] - x [ i + 1 ] [ j - 1 ] ) ) ; } } }
nearest-neigbour Jacobi computation with 9-point Moore neigbourhood
nearest - neigbour Jacobi computation with 9 - point Moore neigbourhood