summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/numeric.py6
-rw-r--r--numpy/core/tests/test_numeric.py9
2 files changed, 13 insertions, 2 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index 713f6f8f0..a02e12b45 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -991,7 +991,7 @@ def convolve(a,v,mode='full'):
mode = _mode_from_name(mode)
return multiarray.correlate(a, v[::-1], mode)
-def outer(a, b):
+def outer(a, b, out=None):
"""
Compute the outer product of two vectors.
@@ -1012,6 +1012,8 @@ def outer(a, b):
b : (N,) array_like
Second input vector. Input is flattened if
not already 1-dimensional.
+ out : (M, N) ndarray, optional
+ A location where the result is stored
Returns
-------
@@ -1065,7 +1067,7 @@ def outer(a, b):
"""
a = asarray(a)
b = asarray(b)
- return a.ravel()[:, newaxis]*b.ravel()[newaxis,:]
+ return multiply(a.ravel()[:, newaxis], b.ravel()[newaxis,:], out)
# try to import blas optimized dot if available
try:
diff --git a/numpy/core/tests/test_numeric.py b/numpy/core/tests/test_numeric.py
index 3a708d9e8..8f2d36c55 100644
--- a/numpy/core/tests/test_numeric.py
+++ b/numpy/core/tests/test_numeric.py
@@ -2023,6 +2023,15 @@ class TestCross(TestCase):
assert_raises(ValueError, np.cross, u, v, axisa=-5, axisb=2)
assert_raises(ValueError, np.cross, u, v, axisa=1, axisb=-4)
+def test_outer_out_param():
+ arr1 = np.ones((5,))
+ arr2 = np.ones((2,))
+ arr3 = np.linspace(-2, 2, 5)
+ out1 = np.ndarray(shape=(5,5))
+ out2 = np.ndarray(shape=(2, 5))
+ res1 = np.outer(arr1, arr3, out1)
+ assert_equal(res1, out1)
+ assert_equal(np.outer(arr2, arr3, out2), out2)
if __name__ == "__main__":
run_module_suite()