Nov 28, 2010

Infer.Net 原理和 C#

1. using 语句
括弧内的 object 会被 dispose
仅此而已


Variable<bool> b = Variable.Bernoulli(0.5);
using (Variable.If(b))
{
Variable.ConstrainPositive(x);
} /// the block is now closed

相当于
Variable<bool> b = Variable.Bernoulli(0.5);
IfBlock ifb = Variable.If(b);
Variable.ConstrainPositive(x);
ifb.CloseBlock();
上面的 IfBlock 怎么起到作用,目前还不理解

2. indexer
x[range] = Variable.Gaussian...().ForEach(range) ;

LHS: indexer,返回值是 Variable<T>
RHS: ForEach 函数生成 Variable<T>

0 comments: