Re: Java vs C++ ?




It looks like that your have an array on which cells are marked
as "boundaries" or not. If not boundary, then the new value of
the cell xyValue[i][j]) at the next "iteration" is the average
of the 4 nearest neighbors at the previous state.
If this is what you want to do, then the algorithm is flawed
because the array is modified in place, which destroy the
values of the neighbor cells of lower index.

I wonder also why the second index depends on i instead of
j (see xyValue[0][i]).

Dan

Peter Christensen wrote:
"DP" <pfennige@xxxxxxxxxxxx> skrev i en meddelelse news:45b61c0d$1@xxxxxxxxxxxxxxxx

Peter Christensen wrote:
I've been writing my simulation program in Java 2, and I didn't see this at a problem before. But now I would like to do some more precise analysis, and now the computers performance is an important limiting factor. -I used Java 2 as the programming language, even though I know that C++ would be faster, partly because I like the Java language, but also because I did't have a C++ compiler at the moment.

I just wonder, if I can really win something by writing the critical part of my program in C++ instead of Java. How much could that be?

The only part of my program, which is really time-consuming is this:

public static float iteration() {
float newValue;
float errorSum = 0;
for (int i=0;i<xRange;i++) {
for (int j=0;j<yRange;j++) {
if (!xyBound[i][j]) {
if (j == 0) {
newValue = (xyValue[i+1][0]+xyValue[i-1][0]
+xyValue[i][1]+xyValue[0][i])/4;
} else if (i == 0) {
newValue = (xyValue[1][j]+xyValue[j][0]
+xyValue[0][j+1]+xyValue[0][j-1])/4;
} else {
newValue = (xyValue[i+1][j]+xyValue[i-1][j]
+xyValue[i][j+1]+xyValue[i][j-1])/4;
}
errorSum += Math.abs(newValue - xyValue[i][j]);
xyValue[i][j] = newValue;
}
}
}
return errorSum;
}
.



Relevant Pages

  • RE: excel formulas
    ... converts a number from euros to a euro member ... Counts the cells that contain numbers in a database ... Specifies a logical test to perform ... Looks in the top row of an array and returns the value of the indicated cell ...
    (microsoft.public.excel.misc)
  • Re: excel formulas
    ... member currency, or converts a number from one euro member currency ... Counts the cells that contain numbers in a database ... Specifies a logical test to perform ... Looks in the top row of an array and returns the value of the ...
    (microsoft.public.excel.misc)
  • Re: Excel Cell Formats
    ... Disable the update of excel. ... Copy the cells from this new sheet to my selection ... Someone suggested that I create a dummy 2D array containing my ... new ordering, but for my selection only, not the entire row. ...
    (microsoft.public.excel.programming)
  • Re: Array Declaration Problem ??
    ... cells B11:B14:: numerical values ... Function Zroots2 (ar As Range, ai As Range, m As Integer, polish As String) ... instead of returning the array 3 results to the 3 vertical cells. ...
    (microsoft.public.excel.programming)
  • Re: Excel Macro Filtered Data in-place: cannot calculate Frequency of Visible Cells
    ... What you could do, perhaps, is to use the Advanced Filter, set a criteria ... I have implemented your suggestion for a separate> named range object SET to the original range that contains the whole> un-filtered list, ... But the data> returned is still based on the whole un-filtered list and not the> filtered, Visible Cells only. ... >>> Returns a frequency distribution as a vertical array. ...
    (microsoft.public.excel.programming)

Quantcast