head	1.3;
access
	monica
	thoth;
symbols;
locks
	thoth:1.3; strict;
comment	@// @;


1.3
date	94.10.24.20.30.42;	author monica;	state Exp;
branches;
next	1.2;

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

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


desc
@Test of assorted image-image operations.
@


1.3
log
@updated type names
@
text
@// Emacs: -*- C++ -*-
static char test_ops_rcsid[] = "$Id: test-ops.c,v 1.2 1994/08/18 22:17:06 thoth Exp $";

//
// $Log: test-ops.c,v $
// Revision 1.2  1994/08/18  22:17:06  thoth
// incomplete updating.
//
// Revision 1.1  93/03/10  13:55:21  thoth
// Initial revision
// 

#include <rand48.h>

#include "ImageIter.h"
#include "PSIter.h"

#include "test-ops.h"

template <class T>
RandomDI<T>::RandomDI(IA_Set<IA_Point<int> > ps, T b1, T b2)
:IA_ClosureI<IA_Point<int>,T>(ps)
{
    if (b1>b2) {
	max = b1;
	min = b2;
    } else {
	max = b2;
	min = b1;
    }
}

int RandomDI<int>::operator()(const IA_Point<int> &) const {
    return (int)(lrand48()%(max-min+1) + min);
}
#if 0
float RandomDI<float>::operator()(const IA_Point<int> &) const {
    return (float)(drand48()*(max-min) + min);
}

double RandomDI<double>::operator()(const IA_Point<int> &) const {
    return drand48()*(max-min) + min;
}
#endif


//
//
//

template <class P, class T>
void test_plus(const IA_Image<P,T> &a, const IA_Image<P,T> &b,
	       const IA_Image<P,T> &ab)
{
    if (ab.domain() != a.domain() ||
	ab.domain() != b.domain()) {
	cout << "test_plus: domain mismatch\n";
	return;
    }
    IA_IVIter<P,T>	itera(a), iterb(b), iterab(ab);
    T	tempa, tempb, tempab;
    unsigned	idx=0;
    while (itera(tempa) && iterb(tempb) && iterab(tempab)) {
	if (tempab != tempa+tempb) {
	    cout << "test_plus: value mismatch at index " << idx << ":" <<
		tempab << "!=" << tempa << "+" << tempb << "\n";;
	}
	idx++;
    }
}

template <class P, class T>
void test_minus(const IA_Image<P,T> &a, const IA_Image<P,T> &b,
		const IA_Image<P,T> &ab)
{
    if (ab.domain() != a.domain() ||
	ab.domain() != b.domain()) {
	cout << "test_minus: domain mismatch\n";
	return;
    }
    IA_IVIter<P,T>	itera(a), iterb(b), iterab(ab);
    T	tempa, tempb, tempab;
    unsigned	idx=0;
    while (itera(tempa) && iterb(tempb) && iterab(tempab)) {
	if (tempab != tempa-tempb) {
	    cout << "test_minus: value mismatch at index " << idx << "\n";;
	}
	idx++;
    }
}

template <class P, class T>
void test_mult(const IA_Image<P,T> &a, const IA_Image<P,T> &b,
	       const IA_Image<P,T> &ab)
{
    if (ab.domain() != a.domain() ||
	ab.domain() != b.domain()) {
	cout << "test_mult: domain mismatch\n";
	return;
    }
    IA_IVIter<P,T>	itera(a), iterb(b), iterab(ab);
    T	tempa, tempb, tempab;
    unsigned	idx=0;
    while (itera(tempa) && iterb(tempb) && iterab(tempab)) {
	if (tempab != tempa*tempb) {
	    cout << "test_mult: value mismatch at index " << idx << "\n";;
	}
	idx++;
    }
}

template <class P, class T>
void test_divide(const IA_Image<P,T> &a, const IA_Image<P,T> &b,
		 const IA_Image<P,T> &ab)
{
    if (ab.domain() != a.domain() ||
	ab.domain() != b.domain()) {
	cout << "test_divide: domain mismatch\n";
	return;
    }
    IA_IVIter<P,T>	itera(a), iterb(b), iterab(ab);
    T	tempa, tempb, tempab;
    unsigned	idx=0;
    while (itera(tempa) && iterb(tempb) && iterab(tempab)) {
	if (tempab != tempa/tempb) {
	    cout << "test_divide: value mismatch at index " << idx << "\n";;
	}
	idx++;
    }
}

template <class P, class T>
void test_pweq(const IA_Image<P,T> &a, const IA_Image<P,T> &b,
		 const IA_Image<P,T> &ab)
{
    if (ab.domain() != a.domain() ||
	ab.domain() != b.domain()) {
	cout << "test_divide: domain mismatch\n";
	return;
    }
    IA_IVIter<P,T>	itera(a), iterb(b), iterab(ab);
    T	tempa, tempb, tempab;
    unsigned	idx=0;
    while (itera(tempa) && iterb(tempb) && iterab(tempab)) {
	if (tempab != (tempa==tempb)) {
	    cout << "test_divide: value mismatch at index " << idx << "\n";;
	}
	idx++;
    }
}

