head	1.7;
access;
symbols
	bobbase:1.7
	bob:1.7.1
	r2_1:1.6
	C_8:1.6
	r2_0:1.5
	r1_1_beta:1.4
	r1_1_alpha:1.3
	r1_0:1.3
	r0_11:1.3;
locks
	thoth:1.7.1.2; strict;
comment	@// @;


1.7
date	94.12.28.22.13.17;	author ljr;	state Exp;
branches
	1.7.1.1;
next	1.6;

1.6
date	94.09.16.14.57.11;	author thoth;	state Exp;
branches;
next	1.5;

1.5
date	94.08.22.15.20.29;	author thoth;	state Exp;
branches;
next	1.4;

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

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

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

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

1.7.1.1
date	95.01.09.17.48.14;	author thoth;	state Exp;
branches;
next	1.7.1.2;

1.7.1.2
date	95.01.13.19.36.30;	author thoth;	state Exp;
branches;
next	;


desc
@Auxiliary operations on DDTemplates.
@


1.7
log
@Bogus return types fixed.
@
text
@// Emacs: -*- C++ -*-

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


//
// $Log: AuxDDTempl.c,v $
// Revision 1.6  1994/09/16  14:57:11  thoth
// more DOS-inspired renaming.
//
// Revision 1.5  1994/08/22  15:20:29  thoth
// DOS-inspired name rework.
//
// Revision 1.4  1994/07/25  17:26:39  thoth
// Name sanitization
//
// Revision 1.3  1994/04/15  13:15:11  thoth
// Flesh out the rest of the generic convolutions.
//
// Revision 1.2  1994/03/30  13:49:19  thoth
// generic convolutions will now compile.
//
// Revision 1.1  1994/03/22  16:08:28  thoth
// Initial revision
//

#include "AuxDDTempl.h"
#include "FBI.h"

#include "IntPoint.h"
#include "IntPS.h"
#include "PSIter.h"
#include "ImageIter.h"
#include "InvDT.h"

//
// Generic backward convolution
//

template <class R, class S, class T>
IA_Image<IA_Point<int>,R>
backw_generic_inv_core(IA_Point<int> src_infimum,
		    IA_Point<int> src_width,
		    const T *src_data, // length is prod(src_width)
		    const IA_CoreImage<IA_Point<int>,S> &templ,
		    IA_Set<IA_Point<int> > dest_ps,
		    R (*circle)(T,S),
		    R (*gamma)(R,R),
		    R gamma_zero,
		    const S*)
{
    const int	dimen = src_width.dim();

    IA_Set<IA_Point<int> >	templ_ps = templ.domain();
    int		templ_sz = templ_ps.card();
    S	*const templ_data = new S[templ_sz];
    int	*const templ_offsets = new int[templ_sz];

    {
	S	*d_scan = templ_data;
	int	*o_scan = templ_offsets;
	IA_IPIter<IA_Point<int>,S>	iter(templ);
	IA_Point<int>	ip;
	while (iter(ip, *d_scan)) {
	    *o_scan = ip[0];
	    for (unsigned i=1; i<dimen; i++) {
		*o_scan *= src_width[i];
		*o_scan += ip[i];
	    }
	    d_scan++;
	    o_scan++;
	}
    }

    IA_PSIter<IA_Point<int> >	iter(dest_ps);
    IA_Point<int>	ip;
    R *const	dest_data = new R[dest_ps.card()];
    R *	valp = dest_data;
    while (iter(ip)) {
	int	offset= ip[0] - src_infimum[0];
	unsigned i;
	for (i=1; i<dimen; i++) {
	    offset *= src_width[i];
	    offset += ip[i] - src_infimum[i];
	}
	const T *const base = src_data + offset;

	*valp = gamma_zero;
	for (i=0; i<templ_sz; i++) {
	    *valp = gamma( circle(base[templ_offsets[i]],
				  templ_data[i]), *valp);
	}

	valp++;
    }
    delete[] templ_offsets;
    delete[] templ_data;

    return IA_Image<IA_Point<int>,R>(dest_ps, dest_data, dest_ps.card(), 1);
}

template <class R, class S, class T>
IA_Image<IA_Point<int>, R>
backw_generic_inv(const IA_CoreImage<IA_Point<int>, T> &img,
		  const IA_CoreImage<IA_Point<int>, S> &invtempl,
		  const IA_Set<IA_Point<int> > &dest_ps,
		  R (*circle)(T,S),
		  R (*gamma)(R,R),
		  R gamma_zero,
		  T ring_zero,
		  const S*)
{
    IA_Point<int>	inf_ = dest_ps.inf()+invtempl.domain().inf();
    IA_Point<int>	sup_ = dest_ps.sup()+invtempl.domain().sup();
    IA_Set<IA_Point<int> >	src_ps = IA_Set<IA_Point<int> >(inf_,sup_);

    T	*const src_data = new T[src_ps.card()];

    zero_extend(IA_CoreImage<IA_Point<int>,T>(img), IA_Set<IA_Point<int> >(src_ps),
		(T*)src_data, T(ring_zero));
    IA_Image<IA_Point<int>,R>	rval =
	backw_generic_inv_core(inf_, sup_-inf_ + 1, src_data,
			       invtempl, dest_ps,
			       circle, gamma, gamma_zero, (S*)0);

    delete[] src_data;

    return rval;
}

template <class R, class S, class T>
IA_Image<IA_Point<int>, R>
generic_product (const IA_CoreImage<IA_Point<int>, T> &img,
		 const IA_DDTemplate< IA_Image<IA_Point<int>, S> > &templ,
		 const IA_Set<IA_Point<int> > &dest_ps,
		 R (*circle)(T,S),
		 R (*gamma)(R,R),
		 R gamma_zero,
		 T ring_zero,
		 const S*)
{

    if (templ.is_a(IA_InvariantDT<IA_Image<IA_Point<int>, S> >::s_type())) {
	return backw_generic_inv
	    (img, ((IA_InvariantDT<IA_Image<IA_Point<int>, S> >*)IA_FBI<IA_Point<int>, IA_Point<int>, S, S, S>::extract_baseptr(templ))->value,
	     dest_ps, circle, gamma, gamma_zero, ring_zero,
	     (S*)0);
	//    } else if (templ.type() == IA_Lazy_REDUCT_DT<IA_Image<IA_Point<int>, S> >::s_type()) {
    } else {
	R *const	dest_data = new R[dest_ps.card()];
	R	*valp = dest_data;
	IA_PSIter<IA_Point<int> >	dest_iter(dest_ps);
	IA_Point<int>	base_ip;
	while (dest_iter(base_ip)) {
	    IA_CoreImage<IA_Point<int>,S>	tv = templ(base_ip);

	    IA_IPIter<IA_Point<int>,S>	templ_iter(tv);
	    IA_Point<int>	templ_ip;
	    S	templ_val;

	    *valp = gamma_zero;

	    while ( templ_iter(templ_ip, templ_val) ) {
		const IA_Point<int>	ip = templ_ip; //+base_ip;
		if (! img.domain().contains(ip))
		    continue;
		*valp = gamma((*circle)(img(ip), templ_val), *valp);
	    }
	    valp++;
	}
	return IA_Image<IA_Point<int>,R>(dest_ps, dest_data,
				       dest_ps.card(), 1);
    }

}

//
// Generic backward convolution with big Gamma
//

