Cody

Problem 43007. Euclidean inter-point distance matrix

Solution 1531497

Submitted on 17 May 2018
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Fail
A = eye(3); y_correct = (1-A)*sqrt(2); tol = 10*eps; assert(norm(interDist(A)-y_correct) < tol)

Undefined function 'dist' for input arguments of type 'double'. Error in interDist (line 4) dist(A'); Error in Test1 (line 4) assert(norm(interDist(A)-y_correct) < tol)

2   Fail
A = (1:4)'; y_correct = [ 0 1 2 3;... 1 0 1 2;... 2 1 0 1;... 3 2 1 0]; tol = 10*eps; assert(norm(interDist(A)-y_correct) < tol)

Undefined function 'dist' for input arguments of type 'double'. Error in interDist (line 4) dist(A'); Error in Test2 (line 7) assert(norm(interDist(A)-y_correct) < tol)

3   Fail
A = magic(3); y_correct = [0 6.48074069840786 9.79795897113271; ... 6.48074069840786 0 6.48074069840786; ... 9.79795897113271 6.48074069840786 0]; tol = 1000*eps; assert(norm(interDist(A)-y_correct) < tol)

Undefined function 'dist' for input arguments of type 'double'. Error in interDist (line 4) dist(A'); Error in Test3 (line 6) assert(norm(interDist(A)-y_correct) < tol)

4   Fail
A = reshape((1:20).^2,4,5); tol = 1e-12; y_correct = [0 49.4469412603045 102.761860629321 160.015624237135; ... 49.4469412603045 0 53.3385414123783 110.634533487515; ... 102.761860629321 53.3385414123783 0 57.3149195236284; ... 160.015624237135 110.634533487515 57.3149195236284 0]; assert(norm(interDist(A)-y_correct) < tol)

Undefined function 'dist' for input arguments of type 'double'. Error in interDist (line 4) dist(A'); Error in Test4 (line 7) assert(norm(interDist(A)-y_correct) < tol)