We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Compare matrix

ZURINET
ZURINET asked
on
Medium Priority
242 Views
Last Modified: 2012-06-27
Hi all
I have this matrix

double[][] arrayInput = {{1,0,1}};
double [][] arrayWeight = {{0.2,1.5,2.}};

arrayWeight = arrayInput
arrayWeight < arrayInput
arrayWeight > arrayInput


I am looking for a method that can help me compare both values
and return the result

public static double getEculideanDistance(double [][]arrayInput, double [][] arrayWeight)
{
retrun result;
}

Thanks in Advance
Comment
Watch Question

Awarded 2011
Awarded 2011

Commented:
I'm not sure there is one general definition in math - what
matrix is bigger than another, or what os the distance between matrices
if you want to compare them element by element and
calculate sum of squares of the distances that is how you do it:


public static double getEculideanDistance(double [][]arrayInput, double [][] arrayWeight) {

double output = 0.0;

    for (int row = 0; row < arrayInput.length; row++) {
            for (int col = 0; col < arrayInput[row].length; col++) {
                output += (arrayInput[row][col]-arrayWeight[row][col])*(arrayInput[row][col]-arrayWeight[row][col]);
            }
         
        }
     return Math.sqrt(output);
}
I'm not quite sure though that to the method it passes dimensions of two dimnsional array correctly,
you can then pass dimensions as integers

Awarded 2011
Awarded 2011
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
ozo
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2015

Commented:
what does arrayWeight < arrayInput mean?

Author

Commented:
Hallo Van

Thanks a lot

regards

Author

Commented:
Perfect
Awarded 2011
Awarded 2011

Commented:
You are always welcome
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.