Cody

Solution 1216699

Submitted on 20 Jun 2017 by Martin C.
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
a=reshape(1:36,6,[]); b=[sum(a(:,1:3),2) sum(a(:,4:6),2)]; m=matrix_crunch(a); assert(max(max(abs(m-b)))<1e-10)

nc = 6 y = 21 24 27 30 33 36 y = 21 75 24 78 27 81 30 84 33 87 36 90

2   Pass
a=magic(9)-30; b=[sum(a(:,1:3),2) sum(a(:,4:6),2) sum(a(:,7:9),2)]; m=matrix_crunch(a); assert(max(max(abs(m-b)))<1e-10)

nc = 9 y = 84 114 63 12 -48 -18 3 33 54 y = 84 3 114 -48 63 -27 12 3 -48 33 -18 63 3 93 33 114 54 63 y = 84 3 12 114 -48 33 63 -27 63 12 3 84 -48 33 114 -18 63 54 3 93 3 33 114 -48 54 63 -18

3   Pass
a=rand(12); b=[sum(a(:,1:3),2) sum(a(:,4:6),2) sum(a(:,7:9),2) sum(a(:,10:12),2)]; m=matrix_crunch(a); assert(max(max(abs(m-b)))<1e-10)

nc = 12 y = 1.6574 1.4233 2.0542 1.9713 1.7381 1.0828 1.2947 2.5020 1.3003 1.0845 1.4081 1.6817 y = 1.6574 1.5021 1.4233 1.1433 2.0542 1.5276 1.9713 1.4355 1.7381 0.4925 1.0828 2.0468 1.2947 2.3617 2.5020 0.7628 1.3003 1.6959 1.0845 1.0812 1.4081 0.7913 1.6817 1.2969 y = 1.6574 1.5021 1.8821 1.4233 1.1433 1.4477 2.0542 1.5276 1.2109 1.9713 1.4355 1.7456 1.7381 0.4925 1.7552 1.0828 2.0468 1.3441 1.2947 2.3617 1.2243 2.5020 0.7628 2.1626 1.3003 1.6959 0.8804 1.0845 1.0812 1.4828 1.4081 0.7913 1.9618 1.6817 1.2969 0.5423 y = 1.6574 1.5021 1.8821 2.3920 1.4233 1.1433 1.4477 0.4873 2.0542 1.5276 1.2109 2.1751 1.9713 1.4355 1.7456 1.1100 1.7381 0.4925 1.7552 1.4320 1.0828 2.0468 1.3441 1.3698 1.2947 2.3617 1.2243 2.0124 2.5020 0.7628 2.1626 2.3162 1.3003 1.6959 0.8804 1.0751 1.0845 1.0812 1.4828 2.3718 1.4081 0.7913 1.9618 1.8899 1.6817 1.2969 0.5423 1.8720

4   Pass
a=ones(18); b=3*ones(18,6); m=matrix_crunch(a); assert(max(max(abs(m-b)))<1e-10)

nc = 18 y = 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 y = 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 y = 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 y = 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 y = 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 y = 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3

5   Pass
a=magic(15)+j.*flipud(magic(15)); a=a(1:10,:)-rand(10,15); b=[sum(a(:,1:3),2) sum(a(:,4:6),2) sum(a(:,7:9),2) sum(a(:,10:12),2) sum(a(:,13:15),2)]; m=matrix_crunch(a); assert(max(max(abs(m-b)))<1e-10)

