Cody

# Problem 451. Is this matrix orthogonal?

Solution 1571435

Submitted on 29 Jun 2018 by Srishti Saha
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   Pass
x = orth(randn(3)); y_correct = true; assert(isequal(isOrthogonal(x),y_correct))

tr = 0 1 1 0 -1 1 1 0 0 iv = 0 1 1 0 -1 1 1 0 0 res = logical 1

2   Pass
x = orth(randn(4)); y_correct = true; assert(isequal(isOrthogonal(x),y_correct))

tr = 1 0 0 0 1 1 0 0 0 0 1 0 0 0 0 1 iv = 1 0 0 0 1 1 0 0 0 0 1 0 0 0 0 1 res = logical 1

3   Pass
x = orth(randn(5)); y_correct = true; assert(isequal(isOrthogonal(x),y_correct))

tr = -1 0 0 -1 0 0 0 1 0 1 0 -1 0 0 0 1 0 0 -1 0 0 0 -1 0 1 iv = -1 0 0 -1 0 0 0 1 0 1 0 -1 0 0 0 1 0 0 -1 0 0 0 -1 0 1 res = logical 1

4   Pass
x=sqrt([3,1;1,1]); y_correct = false; assert(isequal(isOrthogonal(x),y_correct))

tr = 2 1 1 1 iv = 1 -1 -1 2 res = logical 0

5   Pass
x = magic(6); y_correct = false; assert(isequal(isOrthogonal(x),y_correct))

tr = 35 3 31 8 30 4 1 32 9 28 5 36 6 7 2 33 34 29 26 21 22 17 12 13 19 23 27 10 14 18 24 25 20 15 16 11 [Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 8.001607e-19.] [> In isOrthogonal (line 3) In ScoringEngineTestPoint5 (line 3) In solutionTest (line 11)] iv = 1.0e+15 * 2.2518 0 -2.2518 -2.2518 0 2.2518 2.2518 0 -2.2518 -2.2518 0 2.2518 -1.1259 0 1.1259 1.1259 0 -1.1259 -2.2518 0 2.2518 2.2518 0 -2.2518 -2.2518 0 2.2518 2.2518 0 -2.2518 1.1259 0 -1.1259 -1.1259 0 1.1259 res = logical 0

6   Pass
x = randn(2)+1; y_correct = false; assert(isequal(isOrthogonal(x),y_correct))

tr = 1 1 0 0 iv = 0 0 -1 1 res = logical 0