Cody

# Problem 44258. Outer product of multiple vectors

Solution 1418535

Submitted on 17 Jan 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   Pass

2   Pass
y = outerProduct([],[]); assert(isempty(y))

y = []

3   Pass
x = randi(100); y = randi(100); assert(isequal(outerProduct(x,y),x*y))

y = 7553

4   Pass
x = randi(100,[1 100]); y = randi(100,[1 90]); assert(isequal(outerProduct(x,y),x.'*y)) assert(isequal(outerProduct(x.',y),x.'*y)) assert(isequal(outerProduct(x,y.'),x.'*y))

y = Columns 1 through 14 3680 1012 3404 4278 4600 2116 138 4048 1978 506 2760 4324 368 3312 320 88 296 372 400 184 12 352 172 44 240 376 32 288 7120 1958 6586 8277 8900 4094 267 7832 3827 979 5340 8366 712 6408 4720 1298 4366 5487 5900 2714 177 5192 2537 649 3540 5546 472 4248 3920 1078 3626 4557 4900 2254 147 4312 2107 539 2940 4606 392 3528 2960 814 2738 3441 3700 1702 111 3256 1591 407 2220 3478 296 2664 2800 770 2590 3255 3500 1610 105 3080 1505 385 2100 3290 280 2520 640 176 592 744 800 368 24 704 344 88 480 752 64 576 1440 396 1332 1674 1800 828 54 1584 774 198 1080 1692 144 1296 4320 1188 3996 5022 5400 2484 162 4752 2322 594 3240 5076 432 3888 6400 1760 5920 7440 8000 3680 240 7040 3440 880 4800 7520 640 5760 2400 660 2220 2790 3000 1380 90 2640 1290 330 1800 2820 240 2160 1440 396 1332 1674 1800 828 54 1584 774 198 1080 1692 144 1296 3360 924 3108 3906 4200 1932 126 3696 1806 462 2520 3948 336 3024 480 132 444 558 600 276 18 528 258 66 360 564 48 432 4720 1298 4366 5487 5900 2714 177 5192 2537 649 3540 5546 472 4248 3040 836 2812 3534 3800 1748 114 3344 1634 418 2280 3572 304 2736 4160 1144 3848 4836 5200 2392 156 4576 2236 572 3120 4888 416 3744 1440 396 1332 1674 1800 828 54 1584 774 198 1080 1692 144 1296 4640 1276 4292 5394 5800 2668 174 5104 2494 638 3480 5452 464 4176 6080 1672 5624 7068 7600 3496 228 6688 3268 836 4560 7144 608 5472 4800 1320 4440 5580 6000 2760 180 5280 2580 660 3600 5640 480 4320 5440 1496 5032 6324 6800 3128 204 5984 2924 748 4080 6392 544 4896 3520 968 3256 4092 4400 2024 132 3872 1892 484 2640 4136 352 3168 6560 1804 6068 7626 8200 3772 246 7216 3526 902 4920 7708 656 5904 5040 1386 4662 5859 6300 2898 189 5544 2709 693 3780 5922 504 4536 4800 1320 4440 5580 6000 2760 180 5280 2580 660 3600 5640 480 4320 2320 638 2146 2697 2900 1334 87 2552 1247 319 1740 2726 232 2088 2640 726 2442 3069 3300 1518 99 2904 1419 363 1980 3102 264 2376 5440 1496 5032 6324 6800 3128 204 5984 2924 748 4080 6392 544 4896 8000 2200 7400 9300 10000 4600 300 8800 4300 1100 6000 9400 800 7200 8000 2200 7400 9300 10000 4600 300 8800 4300 1100 6000 9400 800 7200 2640 726 2442 3069 3300 1518 99 2904 1419 363 1980 3102 264 2376 7600 2090 7030 8835 9500 4370 285 8360 4085 1045 5700 8930 760 6840 3760 1034 3478 4371 4700 2162 141 4136 2021 517 2820 4418 376 3384 1360 374 1258 1581 1700 782 51 1496 731 187 1020 1598 136 1224 5840 1606 5402 6789 7300 3358 219 6424 3139 803 4380 6862 584 5256 6000 1650 5550 6975 7500 3450 225 6600 3225 825 4500 7050 600 5400 5360 1474 4958 6231 6700 3082 201 5896 2881 737 4020 6298 536 4824 3600 990 3330 4185 4500 2070 135 3960 1935 495 2700 4230 360 3240 1920 528 1776 2232 2400 1104 72 2112 1032 264 1440 2256 192 1728 4080 1122 3774 4743 5100 2346 153 4488 2193 561 3060 4794 408 3672 2560 704 2368 2976 3200 1472 96 2816 1376 352 1920 3008 256 2304 6800 1870 6290 7905 8500 3910 255 7480 3655 935 5100 7990 680 6120 4000 1100 3700 4650 5000 2300 150 4400 2150 550 3000 4700 400 3600 6880 1892 6364 7998 8600 3956 258 7568 3698 946 5160 8084 688 6192 5840 1606 5402 6789 7300 3358 219 6424 3139 803 4380 6862 584 5256 7280 2002 6734 8463 9100 4186 273 8008 3913 1001 5460 8554 728 6552 6720 1848 6216 7812 8400 3864 252 7392 3612 924 5040 7896 672 6048 960 264 888 1116 1200 552 36 1056 516 132 720 1128 96 864 6480 1782 5994 7533 8100 3726 243 7128 3483 891 4860 7614 648 5832 7440 2046 6882 8649 9300 4278 279 8184 3999 1023 5580 8742 744 6696 1280 352 1184 1488 1600 736 48 1408 688 176 960 1504 128 1152 160 44 148 186 200 92 6 176 86 22 120 188 16 144 880 242 814 1023 1100 506 33 968 473 121 660 1034 88 792 4320 1188 3996 5022 5400 2484 162 4752 2322 594 3240 5076 432 3888 7680 2112 7104 8928 9600 4416 288 8448 4128 1056 5760 9024 768 6912 5280 1452 4884 6138 6600 3036 198 5808 2838 726 3960 6204 528 4752 1120 308 1036 1302 1400 644 42 1232 602 154 840 1316 112 1008 ...

