本文整理汇总了C++中Row::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Row::Clear方法的具体用法?C++ Row::Clear怎么用?C++ Row::Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Row
的用法示例。
在下文中一共展示了Row::Clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ComputeOneDocLLH
double Eval::ComputeOneDocLLH(Document* doc, Row<int32_t>& doc_topic_counter)
{
if (doc->Size() == 0) return 0.0;
double one_doc_llh = LogGamma(Config::num_topics * Config::alpha)
- Config::num_topics * LogGamma(Config::alpha);
int32_t nonzero_num = 0;
doc_topic_counter.Clear();
doc->GetDocTopicVector(doc_topic_counter);
Row<int32_t>::iterator iter = doc_topic_counter.Iterator();
while (iter.HasNext())
{
one_doc_llh += LogGamma(iter.Value() + Config::alpha);
++nonzero_num;
iter.Next();
}
one_doc_llh += (Config::num_topics - nonzero_num)
* LogGamma(Config::alpha);
one_doc_llh -= LogGamma(doc->Size() +
Config::alpha * Config::num_topics);
return one_doc_llh;
}
示例2: test_std
int test_std()
{
Table *tab1, *tab2;
ColumnInfo colinfo;
Row row;
// create table1
colinfo.Clear();
colinfo.AddColumn("col1",1,1);
colinfo.AddColumn("col2",2,2);
colinfo.AddColumn("col3",4,5);
tab1 = Table::CreateTable("table1", &colinfo);
colinfo.Clear();
row.AddVal("col1", "1");
row.AddVal("col2", "12");
row.AddVal("col3", "432");
tab1->AddRow( &row );
row.Clear();
row.AddVal("col1", "2");
row.AddVal("col2", "23");
row.AddVal("col3", "234");
tab1->AddRow( &row );
// create table2
colinfo.AddColumn("col2-1",1,2);
colinfo.AddColumn("col2-2",4,5);
tab2 = Table::CreateTable("table2", &colinfo);
colinfo.Clear();
row.Clear();
row.AddVal("col2-1", "1");
row.AddVal("col2-2", "45");
tab2->AddRow( &row );
row.Clear();
row.AddVal("col2-1", "2");
row.AddVal("col2-2", "56");
tab2->AddRow( &row );
Table::Dump();
// get row
assert( !strcmp(tab1->GetRow( "1", "col1" ), "1" ) );
assert( !strcmp(tab1->GetRow( "1", "col2" ), "12" ) );
assert( !strcmp(tab1->GetRow( "1", "col3" ), "432" ) );
assert( !strcmp(tab1->GetRow( "2", "col2" ), "23" ) );
assert( !strcmp(tab1->GetRow( "2", "col3" ), "234" ) );
assert( !strcmp(tab2->GetRow( "1", "col2-2" ), "45" ) );
assert( !strcmp(tab2->GetRow( "2", "col2-2" ), "56" ) );
// update row
tab1->UpdateRow( "1", "col3", "456" );
assert( !strcmp(tab1->GetRow( "1", "col3" ), "456" ) );
// del row
tab1->DelRow( "2" );
Table::Dump();
Table::DeleteTable("table1");
Table::DeleteTable("table2");
return 0;
}