head	1.3;
access;
symbols
	r2_0:1.3
	r1_1_beta:1.3
	r1_1_alpha:1.2
	r1_0:1.2
	r0_11:1.2
	r0_10:1.2;
locks; strict;
comment	@// @;


1.3
date	94.07.25.17.26.39;	author thoth;	state Exp;
branches;
next	1.2;

1.2
date	94.01.07.15.12.35;	author thoth;	state Exp;
branches;
next	1.1;

1.1
date	93.12.29.15.44.32;	author thoth;	state Exp;
branches;
next	;


desc
@source code for the chi_contains implementation.
@


1.3
log
@Name sanitization
@
text
@// Emacs: -*- C++ -*-

//
//	Copyright 1993, Center for Computer Vision and Visualization,
//	University of Florida.  All rights reserved.
//


//
// $Log: chi_contains.c,v $
// Revision 1.2  1994/01/07  15:12:35  thoth
// Image class is now CoreImage and named image types are
// Image<P,T>.
//
// Revision 1.1  1993/12/29  15:44:32  thoth
// Initial revision
//

#include "CoreImage.h"
#include "VectorI.h"
#include "ConstI.h"

typedef int ATYPE;

template <class P, class T>
IA_CoreImage<P, ATYPE>
vec_chi_contains(const IA_VectorI<P, T> *lhs, const IA_ValueSet<T> &rhs)
{
    const IA_Set<IA_Point<int> > domain = lhs->domain();
    const unsigned sz = domain.card();
    ATYPE *const vec = new ATYPE[sz];

    {
	ATYPE *ds = vec;
	const T *ls = lhs->vec;
	for (unsigned i=0; i<sz; i++) {
	    *(ds++) = rhs.contains(*ls);
	    ls++;
	}
    }
    return IA_CoreImage<P, ATYPE>(domain, vec, sz, 1);
}


// scalar-scalar operation is trivial


template <class P, class T>
IA_CoreImage<P, ATYPE>
iter_chi_contains(IA_CoreImage<P, T> lhs, const IA_ValueSet<T> &rhs)
{
    const IA_Set<IA_Point<int> > domain = lhs.domain();
    const unsigned sz = domain.card();
    ATYPE *const vec = new ATYPE[sz];

    {
	ATYPE *ds = vec;
	T ltmp;
	IA_IVIter<P, T>	liter(lhs);
	for (unsigned i=0; i<sz; i++) {
	    liter(ltmp);
	    *(ds++) = rhs.contains(ltmp);
	}
    }
    return IA_CoreImage<P, ATYPE>(domain, vec, sz, 1);
}


template <class P, class T>
IA_CoreImage<P, ATYPE>
chi_contains ( const IA_CoreImage<P, T> &lhs, const IA_ValueSet<T> &rhs)
{
    if (lhs.type() == IA_VectorI<P, T>::s_type()) {
	return vec_chi_contains((IA_VectorI<P, T> *)lhs.bip,rhs);
    } else if (lhs.type() == IA_ConstI<P, T>::s_type()) {
	return IA_CoreImage<P, ATYPE> (lhs.domain(), rhs.contains(((IA_ConstI<P, T> *)lhs.bip)->value));
    } else {
	return iter_chi_contains(lhs,rhs);
    }
}
@


1.2
log
@Image class is now CoreImage and named image types are
Image<P,T>.
@
text
@d11 4
d29 1
a29 1
    const IA_IntPointSet domain = lhs->domain();
d52 1
a52 1
    const IA_IntPointSet domain = lhs.domain();
@


1.1
log
@Initial revision
@
text
@d10 4
a13 1
// $Log: Image.c,v $
d15 1
a15 1
#include "Image.h"
d22 1
a22 1
IA_Image<P, ATYPE>
d37 1
a37 1
    return IA_Image<P, ATYPE>(domain, vec, sz, 1);
d45 2
a46 2
IA_Image<P, ATYPE>
iter_chi_contains(IA_Image<P, T> lhs, const IA_ValueSet<T> &rhs)
d61 1
a61 1
    return IA_Image<P, ATYPE>(domain, vec, sz, 1);
d66 2
a67 2
IA_Image<P, ATYPE>
chi_contains ( const IA_Image<P, T> &lhs, const IA_ValueSet<T> &rhs)
d72 1
a72 1
	return IA_Image<P, ATYPE> (lhs.domain(), rhs.contains(((IA_ConstI<P, T> *)lhs.bip)->value));
@