template <class Q, class R, class S, class T>
// IA_Image<IA_Point<int>,R>
IA_Image<IA_Point<int>,Q>
backw_Generic_inv_core(IA_Point<int> src_infimum,
		       IA_Point<int> src_width,
		       const T *src_data, // length is prod(src_width)
		       const IA_CoreImage<IA_Point<int>,S> &templ,
		       IA_Set<IA_Point<int> > dest_ps,
		       R (*circle)(T,S),
		       Q (*Gamma)(R*,unsigned),
		       const Q*,
		       const R*,
		       const S*)
{
    const int	dimen = src_width.dim();

    IA_Set<IA_Point<int> >	templ_ps = templ.domain();
    int		templ_sz = templ_ps.card();
    S	*const templ_data = new S[templ_sz];
    int	*const templ_offsets = new int[templ_sz];

    {
	S	*d_scan = templ_data;
	int	*o_scan = templ_offsets;
	IA_IPIter<IA_Point<int>,S>	iter(templ);
	IA_Point<int>	ip;
	while (iter(ip, *d_scan)) {
	    *o_scan = ip[0];
	    for (unsigned i=1; i<dimen; i++) {
		*o_scan *= src_width[i];
		*o_scan += ip[i];
	    }
	    d_scan++;
	    o_scan++;
	}
    }

    IA_PSIter<IA_Point<int> >	iter(dest_ps);
    IA_Point<int>	ip;
    Q *const	dest_data = new R[dest_ps.card()];
    Q *	valp = dest_data;
    R	*a = new R[templ_sz];

    while (iter(ip)) {
	int	offset= ip[0] - src_infimum[0];
	unsigned i;
	for (i=1; i<dimen; i++) {
	    offset *= src_width[i];
	    offset += ip[i] - src_infimum[i];
	}
	const T *const base = src_data + offset;

	for (i=0; i<templ_sz; i++) {
	    a[i] = circle(base[templ_offsets[i]], templ_data[i]);
	}

	*(valp++) = Gamma(a, templ_sz);
    }
    delete[] a;

    delete[] templ_offsets;
    delete[] templ_data;

    return IA_Image<IA_Point<int>,Q>(dest_ps, dest_data, dest_ps.card(), 1);
}

template <class Q, class R, class S, class T>
// IA_Image<IA_Point<int>, R>
IA_Image<IA_Point<int>, Q>
backw_Generic_inv(const IA_CoreImage<IA_Point<int>, T> &img,
		  const IA_CoreImage<IA_Point<int>, S> &invtempl,
		  const IA_Set<IA_Point<int> > &dest_ps,
		  R (*circle)(T,S),
		  Q (*Gamma)(R*,unsigned),
		  T ring_zero,
		  const Q*,
		  const R*,
		  const S*)
{
    IA_Point<int>	inf_ = dest_ps.inf()+invtempl.domain().inf();
    IA_Point<int>	sup_ = dest_ps.sup()+invtempl.domain().sup();
    IA_Set<IA_Point<int> >	src_ps = IA_Set<IA_Point<int> >(inf_,sup_);

    T	*const src_data = new T[src_ps.card()];

    zero_extend(IA_CoreImage<IA_Point<int>,T>(img), IA_Set<IA_Point<int> >(src_ps),
		(T*)src_data, T(ring_zero));
    IA_Image<IA_Point<int>,Q>	rval =
	backw_Generic_inv_core(inf_, sup_-inf_ + 1, src_data,
			       invtempl, dest_ps,
			       circle, Gamma, (Q*)0, (R*)0, (S*)0);

    delete[] src_data;

    return rval;
}

template <class Q, class R, class S, class T>
// IA_Image<IA_Point<int>, R>
IA_Image<IA_Point<int>, Q>
generic_product (const IA_CoreImage<IA_Point<int>, T> &img,
		 const IA_DDTemplate< IA_Image<IA_Point<int>, S> > &templ,
		 const IA_Set<IA_Point<int> > &dest_ps,
		 R (*circle)(T,S),
		 Q (*Gamma)(R*,unsigned),
		 T ring_zero,
		 const Q*,
		 const R*,
		 const S*)
{

    if (templ.is_a(IA_InvariantDT<IA_Image<IA_Point<int>, S> >::s_type())) {
	return backw_Generic_inv
	    (img, (IA_CoreImage<IA_Point<int>,S>&)((IA_InvariantDT<IA_Image<IA_Point<int>, S> >*)IA_FBI<IA_Point<int>, IA_Point<int>, S, S, S>::extract_baseptr(templ))->value,
	     dest_ps, (R(*)(T,S))circle,
	     (Q(*)(R*,unsigned))Gamma, T(ring_zero),
	     (const Q*)0, (const R*)0, (const S*)0);
	//    } else if (templ.type() == IA_Lazy_REDUCT_DT<IA_Image<IA_Point<int>, S> >::s_type()) {
    } else {
	Q *const	dest_data = new Q[dest_ps.card()];
	Q	*valp = dest_data;
	IA_PSIter<IA_Point<int> >	dest_iter(dest_ps);
	IA_Point<int>	base_ip;
	while (dest_iter(base_ip)) {
	    IA_CoreImage<IA_Point<int>,S>	tv = templ(base_ip);

	    IA_IPIter<IA_Point<int>,S>	templ_iter(tv);
	    IA_Point<int>	templ_ip;
	    S	templ_val;

	    R	*a = new R[tv.card()];
	    int	idx=0;

	    while ( templ_iter(templ_ip, templ_val) ) {
		const IA_Point<int>	ip = templ_ip; //+base_ip;
		if (! img.domain().contains(ip))
		    continue;
		a[idx++] = (*circle)(img(ip), templ_val);
	    }
	    *(valp++) = Gamma(a, idx);
	    delete[] a;		// deleting every time is inefficient, rewrite
	}
	return IA_Image<IA_Point<int>,Q>(dest_ps, dest_data,
				       dest_ps.card(), 1);
    }

}

//
// Generic backward convolution with big Gamma
//

template <class Q, class R, class S, class T>
// IA_Image<IA_Point<int>,R>
IA_Image<IA_Point<int>,Q>
backw_Generic_inv_core3(IA_Point<int> src_infimum,
		       IA_Point<int> src_width,
		       const T *src_data, // length is prod(src_width)
		       IA_Set<IA_Point<int> > src_ps,
		       const IA_CoreImage<IA_Point<int>,S> &templ,
		       IA_Set<IA_Point<int> > dest_ps,
		       R (*circle)(T,S),
		       Q (*Gamma)(R*,unsigned),
		       const Q*,
		       const R*,
		       const S*)
{
    const int	dimen = src_width.dim();

    IA_Set<IA_Point<int> >	templ_ps = templ.domain();
    int		templ_sz = templ_ps.card();
    S	*const templ_data = new S[templ_sz];
    int	*const templ_offsets = new int[templ_sz];
    IA_Point<int>	*const templ_points = new IA_Point<int>[templ_sz];

    {
	IA_IPIter<IA_Point<int>,S>	iter(templ);

	for (int i=0; iter(templ_points[i], templ_data[i]); i++) {
	    templ_offsets[i] = templ_points[i][0];
	    for (unsigned j=1; j<dimen; j++) {
		templ_offsets[i] *= src_width[j];
		templ_offsets[i] += templ_points[i][j];
	    }
	}
    }


    IA_PSIter<IA_Point<int> >	iter(dest_ps);
    IA_Point<int>	ip;
    Q *const	dest_data = new R[dest_ps.card()];
    Q *	valp = dest_data;
    R	*a = new R[templ_sz];

    while (iter(ip)) {
	int	offset= ip[0] - src_infimum[0];
	unsigned i;
	for (i=1; i<dimen; i++) {
	    offset *= src_width[i];
	    offset += ip[i] - src_infimum[i];
	}
	const T *const base = src_data + offset;

	unsigned count=0;
	for (i=0; i<templ_sz; i++) {
	    if (src_ps.contains(ip + templ_points[i]))
		a[count++] = circle(base[templ_offsets[i]], templ_data[i]);
	}

	*(valp++) = Gamma(a, count);
    }
    delete[] a;

    delete[] templ_points;
    delete[] templ_offsets;
    delete[] templ_data;

    return IA_Image<IA_Point<int>,Q>(dest_ps, dest_data, dest_ps.card(), 1);
}

