vector_dist_operators_unit_tests.hpp 17.5 KB
Newer Older
Pietro Incardona's avatar
Pietro Incardona committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
/*
 * vector_dist_operators_unit_tests.hpp
 *
 *  Created on: Jun 11, 2016
 *      Author: i-bird
 */

#ifndef SRC_VECTOR_VECTOR_DIST_OPERATORS_UNIT_TESTS_HPP_
#define SRC_VECTOR_VECTOR_DIST_OPERATORS_UNIT_TESTS_HPP_

constexpr int A = 0;
constexpr int B = 1;
constexpr int C = 2;

constexpr int PA = 3;
constexpr int PB = 4;
constexpr int PC = 5;

//////////////////// Here we define all the function to checl the operators

template <unsigned int prp, typename vector> bool check_values(const vector & v,float a)
{
	bool ret = true;
	auto it = v.getDomainIterator();

	while (it.isNext())
	{
		ret &= v.template getProp<prp>(it.get()) == a;

		++it;
	}

	BOOST_REQUIRE_EQUAL(ret,true);

	return ret;
}

template <typename vector> bool check_values_complex_expr(const vector & vd)
{
	bool ret = true;
	auto it = vd.getDomainIterator();

	while (it.isNext())
	{
		auto key = it.get();

		float base1 = vd.template getProp<B>(key) + 2.0 + vd.template getProp<B>(key) - 2.0*vd.template getProp<C>(key) / 5.0;
		float base2 = vd.template getProp<A>(key);

		ret &=  base1 == base2;

		++it;
	}

	BOOST_REQUIRE_EQUAL(ret,true);

	return ret;
}

Pietro Incardona's avatar
Pietro Incardona committed
60
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_sum(const vector & vd, double d)
Pietro Incardona's avatar
Pietro Incardona committed
61 62 63 64 65 66 67 68
{
	bool ret = true;
	auto it = vd.getDomainIterator();

	while (it.isNext())
	{
		auto key = it.get();

Pietro Incardona's avatar
Pietro Incardona committed
69 70
		rtype base1 = vd.template getProp<B>(key) + d;
		rtype base2 = vd.template getProp<A>(key);
Pietro Incardona's avatar
Pietro Incardona committed
71 72 73 74 75 76 77 78 79 80 81

		ret &=  base1 == base2;

		++it;
	}

	BOOST_REQUIRE_EQUAL(ret,true);

	return ret;
}

Pietro Incardona's avatar
Pietro Incardona committed
82
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_sum(const vector & vd1, const vector & vd2)
Pietro Incardona's avatar
Pietro Incardona committed
83 84 85 86 87 88 89 90
{
	bool ret = true;
	auto it = vd1.getDomainIterator();

	while (it.isNext())
	{
		auto key = it.get();

Pietro Incardona's avatar
Pietro Incardona committed
91 92
		rtype base1 = vd1.template getProp<B>(key) + vd2.template getProp<C>(key);
		rtype base2 = vd1.template getProp<A>(key);
Pietro Incardona's avatar
Pietro Incardona committed
93 94 95 96 97 98 99 100 101 102 103

		ret &=  base1 == base2;

		++it;
	}

	BOOST_REQUIRE_EQUAL(ret,true);

	return ret;
}

Pietro Incardona's avatar
Pietro Incardona committed
104
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_sum_3(const vector & vd1)
Pietro Incardona's avatar
Pietro Incardona committed
105 106 107 108 109 110 111 112
{
	bool ret = true;
	auto it = vd1.getDomainIterator();

	while (it.isNext())
	{
		auto key = it.get();

Pietro Incardona's avatar
Pietro Incardona committed
113 114
		rtype base1 = vd1.template getProp<B>(key) + vd1.template getProp<C>(key) + vd1.template getProp<B>(key);
		rtype base2 = vd1.template getProp<A>(key);
Pietro Incardona's avatar
Pietro Incardona committed
115 116 117 118 119 120 121 122 123 124 125

		ret &=  base1 == base2;

		++it;
	}

	BOOST_REQUIRE_EQUAL(ret,true);

	return ret;
}

