#ifndef vec_scalar_ATYPE_LTYPE_RTYPE_OPNAME
#define vec_scalar_ATYPE_LTYPE_RTYPE_OPNAME
ATYPE vec_scalar_bo_OPNAME(const IA_VectorDI<RTYPE> *lhs,LTYPE rhs)
{
    const IA_IntPointSet domain = lhs->domain();
    const unsigned sz = domain.card();
    ATYPE *const vec = new ATYPE[sz];

    {
	ATYPE *ds = vec;
	const LTYPE *ls = lhs->vec;
	for (unsigned i=0; i<sz; i++) {
	    if (!( (*(ls++)) SUBOP (rhs) ))
		return 0;
	}
    }
    return 1;
}
#endif // vec_scalar_ATYPE_LTYPE_RTYPE_OPNAME

// scalar-scalar operation is trivial

#ifndef scalar_iter_ATYPE_LTYPE_RTYPE_OPNAME
#define scalar_iter_ATYPE_LTYPE_RTYPE_OPNAME
ATYPE scalar_iter_bo_OPNAME(LTYPE lhs,IA_DiscreteImage<RTYPE> rhs)
{
    const IA_IntPointSet domain = rhs.domain();
    const unsigned sz = domain.card();
    ATYPE *const vec = new ATYPE[sz];

    {
	ATYPE *ds = vec;
	RTYPE rtmp;
	IA_DIVIter<RTYPE>	riter(rhs);
	for (unsigned i=0; i<sz; i++) {
	    riter(rtmp);
	    if (!( (lhs) SUBOP (rtmp) ))
		return 0;
	}
    }
    return 1;
}
#endif // scalar_iter_ATYPE_LTYPE_RTYPE_OPNAME

ATYPE OP (LTYPE lhs, const IA_DiscreteImage<RTYPE> &rhs)
{
    if (rhs.type() == IA_VectorDI<RTYPE>::s_type()) {
	return vec_scalar_bo_OPNAME((IA_VectorDI<RTYPE> *)rhs.bdip,lhs);
    } else if (rhs.type() == IA_ConstDI<RTYPE>::s_type()) {
	return (lhs) SUBOP (((IA_ConstDI<RTYPE> *)rhs.bdip)->value);
    } else {
	return scalar_iter_bo_OPNAME(lhs,rhs);
    }
}