template <class Q, class R, class S, class T>
// IA_Image<IA_Point<int>, R>
IA_Image<IA_Point<int>, Q>
backw_Generic_inv3(const IA_CoreImage<IA_Point<int>, T> &img,
		  const IA_CoreImage<IA_Point<int>, S> &invtempl,
		  const IA_Set<IA_Point<int> > &dest_ps,
		  R (*circle)(T,S),
		  Q (*Gamma)(R*,unsigned),
		  const Q*,
		  const R*,
		  const S*)
{
    IA_Point<int>	inf_ = dest_ps.inf()+invtempl.domain().inf();
    IA_Point<int>	sup_ = dest_ps.sup()+invtempl.domain().sup();
    IA_Set<IA_Point<int> >	src_ps = IA_Set<IA_Point<int> >(inf_,sup_);

    T	*const src_data = new T[src_ps.card()];

    T	ring_zero;
    zero_extend(IA_CoreImage<IA_Point<int>,T>(img), IA_Set<IA_Point<int> >(src_ps),
		(T*)src_data, ring_zero);
    IA_Image<IA_Point<int>,Q>	rval =
	backw_Generic_inv_core3
	    (inf_, sup_-inf_ + 1, src_data, img.domain(),
	     invtempl, dest_ps,
	     circle, Gamma, (Q*)0, (R*)0, (S*)0);

    delete[] src_data;

    return rval;
}

template <class Q, class R, class S, class T>
// IA_Image<IA_Point<int>, R>
IA_Image<IA_Point<int>, Q>
generic_product (const IA_CoreImage<IA_Point<int>, T> &img,
		 const IA_DDTemplate< IA_Image<IA_Point<int>, S> > &templ,
		 const IA_Set<IA_Point<int> > &dest_ps,
		 R (*circle)(T,S),
		 Q (*Gamma)(R*,unsigned),
		 const Q*,
		 const R*,
		 const S*)
{

    if (templ.is_a(IA_InvariantDT<IA_Image<IA_Point<int>, S> >::s_type())) {
	return backw_Generic_inv3
	    (img, (IA_CoreImage<IA_Point<int>,S>&)((IA_InvariantDT<IA_Image<IA_Point<int>, S> >*)IA_FBI<IA_Point<int>, IA_Point<int>, S, S, S>::extract_baseptr(templ))->value,
	     dest_ps, (R(*)(T,S))circle,
	     (Q(*)(R*,unsigned))Gamma,
	     (const Q*)0, (const R*)0, (const S*)0);
	//    } else if (templ.type() == IA_Lazy_REDUCT_DT<IA_Image<IA_Point<int>, S> >::s_type()) {
    } else {
	Q *const	dest_data = new Q[dest_ps.card()];
	Q	*valp = dest_data;
	IA_PSIter<IA_Point<int> >	dest_iter(dest_ps);
	IA_Point<int>	base_ip;
	while (dest_iter(base_ip)) {
	    IA_CoreImage<IA_Point<int>,S>	tv = templ(base_ip);

	    IA_IPIter<IA_Point<int>,S>	templ_iter(tv);
	    IA_Point<int>	templ_ip;
	    S	templ_val;

	    R	*a = new R[tv.card()];
	    int	idx=0;

	    while ( templ_iter(templ_ip, templ_val) ) {
		const IA_Point<int>	ip = templ_ip; //+base_ip;
		if (! img.domain().contains(ip))
		    continue;
		a[idx++] = (*circle)(img(ip), templ_val);
	    }
	    *(valp++) = Gamma(a, idx);
	    delete[] a;		// deleting every time is inefficient, rewrite
	}
	return IA_Image<IA_Point<int>,Q>(dest_ps, dest_data,
				       dest_ps.card(), 1);
    }

}

//
// Generic forward convolution
//

template <class R, class S, class T>
IA_Image<IA_Point<int>,R>
forw_generic_inv_core(IA_Point<int> src_infimum,
		    IA_Point<int> src_width,
		    const T *src_data, // length is prod(src_width)
		    const IA_CoreImage<IA_Point<int>,S> &templ,
		    IA_Set<IA_Point<int> > dest_ps,
		    R (*circle)(T,S),
		    R (*gamma)(R,R),
		    R gamma_zero,
		    const S*)
{
    const int	dimen = src_width.dim();

    IA_Set<IA_Point<int> >	templ_ps = templ.domain();
    int		templ_sz = templ_ps.card();
    S	*const templ_data = new S[templ_sz];
    int	*const templ_offsets = new int[templ_sz];

    {
	S	*d_scan = templ_data;
	int	*o_scan = templ_offsets;
	IA_IPIter<IA_Point<int>,S>	iter(templ);
	IA_Point<int>	ip;
	while (iter(ip, *d_scan)) {
	    *o_scan = -ip[0];
	    for (unsigned i=1; i<dimen; i++) {
		*o_scan *= src_width[i];
		*o_scan -= ip[i];
	    }
	    d_scan++;
	    o_scan++;
	}
    }

    IA_PSIter<IA_Point<int> >	iter(dest_ps);
    IA_Point<int>	ip;
    R *const	dest_data = new R[dest_ps.card()];
    R *	valp = dest_data;
    while (iter(ip)) {
	int	offset= ip[0] - src_infimum[0];
	unsigned i;
	for (i=1; i<dimen; i++) {
	    offset *= src_width[i];
	    offset += ip[i] - src_infimum[i];
	}
	const T *const base = src_data + offset;

	*valp = gamma_zero;
	for (i=0; i<templ_sz; i++) {
	    *valp = gamma( circle(base[templ_offsets[i]],
				  templ_data[i]), *valp);
	}

	valp++;
    }
    delete[] templ_offsets;
    delete[] templ_data;

    return IA_Image<IA_Point<int>,R>(dest_ps, dest_data, dest_ps.card(), 1);
}

template <class R, class S, class T>
IA_Image<IA_Point<int>, R>
forw_generic_inv(const IA_CoreImage<IA_Point<int>, T> &img,
		  const IA_CoreImage<IA_Point<int>, S> &invtempl,
		  const IA_Set<IA_Point<int> > &dest_ps,
		  R (*circle)(T,S),
		  R (*gamma)(R,R),
		  R gamma_zero,
		  T ring_zero,
		  const S*)
{
    IA_Point<int>	inf_ = dest_ps.inf()-invtempl.domain().sup();
    IA_Point<int>	sup_ = dest_ps.sup()-invtempl.domain().inf();
    IA_Set<IA_Point<int> >	src_ps = IA_Set<IA_Point<int> >(inf_,sup_);

    T	*const src_data = new T[src_ps.card()];

    zero_extend(IA_CoreImage<IA_Point<int>,T>(img), IA_Set<IA_Point<int> >(src_ps),
		(T*)src_data, T(ring_zero));
    IA_Image<IA_Point<int>,R>	rval =
	forw_generic_inv_core(inf_, sup_-inf_ + 1, src_data,
			       invtempl, dest_ps,
			       circle, gamma, gamma_zero, (S*)0);

    delete[] src_data;

    return rval;
}