Pietro Incardona's avatar
Pietro Incardona committed
126
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_sum_4(const vector & vd1)
Pietro Incardona's avatar
Pietro Incardona committed
127 128 129 130 131 132 133 134
{
	bool ret = true;
	auto it = vd1.getDomainIterator();

	while (it.isNext())
	{
		auto key = it.get();

Pietro Incardona's avatar
Pietro Incardona committed
135 136
		rtype base1 = vd1.template getProp<B>(key) + vd1.template getProp<C>(key) + vd1.template getProp<B>(key) + vd1.template getProp<C>(key);
		rtype base2 = vd1.template getProp<A>(key);
Pietro Incardona's avatar
Pietro Incardona committed
137 138 139 140 141 142 143 144 145 146 147

		ret &=  base1 == base2;

		++it;
	}

	BOOST_REQUIRE_EQUAL(ret,true);

	return ret;
}

Pietro Incardona's avatar
Pietro Incardona committed
148
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_sub(const vector & vd, double d)
Pietro Incardona's avatar
Pietro Incardona committed
149 150 151 152 153 154 155 156
{
	bool ret = true;
	auto it = vd.getDomainIterator();

	while (it.isNext())
	{
		auto key = it.get();

Pietro Incardona's avatar
Pietro Incardona committed
157 158
		rtype base1 = vd.template getProp<B>(key) - d;
		rtype base2 = vd.template getProp<A>(key);
Pietro Incardona's avatar
Pietro Incardona committed
159 160 161 162 163 164 165 166 167 168 169

		ret &=  base1 == base2;

		++it;
	}

	BOOST_REQUIRE_EQUAL(ret,true);

	return ret;
}

Pietro Incardona's avatar
Pietro Incardona committed
170
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_sub(double d, const vector & vd)
Pietro Incardona's avatar
Pietro Incardona committed
171 172 173 174 175 176 177 178
{
	bool ret = true;
	auto it = vd.getDomainIterator();

	while (it.isNext())
	{
		auto key = it.get();

Pietro Incardona's avatar
Pietro Incardona committed
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
		rtype base1 = d - vd.template getProp<B>(key);
		rtype base2 = vd.template getProp<A>(key);

		ret &=  base1 == base2;

		++it;
	}

	BOOST_REQUIRE_EQUAL(ret,true);

	return ret;
}

template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_sub(const vector & vd1, const vector & vd2)
{
	bool ret = true;
	auto it = vd1.getDomainIterator();

	while (it.isNext())
	{
		auto key = it.get();

		rtype base1 = vd1.template getProp<C>(key) - vd2.template getProp<B>(key);
		rtype base2 = vd1.template getProp<A>(key);
Pietro Incardona's avatar
Pietro Incardona committed
203 204 205 206 207 208 209 210 211 212 213

		ret &=  base1 == base2;

		++it;
	}

	BOOST_REQUIRE_EQUAL(ret,true);

	return ret;
}

Pietro Incardona's avatar
Pietro Incardona committed
214
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_sub_31(const vector & vd1)
Pietro Incardona's avatar
Pietro Incardona committed
215 216 217 218 219 220 221 222
{
	bool ret = true;
	auto it = vd1.getDomainIterator();

	while (it.isNext())
	{
		auto key = it.get();

Pietro Incardona's avatar
Pietro Incardona committed
223 224
		rtype base1 = vd1.template getProp<B>(key) - (vd1.template getProp<C>(key) + vd1.template getProp<B>(key));
		rtype base2 = vd1.template getProp<A>(key);
Pietro Incardona's avatar
Pietro Incardona committed
225 226 227 228 229 230 231 232 233 234 235

		ret &=  base1 == base2;

		++it;
	}

	BOOST_REQUIRE_EQUAL(ret,true);

	return ret;
}

