%mathpiper,def="Outer"

// outer product of vectors
Outer(t1_IsVector, t2_IsVector) <--
[
   Local(i,j,n,m,result);
   n:=Length(t1);
   m:=Length(t2);
   result:=ZeroMatrix(n,m);
   For(i:=1,i<=n,i++)
      For(j:=1,j<=m,j++)
	 result[i][j]:=t1[i]*t2[j];
   result;
];

%/mathpiper



%mathpiper_docs,name="Outer",categories="User Functions;Linear Algebra"
*CMD Outer, o --- get outer tensor product
*STD
*CALL
	Outer(t1,t2)
	t1 o t2
Precedence:
*EVAL PrecedenceGet("o")

*PARMS

{t1,t2} -- tensor lists (currently only vectors are supported)

*DESC

{Outer} returns the outer product of two tensors t1 and t2. Currently
{Outer} work works only for vectors, i.e. tensors of rank 1. The outer
product of two vectors yields a matrix.

*E.G.

In> Outer({1,2},{3,4,5})
Result: {{3,4,5},{6,8,10}};
In> Outer({a,b},{c,d})
Result: {{a*c,a*d},{b*c,b*d}};

	Or, using the "o"-Operator:

In> {1,2} o {3,4,5}
Result: {{3,4,5},{6,8,10}};
In> {a,b} o {c,d}
Result: {{a*c,a*d},{b*c,b*d}};


*SEE InProduct, Dot, Cross
%/mathpiper_docs