nc = 15 y = 1.0e+02 * 4.1596 + 3.6900i 4.6399 + 3.3600i 5.1206 + 2.8800i 5.5964 + 2.5500i 6.0680 + 2.0700i 4.3039 + 1.7400i 2.5257 + 1.2600i 0.7675 + 0.7800i 1.2503 + 2.5500i 1.7285 + 4.3200i y = 1.0e+02 * 4.1596 + 3.6900i 5.6910 + 5.2200i 4.6399 + 3.3600i 6.1647 + 4.7400i 5.1206 + 2.8800i 4.3999 + 4.2600i 5.5964 + 2.5500i 2.6171 + 3.7800i 6.0680 + 2.0700i 0.7030 + 3.3000i 4.3039 + 1.7400i 1.1805 + 2.8200i 2.5257 + 1.2600i 1.5171 + 2.3400i 0.7675 + 0.7800i 1.9938 + 2.0100i 1.2503 + 2.5500i 2.3258 + 1.5300i 1.7285 + 4.3200i 2.8095 + 1.2000i y = 1.0e+02 * 4.1596 + 3.6900i 5.6910 + 5.2200i 2.4101 + 4.3500i 4.6399 + 3.3600i 6.1647 + 4.7400i 0.6439 + 6.1200i 5.1206 + 2.8800i 4.3999 + 4.2600i 0.9797 + 5.7900i 5.5964 + 2.5500i 2.6171 + 3.7800i 1.4599 + 5.3100i 6.0680 + 2.0700i 0.7030 + 3.3000i 1.9387 + 4.8300i 4.3039 + 1.7400i 1.1805 + 2.8200i 2.4107 + 4.3500i 2.5257 + 1.2600i 1.5171 + 2.3400i 2.8873 + 3.8700i 0.7675 + 0.7800i 1.9938 + 2.0100i 3.3782 + 3.3900i 1.2503 + 2.5500i 2.3258 + 1.5300i 3.8569 + 2.9100i 1.7285 + 4.3200i 2.8095 + 1.2000i 4.3309 + 2.4300i y = 1.0e+02 * 4.1596 + 3.6900i 5.6910 + 5.2200i 2.4101 + 4.3500i 1.5488 + 1.0800i 4.6399 + 3.3600i 6.1647 + 4.7400i 0.6439 + 6.1200i 2.0245 + 0.6000i 5.1206 + 2.8800i 4.3999 + 4.2600i 0.9797 + 5.7900i 2.5085 + 2.3700i 5.5964 + 2.5500i 2.6171 + 3.7800i 1.4599 + 5.3100i 2.9780 + 4.1400i 6.0680 + 2.0700i 0.7030 + 3.3000i 1.9387 + 4.8300i 3.4616 + 6.0600i 4.3039 + 1.7400i 1.1805 + 2.8200i 2.4107 + 4.3500i 3.9428 + 5.5800i 2.5257 + 1.2600i 1.5171 + 2.3400i 2.8873 + 3.8700i 4.4266 + 5.2500i 0.7675 + 0.7800i 1.9938 + 2.0100i 3.3782 + 3.3900i 4.7550 + 4.7700i 1.2503 + 2.5500i 2.3258 + 1.5300i 3.8569 + 2.9100i 5.2370 + 4.4400i 1.7285 + 4.3200i 2.8095 + 1.2000i 4.3309 + 2.4300i 5.5577 + 3.9600i y = 1.0e+02 * 4.1596 + 3.6900i 5.6910 + 5.2200i 2.4101 + 4.3500i 1.5488 + 1.0800i 3.0835 + 2.6100i 4.6399 + 3.3600i 6.1647 + 4.7400i 0.6439 + 6.1200i 2.0245 + 0.6000i 3.4071 + 2.1300i 5.1206 + 2.8800i 4.3999 + 4.2600i 0.9797 + 5.7900i 2.5085 + 2.3700i 3.8843 + 1.6500i 5.5964 + 2.5500i 2.6171 + 3.7800i 1.4599 + 5.3100i 2.9780 + 4.1400i 4.2184 + 1.1700i 6.0680 + 2.0700i 0.7030 + 3.3000i 1.9387 + 4.8300i 3.4616 + 6.0600i 4.6852 + 0.6900i 4.3039 + 1.7400i 1.1805 + 2.8200i 2.4107 + 4.3500i 3.9428 + 5.5800i 5.0311 + 2.4600i 2.5257 + 1.2600i 1.5171 + 2.3400i 2.8873 + 3.8700i 4.4266 + 5.2500i 5.5000 + 4.2300i 0.7675 + 0.7800i 1.9938 + 2.0100i 3.3782 + 3.3900i 4.7550 + 4.7700i 5.9900 + 6.0000i 1.2503 + 2.5500i 2.3258 + 1.5300i 3.8569 + 2.9100i 5.2370 + 4.4400i 4.2095 + 5.5200i 1.7285 + 4.3200i 2.8095 + 1.2000i 4.3309 + 2.4300i 5.5577 + 3.9600i 2.4439 + 5.0400i

Suggested Problems

More from this Author80