Pietro Incardona's avatar
Pietro Incardona committed
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282

template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_sub_32(const vector & vd1)
{
	bool ret = true;
	auto it = vd1.getDomainIterator();

	while (it.isNext())
	{
		auto key = it.get();

		rtype base1 = (vd1.template getProp<C>(key) + vd1.template getProp<B>(key)) - vd1.template getProp<B>(key);
		rtype base2 = vd1.template getProp<A>(key);

		ret &=  base1 == base2;

		++it;
	}

	BOOST_REQUIRE_EQUAL(ret,true);

	return ret;
}

template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_sub_4(const vector & vd1)
{
	bool ret = true;
	auto it = vd1.getDomainIterator();

	while (it.isNext())
	{
		auto key = it.get();

		rtype base1 = (vd1.template getProp<C>(key) + vd1.template getProp<B>(key)) - (vd1.template getProp<C>(key) + vd1.template getProp<B>(key));
		rtype base2 = vd1.template getProp<A>(key);

		ret &=  base1 == base2;

		++it;
	}

	BOOST_REQUIRE_EQUAL(ret,true);

	return ret;
}


template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_mul(const vector & vd, double d)
Pietro Incardona's avatar
Pietro Incardona committed
283 284 285 286 287 288 289 290
{
	bool ret = true;
	auto it = vd.getDomainIterator();

	while (it.isNext())
	{
		auto key = it.get();

Pietro Incardona's avatar
Pietro Incardona committed
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337
		rtype base1 = vd.template getProp<B>(key) * d;
		rtype base2 = vd.template getProp<A>(key);

		ret &=  base1 == base2;

		++it;
	}

	BOOST_REQUIRE_EQUAL(ret,true);

	return ret;
}


template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_mul(const vector & vd1, const vector & vd2)
{
	bool ret = true;
	auto it = vd1.getDomainIterator();

	while (it.isNext())
	{
		auto key = it.get();

		rtype base1 = vd1.template getProp<C>(key) * vd2.template getProp<B>(key);
		rtype base2 = vd1.template getProp<A>(key);

		ret &=  base1 == base2;

		++it;
	}

	BOOST_REQUIRE_EQUAL(ret,true);

	return ret;
}

template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_mul_3(const vector & vd1)
{
	bool ret = true;
	auto it = vd1.getDomainIterator();

	while (it.isNext())
	{
		auto key = it.get();

		rtype base1 = vd1.template getProp<B>(key) * (vd1.template getProp<B>(key) + vd1.template getProp<C>(key));
		rtype base2 = vd1.template getProp<A>(key);
Pietro Incardona's avatar
Pietro Incardona committed
338 339 340 341 342 343 344 345 346 347 348 349

		ret &=  base1 == base2;

		++it;
	}

	BOOST_REQUIRE_EQUAL(ret,true);

	return ret;
}


Pietro Incardona's avatar
Pietro Incardona committed
350
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_mul_4(const vector & vd1)
Pietro Incardona's avatar
Pietro Incardona committed
351 352 353 354 355 356 357 358
{
	bool ret = true;
	auto it = vd1.getDomainIterator();

	while (it.isNext())
	{
		auto key = it.get();

Pietro Incardona's avatar
Pietro Incardona committed
359 360
		rtype base1 = (vd1.template getProp<B>(key) + vd1.template getProp<C>(key)) * (vd1.template getProp<B>(key) + vd1.template getProp<C>(key));
		rtype base2 = vd1.template getProp<A>(key);
Pietro Incardona's avatar
Pietro Incardona committed
361 362 363 364 365 366 367 368 369 370 371 372

		ret &=  base1 == base2;

		++it;
	}

	BOOST_REQUIRE_EQUAL(ret,true);

	return ret;
}


Pietro Incardona's avatar
Pietro Incardona committed
373 374

