Changed graph_labeler requirements to allow for zero sized sparse vectors.

This commit is contained in:
Davis King 2012-05-05 13:59:37 -04:00
parent 4d46517ed0
commit bda0943d8c
2 changed files with 4 additions and 8 deletions

View File

@ -39,7 +39,7 @@ namespace dlib
node_weights(node_weights_) node_weights(node_weights_)
{ {
// make sure requires clause is not broken // make sure requires clause is not broken
DLIB_ASSERT(min(edge_weights) >= 0, DLIB_ASSERT(edge_weights.size() == 0 || min(edge_weights) >= 0,
"\t graph_labeler::graph_labeler()" "\t graph_labeler::graph_labeler()"
<< "\n\t Invalid inputs were given to this function." << "\n\t Invalid inputs were given to this function."
<< "\n\t min(edge_weights): " << min(edge_weights) << "\n\t min(edge_weights): " << min(edge_weights)
@ -61,9 +61,7 @@ namespace dlib
{ {
// make sure requires clause is not broken // make sure requires clause is not broken
#ifdef ENABLE_ASSERTS #ifdef ENABLE_ASSERTS
DLIB_ASSERT(get_edge_weights().size() != 0 && DLIB_ASSERT(graph_contains_length_one_cycle(sample) == false,
get_node_weights().size() != 0 &&
graph_contains_length_one_cycle(sample) == false,
"\t void graph_labeler::operator()" "\t void graph_labeler::operator()"
<< "\n\t Invalid inputs were given to this function." << "\n\t Invalid inputs were given to this function."
<< "\n\t get_edge_weights().size(): " << get_edge_weights().size() << "\n\t get_edge_weights().size(): " << get_edge_weights().size()
@ -103,9 +101,9 @@ namespace dlib
); );
} }
DLIB_ASSERT(min(sample.node(i).edge(n)) >= 0, DLIB_ASSERT(sample.node(i).edge(n).size() == 0 || min(sample.node(i).edge(n)) >= 0,
"\t void graph_labeler::operator()" "\t void graph_labeler::operator()"
<< "\n\t Invalid inputs were given to this function." << "\n\t No edge vectors are allowed to have negative elements."
<< "\n\t min(sample.node(i).edge(n)): " << min(sample.node(i).edge(n)) << "\n\t min(sample.node(i).edge(n)): " << min(sample.node(i).edge(n))
<< "\n\t i: " << i << "\n\t i: " << i
<< "\n\t n: " << n << "\n\t n: " << n

View File

@ -102,8 +102,6 @@ namespace dlib
capable of representing column vectors or some kind of sparse vector capable of representing column vectors or some kind of sparse vector
type as defined in dlib/svm/sparse_vector_abstract.h. type as defined in dlib/svm/sparse_vector_abstract.h.
- graph_contains_length_one_cycle(sample) == false - graph_contains_length_one_cycle(sample) == false
- #get_edge_weights().size() != 0
- #get_node_weights().size() != 0
- for all valid i and j: - for all valid i and j:
- min(edge(sample,i,j)) >= 0 - min(edge(sample,i,j)) >= 0
- it must be legal to call dot(edge(sample,i,j), get_edge_weights()) - it must be legal to call dot(edge(sample,i,j), get_edge_weights())