template <class R, class S, class T>
IA_Image<IA_Point<int>, R>
generic_product (const IA_DDTemplate< IA_Image<IA_Point<int>, S> > &templ,
		 const IA_CoreImage<IA_Point<int>, T> &img,
		 const IA_Set<IA_Point<int> > &dest_ps,
		 R (*circle)(T,S),
		 R (*gamma)(R,R),
		 R gamma_zero,
		 T ring_zero,
		 const S*)
{

    if (templ.is_a(IA_InvariantDT<IA_Image<IA_Point<int>, S> >::s_type())) {
	return forw_generic_inv
	    (img, ((IA_InvariantDT<IA_Image<IA_Point<int>, S> >*)IA_FBI<IA_Point<int>, IA_Point<int>, S, S, S>::extract_baseptr(templ))->value,
	     dest_ps, circle, gamma, gamma_zero, ring_zero,
	     (S*)0);
    } else {
	unsigned	size = dest_ps.card();
	R *const	dest_data = new R[size];

	for (int i=0; i<size; i++) {
	    dest_data[i] = gamma_zero;
	}

	IA_PSIter<IA_Point<int> >	src_iter(img.domain());
	IA_Point<int>	base_ip;
	while (src_iter(base_ip)) {
	    IA_CoreImage<IA_Point<int>,S>	tv = templ(base_ip);

	    IA_IPIter<IA_Point<int>,S>	templ_iter(tv);
	    IA_Point<int>	templ_ip;
	    S	templ_val;
	    T	ival = img(base_ip);

	    while ( templ_iter(templ_ip, templ_val) ) {
		const IA_Point<int>	ip = templ_ip; //+base_ip;
		if (! dest_ps.contains(templ_ip))
		    continue;
		unsigned	offset = dest_ps.index(templ_ip);
		R	*valp = dest_data + offset;
		*valp = gamma(circle(templ_val, ival),*valp);
	    }
	}
	return IA_Image<IA_Point<int>,R>(dest_ps, dest_data,
				       size, 1);
    }

}

//
// Generic forward convolution with big Gamma
//

template <class Q, class R, class S, class T>
// IA_Image<IA_Point<int>,R>
IA_Image<IA_Point<int>,Q>
forw_Generic_inv_core(IA_Point<int> src_infimum,
		       IA_Point<int> src_width,
		       const T *src_data, // length is prod(src_width)
		       const IA_CoreImage<IA_Point<int>,S> &templ,
		       IA_Set<IA_Point<int> > dest_ps,
		       R (*circle)(T,S),
		       Q (*Gamma)(R*,unsigned),
		       const Q*,
		       const R*,
		       const S*)
{
    const int	dimen = src_width.dim();

    IA_Set<IA_Point<int> >	templ_ps = templ.domain();
    int		templ_sz = templ_ps.card();
    S	*const templ_data = new S[templ_sz];
    int	*const templ_offsets = new int[templ_sz];

    {
	S	*d_scan = templ_data;
	int	*o_scan = templ_offsets;
	IA_IPIter<IA_Point<int>,S>	iter(templ);
	IA_Point<int>	ip;
	while (iter(ip, *d_scan)) {
	    *o_scan = -ip[0];
	    for (unsigned i=1; i<dimen; i++) {
		*o_scan *= src_width[i];
		*o_scan -= ip[i];
	    }
	    d_scan++;
	    o_scan++;
	}
    }

    IA_PSIter<IA_Point<int> >	iter(dest_ps);
    IA_Point<int>	ip;
    Q *const	dest_data = new R[dest_ps.card()];
    Q *	valp = dest_data;
    R	*a = new R[templ_sz];

    while (iter(ip)) {
	int	offset= ip[0] - src_infimum[0];
	unsigned i;
	for (i=1; i<dimen; i++) {
	    offset *= src_width[i];
	    offset += ip[i] - src_infimum[i];
	}
	const T *const base = src_data + offset;

	for (i=0; i<templ_sz; i++) {
	    a[i] = circle(base[templ_offsets[i]], templ_data[i]);
	}

	*(valp++) = Gamma(a, templ_sz);
    }
    delete[] a;

    delete[] templ_offsets;
    delete[] templ_data;

    return IA_Image<IA_Point<int>,Q>(dest_ps, dest_data, dest_ps.card(), 1);
}

template <class Q, class R, class S, class T>
// IA_Image<IA_Point<int>, R>
IA_Image<IA_Point<int>, Q>
forw_Generic_inv(const IA_CoreImage<IA_Point<int>, T> &img,
		  const IA_CoreImage<IA_Point<int>, S> &invtempl,
		  const IA_Set<IA_Point<int> > &dest_ps,
		  R (*circle)(T,S),
		  Q (*Gamma)(R*,unsigned),
		  T ring_zero,
		  const Q*,
		  const R*,
		  const S*)
{
    IA_Point<int>	inf_ = dest_ps.inf()-invtempl.domain().sup();
    IA_Point<int>	sup_ = dest_ps.sup()-invtempl.domain().inf();
    IA_Set<IA_Point<int> >	src_ps = IA_Set<IA_Point<int> >(inf_,sup_);

    T	*const src_data = new T[src_ps.card()];

    zero_extend(IA_CoreImage<IA_Point<int>,T>(img), IA_Set<IA_Point<int> >(src_ps),
		(T*)src_data, T(ring_zero));
    IA_Image<IA_Point<int>,Q>	rval =
	forw_Generic_inv_core(inf_, sup_-inf_ + 1, src_data,
			       invtempl, dest_ps,
			       circle, Gamma, (Q*)0, (R*)0, (S*)0);

    delete[] src_data;

    return rval;
}

template <class Q, class R, class S, class T>
// IA_Image<IA_Point<int>, R>
IA_Image<IA_Point<int>, Q>
generic_product (const IA_DDTemplate< IA_Image<IA_Point<int>, S> > &templ,
		 const IA_CoreImage<IA_Point<int>, T> &img,
		 const IA_Set<IA_Point<int> > &dest_ps,
		 R (*circle)(T,S),
		 Q (*Gamma)(R*,unsigned),
		 T ring_zero,
		 const Q*,
		 const R*,
		 const S*)
{

    if (templ.is_a(IA_InvariantDT<IA_Image<IA_Point<int>, S> >::s_type())) {
	return forw_Generic_inv
	    (img, (IA_CoreImage<IA_Point<int>,S>&)((IA_InvariantDT<IA_Image<IA_Point<int>, S> >*)IA_FBI<IA_Point<int>, IA_Point<int>, S, S, S>::extract_baseptr(templ))->value,
	     dest_ps, (R(*)(T,S))circle,
	     (Q(*)(R*,unsigned))Gamma, T(ring_zero),
	     (const Q*)0, (const R*)0, (const S*)0);
	//    } else if (templ.type() == IA_Lazy_REDUCT_DT<IA_Image<IA_Point<int>, S> >::s_type()) {
    } else {
	IA::not_yet_implemented(__FILE__, __LINE__);
    }

}

//
// Generic forward convolution with big Gamma
//

