Esempio n. 1
0
TSparseMat oprod(const TSparseVec &a, const TSparseVec &b)
// returns outerproduct of a and b:  a * trans(b)
{
	TSparseMat	result;
	TSVIter		i;
	
	result.SetSize(a.Elts(), b.Elts());
	result = vl_0;
		
	for (i.Begin(a); !i.AtEnd(); i.Inc())
	{
		result[i.Index()] = b;
		result[i.Index()] *= i.Data();
	}
	
	return(result);
}
Esempio n. 2
0
TSparseMat oprods(const TVec &a, const TVec &b)
// returns outerproduct of a and b:  a * trans(b)
{
	TSparseMat	result;
	Int			i;

	result.SetSize(a.Elts(), b.Elts());
	
	for (i = 0; i < a.Elts(); i++)
		if (TSparseVec::IsNonZero(a[i]))
		{
			result[i] = b;
			result[i] *= a[i];
		}
		else
			result[i] = vl_0;

	return(result);
}