E
ElissaT
Hi all,
I'm trying to build the following sums with an Array A[640][480]:
j=rows i=cols
Sum Sum ((A[j]-A[i+1][j])*(A[j]-A[i+1][j]))+((A[j]-A[j
+1])*(A[j]-A[j+1]))
j=0 i=0
where the first sum runs from j=0 to j=number of rows and the second
sum from i=0 to i= number of columns.
As a test I first build the sum with a smaller array A[3][4] this way:
#include <iostream>
#include <ios>
#include <cmath>
using namespace std;
int main()
{
double Sum;
double A[3][4]={{ 1, -2, 3, 4},{ 5, -6, 7, -8},{ 9, -10, 11, 12}};
for (int j=0; j<3; j++) {
Sum = 0.0;
for (int i=0; i<4; i++){
Sum += ((A[j] - A[i+1][j]) * (A[j] - A[i+1][j]))+((A[j] - A
[j+1]) *(A[j] - A[j+1]));
}
}
cout<< scientific<< Sum <<endl;
return 0;
}
I don't understand why the result displayed by the console is :
1.#QNAN
Is something wrong with the code?
Thank you
Lisa
I'm trying to build the following sums with an Array A[640][480]:
j=rows i=cols
Sum Sum ((A[j]-A[i+1][j])*(A[j]-A[i+1][j]))+((A[j]-A[j
+1])*(A[j]-A[j+1]))
j=0 i=0
where the first sum runs from j=0 to j=number of rows and the second
sum from i=0 to i= number of columns.
As a test I first build the sum with a smaller array A[3][4] this way:
#include <iostream>
#include <ios>
#include <cmath>
using namespace std;
int main()
{
double Sum;
double A[3][4]={{ 1, -2, 3, 4},{ 5, -6, 7, -8},{ 9, -10, 11, 12}};
for (int j=0; j<3; j++) {
Sum = 0.0;
for (int i=0; i<4; i++){
Sum += ((A[j] - A[i+1][j]) * (A[j] - A[i+1][j]))+((A[j] - A
[j+1]) *(A[j] - A[j+1]));
}
}
cout<< scientific<< Sum <<endl;
return 0;
}
I don't understand why the result displayed by the console is :
1.#QNAN
Is something wrong with the code?
Thank you
Lisa