template <class Q, class R, class S, class T>
// IA_Image<IA_Point<int>,R>
IA_Image<IA_Point<int>,Q>
forw_Generic_inv_core3(IA_Point<int> src_infimum,
		       IA_Point<int> src_width,
		       const T *src_data, // length is prod(src_width)
		       IA_Set<IA_Point<int> > src_ps,
		       const IA_CoreImage<IA_Point<int>,S> &templ,
		       IA_Set<IA_Point<int> > dest_ps,
		       R (*circle)(T,S),
		       Q (*Gamma)(R*,unsigned),
		       const Q*,
		       const R*,
		       const S*)
{
    const int	dimen = src_width.dim();

    IA_Set<IA_Point<int> >	templ_ps = templ.domain();
    int		templ_sz = templ_ps.card();
    S	*const templ_data = new S[templ_sz];
    int	*const templ_offsets = new int[templ_sz];
    IA_Point<int>	*const templ_points = new IA_Point<int>[templ_sz];

    {
	int	i;
	IA_IPIter<IA_Point<int>,S>	iter(templ);

	for (i=0; iter(templ_points[i], templ_data[i]); i++) {
	    templ_offsets[i] = -templ_points[i][0];
	    for (unsigned j=1; j<dimen; j++) {
		templ_offsets[i] *= src_width[j];
		templ_offsets[i] -= templ_points[i][j];
	    }
	}
    }

    IA_PSIter<IA_Point<int> >	iter(dest_ps);
    IA_Point<int>	ip;
    Q *const	dest_data = new R[dest_ps.card()];
    Q *	valp = dest_data;
    R	*a = new R[templ_sz];

    while (iter(ip)) {
	int	offset= ip[0] - src_infimum[0];
	unsigned i;
	for (i=1; i<dimen; i++) {
	    offset *= src_width[i];
	    offset += ip[i] - src_infimum[i];
	}
	const T *const base = src_data + offset;

	unsigned count=0;
	for (i=0; i<templ_sz; i++) {
	    if (src_ps.contains(ip - templ_points[i]))
		a[count++] = circle(base[templ_offsets[i]], templ_data[i]);
	}

	*(valp++) = Gamma(a, count);
    }
    delete[] a;

    delete[] templ_points;
    delete[] templ_offsets;
    delete[] templ_data;

    return IA_Image<IA_Point<int>,Q>(dest_ps, dest_data, dest_ps.card(), 1);
}

template <class Q, class R, class S, class T>
// IA_Image<IA_Point<int>, R>
IA_Image<IA_Point<int>, Q>
forw_Generic_inv3(const IA_CoreImage<IA_Point<int>, T> &img,
		  const IA_CoreImage<IA_Point<int>, S> &invtempl,
		  const IA_Set<IA_Point<int> > &dest_ps,
		  R (*circle)(T,S),
		  Q (*Gamma)(R*,unsigned),
		  const Q*,
		  const R*,
		  const S*)
{
    IA_Point<int>	inf_ = dest_ps.inf()-invtempl.domain().sup();
    IA_Point<int>	sup_ = dest_ps.sup()-invtempl.domain().inf();
    IA_Set<IA_Point<int> >	src_ps = IA_Set<IA_Point<int> >(inf_,sup_);

    T	*const src_data = new T[src_ps.card()];

    T	ring_zero;
    zero_extend(IA_CoreImage<IA_Point<int>,T>(img), IA_Set<IA_Point<int> >(src_ps),
		(T*)src_data, ring_zero);
    IA_Image<IA_Point<int>,Q>	rval =
	forw_Generic_inv_core3(inf_, sup_-inf_ + 1, src_data,
			       img.domain(), invtempl, dest_ps,
			       circle, Gamma, (Q*)0, (R*)0, (S*)0);

    delete[] src_data;

    return rval;
}

template <class Q, class R, class S, class T>
// IA_Image<IA_Point<int>, R>
IA_Image<IA_Point<int>, Q>
generic_product (const IA_DDTemplate< IA_Image<IA_Point<int>, S> > &templ,
		 const IA_CoreImage<IA_Point<int>, T> &img,
		 const IA_Set<IA_Point<int> > &dest_ps,
		 R (*circle)(T,S),
		 Q (*Gamma)(R*,unsigned),
		 const Q*,
		 const R*,
		 const S*)
{

    if (templ.is_a(IA_InvariantDT<IA_Image<IA_Point<int>, S> >::s_type())) {
	return forw_Generic_inv3
	    (img, (IA_CoreImage<IA_Point<int>,S>&)((IA_InvariantDT<IA_Image<IA_Point<int>, S> >*)IA_FBI<IA_Point<int>, IA_Point<int>, S, S, S>::extract_baseptr(templ))->value,
	     dest_ps, (R(*)(T,S))circle,
	     (Q(*)(R*,unsigned))Gamma,
	     (const Q*)0, (const R*)0, (const S*)0);
	//    } else if (templ.type() == IA_Lazy_REDUCT_DT<IA_Image<IA_Point<int>, S> >::s_type()) {
    } else {
	IA::not_yet_implemented(__FILE__, __LINE__);
    }

}
@


1.7.1.1
log
@Boxy pointsets constructor replaced with function.
@
text
@a10 3
// Revision 1.7  1994/12/28  22:13:17  ljr
// Bogus return types fixed.
//
d118 1
a118 1
    IA_Set<IA_Point<int> >	src_ps = IA_boxy_pset(inf_,sup_);
d185 1
d251 1
d265 1
a265 1
    IA_Set<IA_Point<int> >	src_ps = IA_boxy_pset(inf_,sup_);
d282 1
d337 1
d405 1
d418 1
a418 1
    IA_Set<IA_Point<int> >	src_ps = IA_boxy_pset(inf_,sup_);
d437 1
d565 1
a565 1
    IA_Set<IA_Point<int> >	src_ps = IA_boxy_pset(inf_,sup_);
d636 1
d702 1
d716 1
a716 1
    IA_Set<IA_Point<int> >	src_ps = IA_boxy_pset(inf_,sup_);
d733 1
d764 1
d832 1
d845 1
a845 1
    IA_Set<IA_Point<int> >	src_ps = IA_boxy_pset(inf_,sup_);
d863 1
@


1.7.1.2
log
@CoreImage has been re-merged with Image.  All special stuff should be
friends of FBI now.
@
text
@a10 3
// Revision 1.7.1.1  1995/01/09  17:48:14  thoth
// Boxy pointsets constructor replaced with function.
//
d51 1
a51 1
		    const IA_Image<IA_Point<int>,S> &templ,
