if (left.length() != right.length())
throw new IllegalArgumentException(
"Vectors of different sizes cannot be multiplied");
if (left instanceof SparseVector && right instanceof SparseVector) {
TIntSet lnz = new TIntHashSet(((SparseVector)left).getNonZeroIndices());
for (int nz : ((SparseVector)right).getNonZeroIndices()) {
if (lnz.contains(nz)) {
left.set(nz, left.get(nz) * right.get(nz));
lnz.remove(nz);
}
}
// The remaining non-zero values in left should be zero'd out
// because they were effectively multiplied by zero by the right
// vector.
TIntIterator iter = lnz.iterator();
while (iter.hasNext())
left.set(iter.next(), 0);
}
else {
int length = left.length();