template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_div(const vector & vd, double d)
Pietro Incardona's avatar
Pietro Incardona committed
375 376 377 378 379 380 381 382
{
	bool ret = true;
	auto it = vd.getDomainIterator();

	while (it.isNext())
	{
		auto key = it.get();

Pietro Incardona's avatar
Pietro Incardona committed
383 384
		rtype base1 = vd.template getProp<B>(key) / d;
		rtype base2 = vd.template getProp<A>(key);
Pietro Incardona's avatar
Pietro Incardona committed
385 386 387 388 389 390 391 392 393 394 395

		ret &=  base1 == base2;

		++it;
	}

	BOOST_REQUIRE_EQUAL(ret,true);

	return ret;
}

Pietro Incardona's avatar
Pietro Incardona committed
396
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_div(double d, const vector & vd)
Pietro Incardona's avatar
Pietro Incardona committed
397 398 399 400 401 402 403 404
{
	bool ret = true;
	auto it = vd.getDomainIterator();

	while (it.isNext())
	{
		auto key = it.get();

Pietro Incardona's avatar
Pietro Incardona committed
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428
		rtype base1 = d / vd.template getProp<B>(key);
		rtype base2 = vd.template getProp<A>(key);

		ret &=  base1 == base2;

		++it;
	}

	BOOST_REQUIRE_EQUAL(ret,true);

	return ret;
}

template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_div(const vector & vd1, const vector & vd2)
{
	bool ret = true;
	auto it = vd1.getDomainIterator();

	while (it.isNext())
	{
		auto key = it.get();

		rtype base1 = vd1.template getProp<C>(key) / vd2.template getProp<B>(key);
		rtype base2 = vd1.template getProp<A>(key);
Pietro Incardona's avatar
Pietro Incardona committed
429 430 431 432 433 434 435 436 437 438 439

		ret &=  base1 == base2;

		++it;
	}

	BOOST_REQUIRE_EQUAL(ret,true);

	return ret;
}

Pietro Incardona's avatar
Pietro Incardona committed
440
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_div_31(const vector & vd1)
Pietro Incardona's avatar
Pietro Incardona committed
441 442 443 444 445 446 447 448
{
	bool ret = true;
	auto it = vd1.getDomainIterator();

	while (it.isNext())
	{
		auto key = it.get();

Pietro Incardona's avatar
Pietro Incardona committed
449 450
		rtype base1 = vd1.template getProp<B>(key) / (vd1.template getProp<B>(key) + vd1.template getProp<C>(key));
		rtype base2 = vd1.template getProp<A>(key);
Pietro Incardona's avatar
Pietro Incardona committed
451 452 453 454 455 456 457 458 459 460 461

		ret &=  base1 == base2;

		++it;
	}

	BOOST_REQUIRE_EQUAL(ret,true);

	return ret;
}

Pietro Incardona's avatar
Pietro Incardona committed
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507
template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_div_32(const vector & vd1)
{
	bool ret = true;
	auto it = vd1.getDomainIterator();

	while (it.isNext())
	{
		auto key = it.get();

		rtype base1 = (vd1.template getProp<C>(key) + vd1.template getProp<B>(key)) / vd1.template getProp<B>(key);
		rtype base2 = vd1.template getProp<A>(key);

		ret &=  base1 == base2;

		++it;
	}

	BOOST_REQUIRE_EQUAL(ret,true);

	return ret;
}


template <typename rtype, typename vector, unsigned int A, unsigned int B, unsigned int C> bool check_values_div_4(const vector & vd1)
{
	bool ret = true;
	auto it = vd1.getDomainIterator();

	while (it.isNext())
	{
		auto key = it.get();

		rtype base1 = (vd1.template getProp<B>(key) + vd1.template getProp<C>(key)) / (vd1.template getProp<B>(key) + vd1.template getProp<C>(key));
		rtype base2 = vd1.template getProp<A>(key);

		ret &=  base1 == base2;

		++it;
	}

	BOOST_REQUIRE_EQUAL(ret,true);

	return ret;
}