d110 2
a111 2
backw_generic_inv(const IA_Image<IA_Point<int>, T> &img,
		  const IA_Image<IA_Point<int>, S> &invtempl,
d125 1
a125 1
    zero_extend(IA_Image<IA_Point<int>,T>(img), IA_Set<IA_Point<int> >(src_ps),
d139 1
a139 1
generic_product (const IA_Image<IA_Point<int>, T> &img,
d161 1
a161 1
	    IA_Image<IA_Point<int>,S>	tv = templ(base_ip);
d192 1
a192 1
		       const IA_Image<IA_Point<int>,S> &templ,
d254 2
a255 2
backw_Generic_inv(const IA_Image<IA_Point<int>, T> &img,
		  const IA_Image<IA_Point<int>, S> &invtempl,
d270 1
a270 1
    zero_extend(IA_Image<IA_Point<int>,T>(img), IA_Set<IA_Point<int> >(src_ps),
d284 1
a284 1
generic_product (const IA_Image<IA_Point<int>, T> &img,
d297 1
a297 1
	    (img, (IA_Image<IA_Point<int>,S>&)((IA_InvariantDT<IA_Image<IA_Point<int>, S> >*)IA_FBI<IA_Point<int>, IA_Point<int>, S, S, S>::extract_baseptr(templ))->value,
d308 1
a308 1
	    IA_Image<IA_Point<int>,S>	tv = templ(base_ip);
d342 1
a342 1
		       const IA_Image<IA_Point<int>,S> &templ,
d405 2
a406 2
backw_Generic_inv3(const IA_Image<IA_Point<int>, T> &img,
		  const IA_Image<IA_Point<int>, S> &invtempl,
d421 1
a421 1
    zero_extend(IA_Image<IA_Point<int>,T>(img), IA_Set<IA_Point<int> >(src_ps),
d436 1
a436 1
generic_product (const IA_Image<IA_Point<int>, T> &img,
d448 1
a448 1
	    (img, (IA_Image<IA_Point<int>,S>&)((IA_InvariantDT<IA_Image<IA_Point<int>, S> >*)IA_FBI<IA_Point<int>, IA_Point<int>, S, S, S>::extract_baseptr(templ))->value,
d459 1
a459 1
	    IA_Image<IA_Point<int>,S>	tv = templ(base_ip);
d492 1
a492 1
		    const IA_Image<IA_Point<int>,S> &templ,
d551 2
a552 2
forw_generic_inv(const IA_Image<IA_Point<int>, T> &img,
		  const IA_Image<IA_Point<int>, S> &invtempl,
d566 1
a566 1
    zero_extend(IA_Image<IA_Point<int>,T>(img), IA_Set<IA_Point<int> >(src_ps),
d581 1
a581 1
		 const IA_Image<IA_Point<int>, T> &img,
d606 1
a606 1
	    IA_Image<IA_Point<int>,S>	tv = templ(base_ip);
d637 1
a637 1
		       const IA_Image<IA_Point<int>,S> &templ,
d699 2
a700 2
forw_Generic_inv(const IA_Image<IA_Point<int>, T> &img,
		  const IA_Image<IA_Point<int>, S> &invtempl,
d715 1
a715 1
    zero_extend(IA_Image<IA_Point<int>,T>(img), IA_Set<IA_Point<int> >(src_ps),
d730 1
a730 1
		 const IA_Image<IA_Point<int>, T> &img,
d742 1
a742 1
	    (img, (IA_Image<IA_Point<int>,S>&)((IA_InvariantDT<IA_Image<IA_Point<int>, S> >*)IA_FBI<IA_Point<int>, IA_Point<int>, S, S, S>::extract_baseptr(templ))->value,
d763 1
a763 1
		       const IA_Image<IA_Point<int>,S> &templ,
d826 2
a827 2
forw_Generic_inv3(const IA_Image<IA_Point<int>, T> &img,
		  const IA_Image<IA_Point<int>, S> &invtempl,
d842 1
a842 1
    zero_extend(IA_Image<IA_Point<int>,T>(img), IA_Set<IA_Point<int> >(src_ps),
d857 1
a857 1
		 const IA_Image<IA_Point<int>, T> &img,
d868 1
a868 1
	    (img, (IA_Image<IA_Point<int>,S>&)((IA_InvariantDT<IA_Image<IA_Point<int>, S> >*)IA_FBI<IA_Point<int>, IA_Point<int>, S, S, S>::extract_baseptr(templ))->value,
@


1.6
log
@more DOS-inspired renaming.
@
text
@d11 3
d185 2
a186 1
IA_Image<IA_Point<int>,R>
d251 2
a252 1
IA_Image<IA_Point<int>, R>
d282 2
a283 1
IA_Image<IA_Point<int>, R>
d337 2
a338 1
IA_Image<IA_Point<int>,R>
d405 2
a406 1
IA_Image<IA_Point<int>, R>
d437 2
a438 1
IA_Image<IA_Point<int>, R>
d636 2
a637 1
IA_Image<IA_Point<int>,R>
d702 2
a703 1
IA_Image<IA_Point<int>, R>
d733 2
a734 1
IA_Image<IA_Point<int>, R>
d764 2
a765 1
IA_Image<IA_Point<int>,R>
d832 2
a833 1
IA_Image<IA_Point<int>, R>
d863 2
a864 1
IA_Image<IA_Point<int>, R>
@


1.5
log
@DOS-inspired name rework.
@
text
@d11 3
d34 1
a34 1
#include "InvariantDT.h"
@


1.4
log
@Name sanitization
@
text
@d11 3
d28 1
a28 1
#include "IntPointSet.h"
@


1.3
log
@Flesh out the rest of the generic convolutions.
@
text
@d11 3
d35 3
a37 3
IA_Image<IA_IntPoint,R>
backw_generic_inv_core(IA_IntPoint src_infimum,
		    IA_IntPoint src_width,
d39 2
a40 2
		    const IA_CoreImage<IA_IntPoint,S> &templ,
		    IA_IntPointSet dest_ps,
d48 1
a48 1
    IA_IntPointSet	templ_ps = templ.domain();
d56 2
a57 2
	IA_IPIter<IA_IntPoint,S>	iter(templ);
	IA_IntPoint	ip;
d69 2
a70 2
    IA_PSIter<IA_IntPoint>	iter(dest_ps);
    IA_IntPoint	ip;
d93 1
a93 1
    return IA_Image<IA_IntPoint,R>(dest_ps, dest_data, dest_ps.card(), 1);
d97 4
a100 4
IA_Image<IA_IntPoint, R>
backw_generic_inv(const IA_CoreImage<IA_IntPoint, T> &img,
		  const IA_CoreImage<IA_IntPoint, S> &invtempl,
		  const IA_IntPointSet &dest_ps,
d107 3
a109 3
    IA_IntPoint	inf_ = dest_ps.inf()+invtempl.domain().inf();
    IA_IntPoint	sup_ = dest_ps.sup()+invtempl.domain().sup();
    IA_IntPointSet	src_ps = IA_IntPointSet(inf_,sup_);
d113 1
a113 1
    zero_extend(IA_CoreImage<IA_IntPoint,T>(img), IA_Set<IA_IntPoint>(src_ps),
d115 1
a115 1
    IA_Image<IA_IntPoint,R>	rval =
d126 4
a129 4
IA_Image<IA_IntPoint, R>
generic_product (const IA_CoreImage<IA_IntPoint, T> &img,
		 const IA_DDTemplate< IA_Image<IA_IntPoint, S> > &templ,
		 const IA_IntPointSet &dest_ps,
d137 1
a137 1
    if (templ.is_a(IA_InvariantDT<IA_Image<IA_IntPoint, S> >::s_type())) {
d139 1
a139 1
	    (img, ((IA_InvariantDT<IA_Image<IA_IntPoint, S> >*)IA_FBI<IA_IntPoint, IA_IntPoint, S, S, S>::extract_baseptr(templ))->value,
d142 1
a142 1
	//    } else if (templ.type() == IA_Lazy_REDUCT_DT<IA_Image<IA_IntPoint, S> >::s_type()) {
d146 2
a147 2
	IA_PSIter<IA_IntPoint>	dest_iter(dest_ps);
	IA_IntPoint	base_ip;
d149 1
a149 1
	    IA_CoreImage<IA_IntPoint,S>	tv = templ(base_ip);
d151 2
a152 2
	    IA_IPIter<IA_IntPoint,S>	templ_iter(tv);
	    IA_IntPoint	templ_ip;
d158 1
a158 1
		const IA_IntPoint	ip = templ_ip; //+base_ip;
d165 1
a165 1
	return IA_Image<IA_IntPoint,R>(dest_ps, dest_data,
d176 3
a178 3
IA_Image<IA_IntPoint,R>
backw_Generic_inv_core(IA_IntPoint src_infimum,
		       IA_IntPoint src_width,
d180 2
a181 2
		       const IA_CoreImage<IA_IntPoint,S> &templ,
		       IA_IntPointSet dest_ps,
d190 1
a190 1
    IA_IntPointSet	templ_ps = templ.domain();
d198 2
a199 2
	IA_IPIter<IA_IntPoint,S>	iter(templ);
	IA_IntPoint	ip;
d211 2
a212 2
    IA_PSIter<IA_IntPoint>	iter(dest_ps);
    IA_IntPoint	ip;
d237 1
a237 1
    return IA_Image<IA_IntPoint,Q>(dest_ps, dest_data, dest_ps.card(), 1);
d241 4
a244 4
IA_Image<IA_IntPoint, R>
backw_Generic_inv(const IA_CoreImage<IA_IntPoint, T> &img,
		  const IA_CoreImage<IA_IntPoint, S> &invtempl,
		  const IA_IntPointSet &dest_ps,
d252 3
a254 3
    IA_IntPoint	inf_ = dest_ps.inf()+invtempl.domain().inf();
    IA_IntPoint	sup_ = dest_ps.sup()+invtempl.domain().sup();
    IA_IntPointSet	src_ps = IA_IntPointSet(inf_,sup_);
d258 1
a258 1
    zero_extend(IA_CoreImage<IA_IntPoint,T>(img), IA_Set<IA_IntPoint>(src_ps),
d260 1
a260 1
    IA_Image<IA_IntPoint,Q>	rval =
d271 4
a274 4
IA_Image<IA_IntPoint, R>
generic_product (const IA_CoreImage<IA_IntPoint, T> &img,
		 const IA_DDTemplate< IA_Image<IA_IntPoint, S> > &templ,
		 const IA_IntPointSet &dest_ps,
d283 1
a283 1
    if (templ.is_a(IA_InvariantDT<IA_Image<IA_IntPoint, S> >::s_type())) {
d285 1
a285 1
	    (img, (IA_CoreImage<IA_IntPoint,S>&)((IA_InvariantDT<IA_Image<IA_IntPoint, S> >*)IA_FBI<IA_IntPoint, IA_IntPoint, S, S, S>::extract_baseptr(templ))->value,
d289 1
a289 1
	//    } else if (templ.type() == IA_Lazy_REDUCT_DT<IA_Image<IA_IntPoint, S> >::s_type()) {
d293 2
a294 2
	IA_PSIter<IA_IntPoint>	dest_iter(dest_ps);
	IA_IntPoint	base_ip;
d296 1
a296 1
	    IA_CoreImage<IA_IntPoint,S>	tv = templ(base_ip);
d298 2
a299 2
	    IA_IPIter<IA_IntPoint,S>	templ_iter(tv);
	    IA_IntPoint	templ_ip;
d306 1
a306 1
		const IA_IntPoint	ip = templ_ip; //+base_ip;
d314 1
a314 1
	return IA_Image<IA_IntPoint,Q>(dest_ps, dest_data,
d325 3
a327 3
IA_Image<IA_IntPoint,R>
backw_Generic_inv_core3(IA_IntPoint src_infimum,
		       IA_IntPoint src_width,
d329 3
a331 3
		       IA_IntPointSet src_ps,
		       const IA_CoreImage<IA_IntPoint,S> &templ,
		       IA_IntPointSet dest_ps,
d340 1
a340 1
    IA_IntPointSet	templ_ps = templ.domain();
d344 1
a344 1
    IA_IntPoint	*const templ_points = new IA_IntPoint[templ_sz];
d347 1
a347 1
	IA_IPIter<IA_IntPoint,S>	iter(templ);
d359 2
a360 2
    IA_PSIter<IA_IntPoint>	iter(dest_ps);
    IA_IntPoint	ip;
d388 1
a388 1
    return IA_Image<IA_IntPoint,Q>(dest_ps, dest_data, dest_ps.card(), 1);
d392 4
a395 4
IA_Image<IA_IntPoint, R>
backw_Generic_inv3(const IA_CoreImage<IA_IntPoint, T> &img,
		  const IA_CoreImage<IA_IntPoint, S> &invtempl,
		  const IA_IntPointSet &dest_ps,
d402 3
a404 3
    IA_IntPoint	inf_ = dest_ps.inf()+invtempl.domain().inf();
    IA_IntPoint	sup_ = dest_ps.sup()+invtempl.domain().sup();
    IA_IntPointSet	src_ps = IA_IntPointSet(inf_,sup_);
d409 1
a409 1
    zero_extend(IA_CoreImage<IA_IntPoint,T>(img), IA_Set<IA_IntPoint>(src_ps),
d411 1
a411 1
    IA_Image<IA_IntPoint,Q>	rval =
d423 4
a426 4
IA_Image<IA_IntPoint, R>
generic_product (const IA_CoreImage<IA_IntPoint, T> &img,
		 const IA_DDTemplate< IA_Image<IA_IntPoint, S> > &templ,
		 const IA_IntPointSet &dest_ps,
d434 1
a434 1
    if (templ.is_a(IA_InvariantDT<IA_Image<IA_IntPoint, S> >::s_type())) {
d436 1
a436 1
	    (img, (IA_CoreImage<IA_IntPoint,S>&)((IA_InvariantDT<IA_Image<IA_IntPoint, S> >*)IA_FBI<IA_IntPoint, IA_IntPoint, S, S, S>::extract_baseptr(templ))->value,
d440 1
a440 1
	//    } else if (templ.type() == IA_Lazy_REDUCT_DT<IA_Image<IA_IntPoint, S> >::s_type()) {
d444 2
a445 2
	IA_PSIter<IA_IntPoint>	dest_iter(dest_ps);
	IA_IntPoint	base_ip;
d447 1
a447 1
	    IA_CoreImage<IA_IntPoint,S>	tv = templ(base_ip);
d449 2
a450 2
	    IA_IPIter<IA_IntPoint,S>	templ_iter(tv);
	    IA_IntPoint	templ_ip;
d457 1
a457 1
		const IA_IntPoint	ip = templ_ip; //+base_ip;
d465 1
a465 1
	return IA_Image<IA_IntPoint,Q>(dest_ps, dest_data,
d476 3
a478 3
IA_Image<IA_IntPoint,R>
forw_generic_inv_core(IA_IntPoint src_infimum,
		    IA_IntPoint src_width,
d480 2
a481 2
		    const IA_CoreImage<IA_IntPoint,S> &templ,
		    IA_IntPointSet dest_ps,
d489 1
a489 1
    IA_IntPointSet	templ_ps = templ.domain();
d497 2
a498 2
	IA_IPIter<IA_IntPoint,S>	iter(templ);
	IA_IntPoint	ip;
d510 2
a511 2
    IA_PSIter<IA_IntPoint>	iter(dest_ps);
    IA_IntPoint	ip;
d534 1
a534 1
    return IA_Image<IA_IntPoint,R>(dest_ps, dest_data, dest_ps.card(), 1);
d538 4
a541 4
IA_Image<IA_IntPoint, R>
forw_generic_inv(const IA_CoreImage<IA_IntPoint, T> &img,
		  const IA_CoreImage<IA_IntPoint, S> &invtempl,
		  const IA_IntPointSet &dest_ps,
d548 3
a550 3
    IA_IntPoint	inf_ = dest_ps.inf()-invtempl.domain().sup();
    IA_IntPoint	sup_ = dest_ps.sup()-invtempl.domain().inf();
    IA_IntPointSet	src_ps = IA_IntPointSet(inf_,sup_);
d554 1
a554 1
    zero_extend(IA_CoreImage<IA_IntPoint,T>(img), IA_Set<IA_IntPoint>(src_ps),
d556 1
a556 1
    IA_Image<IA_IntPoint,R>	rval =
d567 4
a570 4
IA_Image<IA_IntPoint, R>
generic_product (const IA_DDTemplate< IA_Image<IA_IntPoint, S> > &templ,
		 const IA_CoreImage<IA_IntPoint, T> &img,
		 const IA_IntPointSet &dest_ps,
d578 1
a578 1
    if (templ.is_a(IA_InvariantDT<IA_Image<IA_IntPoint, S> >::s_type())) {
d580 1
a580 1
	    (img, ((IA_InvariantDT<IA_Image<IA_IntPoint, S> >*)IA_FBI<IA_IntPoint, IA_IntPoint, S, S, S>::extract_baseptr(templ))->value,
d591 2
a592 2
	IA_PSIter<IA_IntPoint>	src_iter(img.domain());
	IA_IntPoint	base_ip;
d594 1
a594 1
	    IA_CoreImage<IA_IntPoint,S>	tv = templ(base_ip);
d596 2
a597 2
	    IA_IPIter<IA_IntPoint,S>	templ_iter(tv);
	    IA_IntPoint	templ_ip;
d602 1
a602 1
		const IA_IntPoint	ip = templ_ip; //+base_ip;
d610 1
a610 1
	return IA_Image<IA_IntPoint,R>(dest_ps, dest_data,
d621 3
a623 3
IA_Image<IA_IntPoint,R>
forw_Generic_inv_core(IA_IntPoint src_infimum,
		       IA_IntPoint src_width,
d625 2
a626 2
		       const IA_CoreImage<IA_IntPoint,S> &templ,
		       IA_IntPointSet dest_ps,
d635 1
a635 1
    IA_IntPointSet	templ_ps = templ.domain();
d643 2
a644 2
	IA_IPIter<IA_IntPoint,S>	iter(templ);
	IA_IntPoint	ip;
d656 2
a657 2
    IA_PSIter<IA_IntPoint>	iter(dest_ps);
    IA_IntPoint	ip;
d682 1
a682 1
    return IA_Image<IA_IntPoint,Q>(dest_ps, dest_data, dest_ps.card(), 1);
d686 4
a689 4
IA_Image<IA_IntPoint, R>
forw_Generic_inv(const IA_CoreImage<IA_IntPoint, T> &img,
		  const IA_CoreImage<IA_IntPoint, S> &invtempl,
		  const IA_IntPointSet &dest_ps,
d697 3
a699 3
    IA_IntPoint	inf_ = dest_ps.inf()-invtempl.domain().sup();
    IA_IntPoint	sup_ = dest_ps.sup()-invtempl.domain().inf();
    IA_IntPointSet	src_ps = IA_IntPointSet(inf_,sup_);
d703 1
a703 1
    zero_extend(IA_CoreImage<IA_IntPoint,T>(img), IA_Set<IA_IntPoint>(src_ps),
d705 1
a705 1
    IA_Image<IA_IntPoint,Q>	rval =
d716 4
a719 4
IA_Image<IA_IntPoint, R>
generic_product (const IA_DDTemplate< IA_Image<IA_IntPoint, S> > &templ,
		 const IA_CoreImage<IA_IntPoint, T> &img,
		 const IA_IntPointSet &dest_ps,
d728 1
a728 1
    if (templ.is_a(IA_InvariantDT<IA_Image<IA_IntPoint, S> >::s_type())) {
d730 1
a730 1
	    (img, (IA_CoreImage<IA_IntPoint,S>&)((IA_InvariantDT<IA_Image<IA_IntPoint, S> >*)IA_FBI<IA_IntPoint, IA_IntPoint, S, S, S>::extract_baseptr(templ))->value,
d734 1
a734 1
	//    } else if (templ.type() == IA_Lazy_REDUCT_DT<IA_Image<IA_IntPoint, S> >::s_type()) {
d746 3
a748 3
IA_Image<IA_IntPoint,R>
forw_Generic_inv_core3(IA_IntPoint src_infimum,
		       IA_IntPoint src_width,
d750 3
a752 3
		       IA_IntPointSet src_ps,
		       const IA_CoreImage<IA_IntPoint,S> &templ,
		       IA_IntPointSet dest_ps,
d761 1
a761 1
    IA_IntPointSet	templ_ps = templ.domain();
d765 1
a765 1
    IA_IntPoint	*const templ_points = new IA_IntPoint[templ_sz];
d769 1
a769 1
	IA_IPIter<IA_IntPoint,S>	iter(templ);
d780 2
a781 2
    IA_PSIter<IA_IntPoint>	iter(dest_ps);
    IA_IntPoint	ip;
d809 1
a809 1
    return IA_Image<IA_IntPoint,Q>(dest_ps, dest_data, dest_ps.card(), 1);
d813 4
a816 4
IA_Image<IA_IntPoint, R>
forw_Generic_inv3(const IA_CoreImage<IA_IntPoint, T> &img,
		  const IA_CoreImage<IA_IntPoint, S> &invtempl,
		  const IA_IntPointSet &dest_ps,
d823 3
a825 3
    IA_IntPoint	inf_ = dest_ps.inf()-invtempl.domain().sup();
    IA_IntPoint	sup_ = dest_ps.sup()-invtempl.domain().inf();
    IA_IntPointSet	src_ps = IA_IntPointSet(inf_,sup_);
d830 1
a830 1
    zero_extend(IA_CoreImage<IA_IntPoint,T>(img), IA_Set<IA_IntPoint>(src_ps),
d832 1
a832 1
    IA_Image<IA_IntPoint,Q>	rval =
d843 4
a846 4
IA_Image<IA_IntPoint, R>
generic_product (const IA_DDTemplate< IA_Image<IA_IntPoint, S> > &templ,
		 const IA_CoreImage<IA_IntPoint, T> &img,
		 const IA_IntPointSet &dest_ps,
d854 1
a854 1
    if (templ.is_a(IA_InvariantDT<IA_Image<IA_IntPoint, S> >::s_type())) {
d856 1
a856 1
	    (img, (IA_CoreImage<IA_IntPoint,S>&)((IA_InvariantDT<IA_Image<IA_IntPoint, S> >*)IA_FBI<IA_IntPoint, IA_IntPoint, S, S, S>::extract_baseptr(templ))->value,
d860 1
a860 1
	//    } else if (templ.type() == IA_Lazy_REDUCT_DT<IA_Image<IA_IntPoint, S> >::s_type()) {
@


1.2
log
@generic convolutions will now compile.
@
text
@d11 3
d318 151
d730 126
@


1.1
log
@Initial revision
@
text
@d10 4
a13 1
// $Log: DDTempl.c,v $
d133 3
a135 1
	    (img, ((IA_InvariantDT<IA_Image<IA_IntPoint, S> >*)IA_FBI<IA_IntPoint,S>::extract_baseptr(templ))->value, dest_ps, circle, gamma, gamma_zero, ring_zero, (S*)0);
d171 1
a171 1
backw_generic_inv_core(IA_IntPoint src_infimum,
d177 1
a177 1
		       Q (*Gamma)(R,R),
d236 1
a236 1
backw_generic_inv(const IA_CoreImage<IA_IntPoint, T> &img,
d240 1
a240 1
		  Q (*Gamma)(R,R),
d255 1
a255 1
	backw_generic_inv_core(inf_, sup_-inf_ + 1, src_data,
d278 5
a282 4
	return backw_generic_inv
	    (img, ((IA_InvariantDT<IA_Image<IA_IntPoint, S> >*)IA_FBI<IA_IntPoint,S>::extract_baseptr(templ))->value,
	     dest_ps, circle, Gamma, ring_zero,
	     (Q*)0, (R*)0, (S*)0);
d310 270
@
