matrix calculation problem..

H

harryos

hi
while using colt matrices( (http://acs.lbl.gov/~hoschek/colt/)) to do
some image processing calculations i ran into some problems
I am trying to normalise(i don't know if that is the right word) a 1D
array of doubles by dividing each element with the max element of the
array using primitive arrays i can do it like below
<snippet>
double[] origArray=new double[]{....//some double values//..};
double arraymax=Double.MIN_VALUE;
for(int i=0;i<origArray.length;i++){
arraymax=(origArray>arraymax)? origArray:arraymax;


}
for(int i=0;i<origArray.length;i++){
origArray/=arraymax;
}
</snippet>
in the modified origArray a sample value i got using debug option in
eclipse is 0.1450980392156863

I did the same using colt matrices
<snippet>
DoubleMatrix1D origmat=new DenseDoubleMatrix1D(origArray);
cern.jet.math.Functions F = cern.jet.math.Functions.functions;
origmat.assign(F.div(inputfacemax));
</snippet>

this does the job,but i found that the corresponding sample value is
0.14509803921568626..this happens in some elements only. ..most
elements are identical to those when primitive arrays were
used ..This difference causes a difference in final results in my
program..
for example i need to get minimum value from a double[] that has some
values of distances (of a comparison of images)calculated using
matrices (or for loops in the case of primitive arrays..)

suppose the array is
[0.0, 0.0234567, 0.567834,0.134234] it means that min distance is 0.0
and the image is a perfect match..This was the case when i used
primitive arrays and loops to do the calculation

but if i use colt matrices as above ..i get
[6.162975822039155E-33,0.0234567, 0.567834,0.134234]
so for a perfect match of images i will be reporting the distance as
6.162975822039155E-33 instead of 0.0.
This is frustrating...Can someone tell me how i can solve this..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,001
Messages
2,570,254
Members
46,850
Latest member
VMRKlaus8

Latest Threads

Top