Passing Matrix as Parameter Row by Row

Typechecker

Member
Joined
Mar 24, 2013
Messages
5
Programming Experience
Beginner
Hey,

I have a matrix and it stores N dimensional vectors inside it.

Example : int[,] numbers = new int[3, 2] { {1, 2}, {3, 4}, {5, 6} }; Assume that each row is a 2 dimensional vector.Normally I will compute as N dimension.

I compute distance between them by using Euclidean formula but I apply Euclidan in Main.Normally,I compute this element by element.I would like to send parameter to Euclidean Function row by row.

Example:

for(int i=0;i<3;i++)
{
for(int j=0;j<2;j++)
{
anymatrix[i,j]=Euclidean(vector,vector [j])
}
}

I have javascript code below exactly what i want to do.I used Generic List to do this in C# but I couldnt' handle.Can you help me with this issue?

function EuclideanDistance (vec1 , vec2) {
var N = vec1.length ;
var d = 0 ;
for (var i = 0 ; i < N ; i++)
d += Math.pow (vec1[i] - vec2[i], 2)
d = Math.sqrt (d) ;
return d ;
}

for (i = 0 ; i < N ; i++) {
for (j = 0 ; j < N ; j++) {
if (i == j)
anyMatrix[i][j] = Infinity ;
else
anyMatrix[i][j] = EuclideanDistance(vectors[i] , vectors[j]) ;
}
}
 
Top Bottom