add more asserts

This commit is contained in:
Tiago Gomes 2012-04-30 17:49:07 +01:00
parent ad50166bd0
commit 92d8c7dcbe

View File

@ -10,7 +10,6 @@
#include "Indexer.h" #include "Indexer.h"
Factor::Factor (const Factor& g) Factor::Factor (const Factor& g)
{ {
copyFromFactor (g); copyFromFactor (g);
@ -97,6 +96,7 @@ Factor::sumOutAllExcept (const VarIds& vids)
void void
Factor::sumOutIndex (unsigned idx) Factor::sumOutIndex (unsigned idx)
{ {
assert (idx < args_.size());
// number of parameters separating a different state of `var', // number of parameters separating a different state of `var',
// with the states of the remaining variables fixed // with the states of the remaining variables fixed
unsigned varOffset = 1; unsigned varOffset = 1;
@ -151,6 +151,7 @@ Factor::sumOutIndex (unsigned idx)
void void
Factor::sumOutAllExceptIndex (unsigned idx) Factor::sumOutAllExceptIndex (unsigned idx)
{ {
assert (idx < args_.size());
while (args_.size() > idx + 1) { while (args_.size() > idx + 1) {
sumOutLastVariable(); sumOutLastVariable();
} }
@ -164,6 +165,7 @@ Factor::sumOutAllExceptIndex (unsigned idx)
void void
Factor::sumOutFirstVariable (void) Factor::sumOutFirstVariable (void)
{ {
assert (args_.size() > 1);
unsigned range = ranges_.front(); unsigned range = ranges_.front();
unsigned sep = params_.size() / range; unsigned sep = params_.size() / range;
if (Globals::logDomain) { if (Globals::logDomain) {
@ -185,6 +187,7 @@ Factor::sumOutFirstVariable (void)
void void
Factor::sumOutLastVariable (void) Factor::sumOutLastVariable (void)
{ {
assert (args_.size() > 1);
unsigned range = ranges_.back(); unsigned range = ranges_.back();
unsigned idx1 = 0; unsigned idx1 = 0;
unsigned idx2 = 0; unsigned idx2 = 0;