5   Fail
x = randi(100,[1 1000]); xc = num2cell(x); assert(isequal(outerProduct(xc{:}),prod(x)))

y = 5238 y = 26273808 y = 2.5722e+10 y = 1.5240e+14 y = 4.8190e+17 y = 1.0799e+21 y = 2.8769e+24 y = 7.8972e+27 y = 6.3178e+29 y = 3.4078e+33 y = 2.2614e+37 y = 1.8069e+40 y = 2.2550e+43 y = 1.4206e+46 y = 5.2890e+49 y = 9.4462e+52 y = 3.6160e+56 y = 5.8869e+59 y = 2.1128e+63 y = 5.9771e+66 y = 2.1380e+70 y = 2.0012e+73 y = 4.2025e+76 y = 8.3713e+79 y = 2.9534e+83 y = 1.7366e+86 y = 5.4026e+89 y = 8.4280e+92 y = 3.2768e+96 y = 1.0486e+99 y = 5.0961e+101 y = 5.1980e+103 y = 5.3176e+106 y = 9.6780e+109 y = 1.0336e+113 y = 8.6823e+115 y = 8.1266e+118 y = 8.1916e+121 y = 3.9811e+124 y = 7.9424e+127 y = 2.5733e+131 y = 2.1024e+134 y = 9.1455e+136 y = 2.1766e+140 y = 1.5911e+144 y = 2.1003e+147 y = 3.1126e+150 y = 2.2411e+153 y = 6.5238e+156 y = 2.8705e+158 y = 9.1855e+160 y = 4.3658e+164 y = 2.6195e+167 y = 4.2305e+170 y = 1.6854e+174 y = 2.8315e+177 y = 8.5682e+180 y = 2.8378e+184 y = 1.7311e+188 y = 3.6560e+191 y = 2.2667e+194 y = 3.7174e+197 y = 6.2452e+200 y = 5.6944e+204 y = 3.0511e+208 y = 3.4050e+211 y = 6.2516e+214 y = 1.2191e+218 y = 8.0457e+219 y = 4.9916e+223 y = 2.0216e+226 y = 2.7494e+229 y = 7.9677e+232 y = 2.0078e+236 y = 3.9153e+239 y = 4.0484e+242 y = 3.2691e+246 y = 1.1246e+250 y = 1.5778e+253 y = 2.6822e+255 y = 1.5020e+258 y = 1.9151e+261 y = 1.8921e+264 y = 3.0085e+267 y = 1.2121e+271 y = 7.8909e+274 y = 4.1822e+278 y = 1.2546e+281 y = 4.6547e+284 y = 5.2180e+287 y = 4.0700e+289 y = 6.4347e+292 y = 6.3446e+295 y = 5.2026e+298 y = 1.1550e+301 y = 1.7671e+304 y = 4.5768e+307 y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf

Maximum recursion limit of 500 reached. Error in outerProduct (line 15) y = outerProduct( y*varargin{3} , varargin{4:end} ) % Not robust to handle nonscalar varargin{3}. Caused by: Maximum recursion limit of 500 reached.