template <class P, class T>
void test_equal(const IA_Image<P,T> &a, const IA_Image<P,T> &b,
		 int ab)
{
    if (a.domain() != b.domain()) {
	cout << "test_equal: domain mismatch\n";
	return;
    }
    IA_IVIter<P,T>	itera(a), iterb(b);
    T	tempa, tempb;
    unsigned	result=1;
    while (itera(tempa) && iterb(tempb)) {
	if (tempa != tempb) {
	    result=0;
	    break;
	}
    }
    if (result != ab)
	cout << "test_equal: value mismatch\n";
}

template <class P, class T>
void test_strictne(const IA_Image<P,T> &a, const IA_Image<P,T> &b,
		   int ab)
{
    if (a.domain() != b.domain()) {
	cout << "test_equal: domain mismatch\n";
	return;
    }
    IA_IVIter<P,T>	itera(a), iterb(b);
    T	tempa, tempb;
    unsigned	result=1;
    while (itera(tempa) && iterb(tempb)) {
	if (tempa == tempb) {
	    result=0;
	    break;
	}
    }
    if (result != ab)
	cout << "test_equal: value mismatch\n";
}



template <class P, class T>
void test_restrict(const IA_Image<P,T> &a,
		   const IA_Set<IA_Point<int> > &ps,
		   const IA_Image<IA_Point<int>,T> &arps)
{
    IA_Set<IA_Point<int> >	ips = a.domain()&ps;

    if (ips != arps.domain()) {
	cerr << "domain mismatch in result of restriction" << endl;
    }

    if (!ips.extensive()) {
	// unable to test the values of the image: comprehensive
	return;
    }

    IA_PSIter<IA_Point<int> >	iter(ips);
    IA_Point<int> 	p;

    while (iter(p)) {
	if (a(p) != arps(p)) {
	    cerr << "value mismatch at point " << p << endl;
	}
    }
}
@


1.2
log
@incomplete updating.
@
text
@d2 1
a2 1
static char test_ops_rcsid[] = "$Id: test-ops.c,v 1.1 93/03/10 13:55:21 thoth Exp Locker: thoth $";
d5 4
a8 1
// $Log:	test-ops.c,v $
d21 2
a22 2
RandomDI<T>::RandomDI(IA_IntPointSet ps, T b1, T b2)
:IA_ClosureI<IA_IntPoint,T>(ps)
d33 1
a33 1
int RandomDI<int>::operator()(const IA_IntPoint &) const {
d37 1
a37 1
float RandomDI<float>::operator()(const IA_IntPoint &) const {
d41 1
a41 1
double RandomDI<double>::operator()(const IA_IntPoint &) const {
d198 2
a199 2
		   const IA_Set<IA_IntPoint> &ps,
		   const IA_Image<IA_IntPoint,T> &arps)
d201 1
a201 1
    IA_IntPointSet	ips = a.domain()&ps;
d212 2
a213 2
    IA_PSIter<IA_IntPoint>	iter(ips);
    IA_IntPoint	p;
@


1.1
log
@Initial revision
@
text
@d2 1
a2 1
static char test_ops_rcsid[] = "$Id: test103.c,v 1.1 93/02/20 16:49:59 thoth Exp $";
d5 4
a8 1
// $Log:	test103.c,v $
d11 4
a14 1
#include "DIVIter.h"
d19 1
a19 1
:IA_OtherDI<T>(ps)
d48 3
a50 3
template <class T>
void test_plus(const IA_DiscreteImage<T> &a, const IA_DiscreteImage<T> &b,
	       const IA_DiscreteImage<T> &ab)
d57 1
a57 1
    IA_DIVIter<int>	itera(a), iterb(b), iterab(ab);
d62 2
a63 1
	    cout << "test_plus: value mismatch at index " << idx << "\n";;
d69 3
a71 3
template <class T>
void test_minus(const IA_DiscreteImage<T> &a, const IA_DiscreteImage<T> &b,
		const IA_DiscreteImage<T> &ab)
d78 1
a78 1
    IA_DIVIter<int>	itera(a), iterb(b), iterab(ab);
d89 3
a91 3
template <class T>
void test_mult(const IA_DiscreteImage<T> &a, const IA_DiscreteImage<T> &b,
	       const IA_DiscreteImage<T> &ab)
d98 1
a98 1
    IA_DIVIter<int>	itera(a), iterb(b), iterab(ab);
d109 3
a111 3
template <class T>
void test_divide(const IA_DiscreteImage<T> &a, const IA_DiscreteImage<T> &b,
		 const IA_DiscreteImage<T> &ab)
d118 1
a118 1
    IA_DIVIter<int>	itera(a), iterb(b), iterab(ab);
d129 3
a131 3
template <class T>
void test_pweq(const IA_DiscreteImage<T> &a, const IA_DiscreteImage<T> &b,
		 const IA_DiscreteImage<T> &ab)
d138 1
a138 1
    IA_DIVIter<int>	itera(a), iterb(b), iterab(ab);
d149 2
a150 2
template <class T>
void test_equal(const IA_DiscreteImage<T> &a, const IA_DiscreteImage<T> &b,
d157 1
a157 1
    IA_DIVIter<int>	itera(a), iterb(b);
d170 3
a172 3
template <class T>
void test_strictne(const IA_DiscreteImage<T> &a, const IA_DiscreteImage<T> &b,
		 int ab)
d178 1
a178 1
    IA_DIVIter<int>	itera(a), iterb(b);
d189 28
@
