Cody

# Problem 44258. Outer product of multiple vectors

Solution 1418524

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
filetext = fileread('outerProduct.m'); assert(~contains(filetext,'regexp'))

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

y = []

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

y = 3458

4   Fail
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))

Error using * Inner matrix dimensions must agree. Error in outerProduct (line 2) y = varargin{1} * varargin{2} Error in Test4 (line 3) assert(isequal(outerProduct(x,y),x.'*y))

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

y = 720 y = 36000 y = 2592000 y = 152928000 y = 1.1470e+10 y = 2.9821e+11 y = 2.9821e+12 y = 1.2227e+14 y = 1.0515e+16 y = 1.1566e+17 y = 7.9808e+18 y = 4.5490e+20 y = 1.3647e+22 y = 7.3695e+23 y = 4.7165e+25 y = 3.3958e+27 y = 1.7319e+29 y = 3.1174e+30 y = 2.8992e+32 y = 1.3046e+34 y = 4.4357e+35 y = 4.4357e+37 y = 1.5525e+39 y = 1.3196e+41 y = 1.0953e+43 y = 4.4907e+44 y = 4.3111e+46 y = 8.6221e+46 y = 8.6221e+46 y = 2.6729e+48 y = 1.0959e+50 y = 1.0849e+52 y = 2.4953e+53 y = 9.4822e+54 y = 2.9395e+56 y = 6.4668e+57 y = 1.8754e+59 y = 1.3128e+61 y = 1.1552e+63 y = 6.4693e+64 y = 4.7873e+66 y = 6.7022e+67 y = 1.6756e+69 y = 8.0427e+70 y = 3.1366e+72 y = 2.1015e+74 y = 1.9544e+76 y = 6.0588e+77 y = 8.4823e+78 y = 3.1384e+80 y = 1.0043e+82 y = 6.4275e+83 y = 3.5351e+85 y = 2.0504e+87 y = 1.3738e+89 y = 1.7859e+90 y = 2.3216e+91 y = 1.3233e+93 y = 1.9850e+94 y = 1.3498e+96 y = 7.8289e+97 y = 4.0710e+99 y = 2.6869e+101 y = 1.6121e+103 y = 1.2252e+105 y = 1.1027e+106 y = 1.0806e+108 y = 1.0698e+110 y = 5.7771e+111 y = 3.6396e+113 y = 2.9116e+114 y = 1.6596e+116 y = 4.9789e+117 y = 4.6802e+119 y = 1.7785e+121 y = 4.2683e+122 y = 3.8415e+123 y = 9.2196e+124 y = 3.3190e+126 y = 1.0953e+128 y = 7.2289e+129 y = 4.6988e+131 y = 1.3626e+133 y = 8.8572e+134 y = 7.5286e+136 y = 6.0229e+137 y = 3.0114e+138 y = 8.7332e+139 y = 3.3186e+141 y = 3.1195e+143 y = 2.4956e+145 y = 2.0713e+147 y = 1.5742e+149 y = 1.2279e+151 y = 9.3320e+152 y = 5.5992e+154 y = 1.9037e+156 y = 1.4468e+158 y = 2.8937e+159 y = 2.3439e+161 y = 1.9923e+163 y = 1.9923e+165 y = 4.5823e+166 y = 7.7898e+167 y = 5.7645e+169 y = 5.2457e+171 y = 1.4688e+173 y = 1.0722e+175 y = 1.6083e+176 y = 3.6992e+177 y = 2.9593e+178 y = 2.8705e+180 y = 2.7557e+182 y = 6.8893e+183 y = 3.2380e+185 y = 1.1980e+187 y = 5.7506e+188 y = 3.4504e+190 y = 1.3456e+192 y = 8.6122e+193 y = 8.4399e+195 y = 2.5320e+196 y = 2.3547e+198 y = 8.7125e+199 y = 3.6593e+201 y = 2.4151e+203 y = 2.0045e+205 y = 1.2829e+207 y = 3.8487e+208 y = 3.4254e+210 y = 2.5348e+212 y = 1.0393e+214 y = 2.8060e+215 y = 1.5433e+217 y = 1.6976e+218 y = 1.6467e+220 y = 1.1033e+222 y = 9.9296e+222 y = 8.4401e+224 y = 3.2916e+226 y = 1.3167e+227 y = 1.9750e+228 y = 9.8749e+229 y = 2.6662e+231 y = 2.3463e+233 y = 2.0413e+235 y = 1.9596e+237 y = 1.2738e+239 y = 9.0436e+240 y = 5.0644e+242 y = 1.3674e+244 y = 3.9655e+245 y = 3.9258e+247 y = 2.6303e+249 y = 7.3648e+250 y = 7.2912e+252 y = 1.9686e+254 y = 6.2996e+255 y = 7.5595e+256 y = 4.5357e+257 y = 2.4039e+259 y = 2.1635e+261 y = 2.0337e+263 y = 1.5863e+265 y = 1.1421e+267 y = 5.8249e+268 y = 5.4171e+270 y = 7.0423e+271 y = 3.5211e+272 y = 3.5211e+274 y = 1.4437e+276 y = 1.0972e+278 y = 3.4013e+279 y = 2.7210e+280 y = 1.7687e+282 y = 2.2993e+283 y = 1.3106e+285 y = 8.2566e+286 y = 4.8714e+288 y = 9.7428e+288 y = 6.8200e+289 y = 3.0690e+291 y = 2.3017e+293 y = 1.6803e+295 y = 8.2333e+296 y = 7.6570e+298 y = 3.2159e+300 y = 2.9587e+302 y = 6.5091e+303 y = 3.0593e+305 y = 3.6711e+306 y = 1.6153e+308 y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf y = Inf 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 5) y = outerProduct( y , varargin{3:end} ) Caused by: Maximum recursion limit of 500 reached.