Pietro Incardona's avatar
Pietro Incardona committed
508 509 510 511 512 513 514 515 516 517 518 519
template <typename vector> void fill_values(const vector & v)
{
	auto it = v.getDomainIterator();

	while (it.isNext())
	{
		auto p = it.get();

		v.template getProp<A>(p) = p.getKey()+1;
		v.template getProp<B>(p) = 2.0*p.getKey()+1;
		v.template getProp<C>(p) = 3.0*p.getKey()+1;

Pietro Incardona's avatar
Pietro Incardona committed
520 521 522 523 524 525 526
		for (size_t k = 0 ; k < 3 ; k++)
		{
			v.template getProp<PA>(p) = p.getKey()+1+k;
			v.template getProp<PB>(p) = 2.0*p.getKey()+1+k;
			v.template getProp<PC>(p) = 3.0*p.getKey()+1+k;
		}

Pietro Incardona's avatar
Pietro Incardona committed
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553
		++it;
	}
}

float getProp0(vector_dist<3,float,aggregate<float,float,float,VectorS<3,float>,VectorS<3,float>,VectorS<3,float>>> & v, size_t p)
{
	return v.template getProp<A>(p);
}

////////////////////////////////////////////////////////////////////////////

BOOST_AUTO_TEST_SUITE( vector_dist_test )


BOOST_AUTO_TEST_CASE( vector_dist_operators_test )
{
	if (create_vcluster().getProcessingUnits() > 3)
		return;

	Box<3,float> box({0.0,0.0,0.0},{1.0,1.0,1.0});

	// Boundary conditions
	size_t bc[3]={PERIODIC,PERIODIC,PERIODIC};

	// ghost
	Ghost<3,float> ghost(0.05);

Pietro Incardona's avatar
Pietro Incardona committed
554 555 556
	// vector type
	typedef vector_dist<3,float,aggregate<float,float,float,VectorS<3,float>,VectorS<3,float>,VectorS<3,float>>> vtype;

Pietro Incardona's avatar
Pietro Incardona committed
557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574
	vector_dist<3,float,aggregate<float,float,float,VectorS<3,float>,VectorS<3,float>,VectorS<3,float>>> vd(100,box,bc,ghost);

	vd.getV<A>() = 1.0;
	vd.getV<B>() = 2.0f;
	vd.getV<C>() = 3.0;

	check_values<A>(vd,1.0);
	check_values<B>(vd,2.0);
	check_values<C>(vd,3.0);

	fill_values(vd);

	vd.getV<A>() = vd.getV<B>() + 2.0 + vd.getV<B>() - 2.0*vd.getV<C>() / 5.0;
	check_values_complex_expr(vd);

	// Various combination of 2 operator

	vd.getV<A>() = vd.getV<B>() + 2.0;
Pietro Incardona's avatar
Pietro Incardona committed
575
	check_values_sum<float,vtype,A,B,C>(vd,2.0);
Pietro Incardona's avatar
Pietro Incardona committed
576
	vd.getV<A>() = 2.0 + vd.getV<B>();
Pietro Incardona's avatar
Pietro Incardona committed
577
	check_values_sum<float,vtype,A,B,C>(vd,2.0);
Pietro Incardona's avatar
Pietro Incardona committed
578
	vd.getV<A>() = vd.getV<C>() + vd.getV<B>();
Pietro Incardona's avatar
Pietro Incardona committed
579
	check_values_sum<float,vtype,A,B,C>(vd,vd);
Pietro Incardona's avatar
Pietro Incardona committed
580 581

	vd.getV<A>() = vd.getV<B>() - 2.0;
Pietro Incardona's avatar
Pietro Incardona committed
582
	check_values_sub<float,vtype,A,B,C>(vd,2.0);
Pietro Incardona's avatar
Pietro Incardona committed
583
	vd.getV<A>() = 2.0 - vd.getV<B>();
Pietro Incardona's avatar
Pietro Incardona committed
584
	check_values_sub<float,vtype,A,B,C>(2.0,vd);
Pietro Incardona's avatar
Pietro Incardona committed
585
	vd.getV<A>() = vd.getV<C>() - vd.getV<B>();
Pietro Incardona's avatar
Pietro Incardona committed
586
	check_values_sub<float,vtype,A,B,C>(vd,vd);
Pietro Incardona's avatar
Pietro Incardona committed
587 588

	vd.getV<A>() = vd.getV<B>() * 2.0;
Pietro Incardona's avatar
Pietro Incardona committed
589
	check_values_mul<float,vtype,A,B,C>(vd,2.0);
Pietro Incardona's avatar
Pietro Incardona committed
590
	vd.getV<A>() = 2.0 * vd.getV<B>();
Pietro Incardona's avatar
Pietro Incardona committed
591
	check_values_mul<float,vtype,A,B,C>(vd,2.0);
Pietro Incardona's avatar
Pietro Incardona committed
592
	vd.getV<A>() = vd.getV<C>() * vd.getV<B>();
Pietro Incardona's avatar
Pietro Incardona committed
593
	check_values_mul<float,vtype,A,B,C>(vd,vd);
Pietro Incardona's avatar
Pietro Incardona committed
594 595

	vd.getV<A>() = vd.getV<B>() / 2.0;
Pietro Incardona's avatar
Pietro Incardona committed
596
	check_values_div<float,vtype,A,B,C>(vd,2.0);
Pietro Incardona's avatar
Pietro Incardona committed
597
	vd.getV<A>() = 2.0 / vd.getV<B>();
Pietro Incardona's avatar
Pietro Incardona committed
598
	check_values_div<float,vtype,A,B,C>(2.0,vd);
Pietro Incardona's avatar
Pietro Incardona committed
599
	vd.getV<A>() = vd.getV<C>() / vd.getV<B>();
Pietro Incardona's avatar
Pietro Incardona committed
600
	check_values_div<float,vtype,A,B,C>(vd,vd);
Pietro Incardona's avatar
Pietro Incardona committed
601 602 603 604

	// Variuos combination 3 operator

	vd.getV<A>() = vd.getV<B>() + (vd.getV<C>() + vd.getV<B>());
Pietro Incardona's avatar
Pietro Incardona committed
605
	check_values_sum_3<float,vtype,A,B,C>(vd);
Pietro Incardona's avatar
Pietro Incardona committed
606
	vd.getV<A>() = (vd.getV<C>() + vd.getV<B>()) + vd.getV<B>();
Pietro Incardona's avatar
Pietro Incardona committed
607
	check_values_sum_3<float,vtype,A,B,C>(vd);
Pietro Incardona's avatar
Pietro Incardona committed
608
	vd.getV<A>() = (vd.getV<C>() + vd.getV<B>()) + (vd.getV<C>() + vd.getV<B>());
Pietro Incardona's avatar
Pietro Incardona committed
609
	check_values_sum_4<float,vtype,A,B,C>(vd);
Pietro Incardona's avatar
Pietro Incardona committed
610

Pietro Incardona's avatar
Pietro Incardona committed
611 612
	vd.getV<A>() = vd.getV<B>() - (vd.getV<C>() + vd.getV<B>());
	check_values_sub_31<float,vtype,A,B,C>(vd);
Pietro Incardona's avatar
Pietro Incardona committed
613
	vd.getV<A>() = (vd.getV<C>() + vd.getV<B>()) - vd.getV<B>();
Pietro Incardona's avatar
Pietro Incardona committed
614
	check_values_sub_32<float,vtype,A,B,C>(vd);
Pietro Incardona's avatar
Pietro Incardona committed
615
	vd.getV<A>() = (vd.getV<C>() + vd.getV<B>()) - (vd.getV<C>() + vd.getV<B>());
Pietro Incardona's avatar
Pietro Incardona committed
616
	check_values_sub_4<float,vtype,A,B,C>(vd);
Pietro Incardona's avatar
Pietro Incardona committed
617 618

	vd.getV<A>() = vd.getV<B>() * (vd.getV<C>() + vd.getV<B>());
Pietro Incardona's avatar
Pietro Incardona committed
619
	check_values_mul_3<float,vtype,A,B,C>(vd);
Pietro Incardona's avatar
Pietro Incardona committed
620
	vd.getV<A>() = (vd.getV<C>() + vd.getV<B>()) * vd.getV<B>();
Pietro Incardona's avatar
Pietro Incardona committed
621
	check_values_mul_3<float,vtype,A,B,C>(vd);
Pietro Incardona's avatar
Pietro Incardona committed
622
	vd.getV<A>() = (vd.getV<C>() + vd.getV<B>()) * (vd.getV<C>() + vd.getV<B>());
Pietro Incardona's avatar
Pietro Incardona committed
623
	check_values_mul_4<float,vtype,A,B,C>(vd);
Pietro Incardona's avatar
Pietro Incardona committed
624 625

	vd.getV<A>() = vd.getV<B>() / (vd.getV<C>() + vd.getV<B>());
Pietro Incardona's avatar
Pietro Incardona committed
626
	check_values_div_31<float,vtype,A,B,C>(vd);
Pietro Incardona's avatar
Pietro Incardona committed
627
	vd.getV<A>() = (vd.getV<C>() + vd.getV<B>()) / vd.getV<B>();
Pietro Incardona's avatar
Pietro Incardona committed
628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701
	check_values_div_32<float,vtype,A,B,C>(vd);
	vd.getV<A>() = (vd.getV<C>() + vd.getV<B>()) / (vd.getV<C>() + vd.getV<B>());
	check_values_div_4<float,vtype,A,B,C>(vd);

	// We try with vectors

	// Various combination of 2 operator

	vd.getV<PA>() = vd.getV<PB>() + 2.0;
	check_values_sum<VectorS<3,float>,vtype,PA,PB,PC>(vd,2.0);
	vd.getV<PA>() = 2.0 + vd.getV<PB>();
	check_values_sum<VectorS<3,float>,vtype,PA,PB,PC>(vd,2.0);
	vd.getV<PA>() = vd.getV<PC>() + vd.getV<PB>();
	check_values_sum<VectorS<3,float>,vtype,PA,PB,PC>(vd,vd);

	vd.getV<PA>() = vd.getV<PB>() - 2.0;
	check_values_sub<VectorS<3,float>,vtype,PA,PB,PC>(vd,2.0);
	vd.getV<PA>() = 2.0 - vd.getV<PB>();
	check_values_sub<VectorS<3,float>,vtype,PA,PB,PC>(2.0,vd);
	vd.getV<PA>() = vd.getV<PC>() - vd.getV<PB>();
	check_values_sub<VectorS<3,float>,vtype,PA,PB,PC>(vd,vd);

	vd.getV<PA>() = vd.getV<PB>() * 2.0;
	check_values_mul<VectorS<3,float>,vtype,PA,PB,PC>(vd,2.0);
	vd.getV<PA>() = 2.0 * vd.getV<PB>();
	check_values_mul<VectorS<3,float>,vtype,PA,PB,PC>(vd,2.0);
	vd.getV<PA>() = vd.getV<PC>() * vd.getV<PB>();
	check_values_mul<VectorS<3,float>,vtype,PA,PB,PC>(vd,vd);

	vd.getV<PA>() = vd.getV<PB>() / 2.0;
	check_values_div<VectorS<3,float>,vtype,PA,PB,PC>(vd,2.0);
	vd.getV<PA>() = 2.0 / vd.getV<PB>();
	check_values_div<VectorS<3,float>,vtype,PA,PB,PC>(2.0,vd);
	vd.getV<PA>() = vd.getV<PC>() / vd.getV<PB>();
	check_values_div<VectorS<3,float>,vtype,PA,PB,PC>(vd,vd);

	// Variuos combination 3 operator

	vd.getV<PA>() = vd.getV<PB>() + (vd.getV<PC>() + vd.getV<PB>());
	check_values_sum_3<VectorS<3,float>,vtype,PA,PB,PC>(vd);
	vd.getV<PA>() = (vd.getV<PC>() + vd.getV<PB>()) + vd.getV<PB>();
	check_values_sum_3<VectorS<3,float>,vtype,PA,PB,PC>(vd);
	vd.getV<PA>() = (vd.getV<PC>() + vd.getV<PB>()) + (vd.getV<PC>() + vd.getV<PB>());
	check_values_sum_4<VectorS<3,float>,vtype,PA,PB,PC>(vd);

	vd.getV<PA>() = vd.getV<PB>() - (vd.getV<PC>() + vd.getV<PB>());
	check_values_sub_31<VectorS<3,float>,vtype,PA,PB,PC>(vd);
	vd.getV<PA>() = (vd.getV<PC>() + vd.getV<PB>()) - vd.getV<PB>();
	check_values_sub_32<VectorS<3,float>,vtype,PA,PB,PC>(vd);
	vd.getV<PA>() = (vd.getV<PC>() + vd.getV<PB>()) - (vd.getV<PC>() + vd.getV<PB>());
	check_values_sub_4<VectorS<3,float>,vtype,PA,PB,PC>(vd);

	vd.getV<PA>() = vd.getV<PB>() * (vd.getV<PC>() + vd.getV<PB>());
	check_values_mul_3<VectorS<3,float>,vtype,PA,PB,PC>(vd);
	vd.getV<PA>() = (vd.getV<PC>() + vd.getV<PB>()) * vd.getV<PB>();
	check_values_mul_3<VectorS<3,float>,vtype,PA,PB,PC>(vd);
	vd.getV<PA>() = (vd.getV<PC>() + vd.getV<PB>()) * (vd.getV<PC>() + vd.getV<PB>());
	check_values_mul_4<VectorS<3,float>,vtype,PA,PB,PC>(vd);
	vd.getV<A>() = vd.getV<PB>() * (vd.getV<PC>() + vd.getV<PB>());
	check_values_mul_3<float,vtype,A,PB,PC>(vd);
	vd.getV<A>() = (vd.getV<PC>() + vd.getV<PB>()) * vd.getV<PB>();
	check_values_mul_3<float,vtype,A,PB,PC>(vd);
	vd.getV<A>() = (vd.getV<PC>() + vd.getV<PB>()) * (vd.getV<PC>() + vd.getV<PB>());
	check_values_mul_4<float,vtype,A,PB,PC>(vd);

	vd.getV<PA>() = vd.getV<PB>() / (vd.getV<PC>() + vd.getV<PB>());
	check_values_div_31<VectorS<3,float>,vtype,PA,PB,PC>(vd);
	vd.getV<PA>() = (vd.getV<PC>() + vd.getV<PB>()) / vd.getV<PB>();
	check_values_div_32<VectorS<3,float>,vtype,PA,PB,PC>(vd);
	vd.getV<PA>() = (vd.getV<PC>() + vd.getV<PB>()) / (vd.getV<PC>() + vd.getV<PB>());
	check_values_div_4<VectorS<3,float>,vtype,PA,PB,PC>(vd);

	// normalization function

Pietro Incardona's avatar
Pietro Incardona committed
702 703 704 705 706 707 708 709

}

BOOST_AUTO_TEST_SUITE_END()



#endif /* SRC_VECTOR_VECTOR_DIST_OPERATORS_UNIT_TESTS_HPP_ */