本文整理汇总了C++中Spectrum::dim方法的典型用法代码示例。如果您正苦于以下问题:C++ Spectrum::dim方法的具体用法?C++ Spectrum::dim怎么用?C++ Spectrum::dim使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Spectrum
的用法示例。
在下文中一共展示了Spectrum::dim方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: move
std::unique_ptr<TH1D> spectrum_to_roothist(const Spectrum & s, const std::string & hname, bool set_errors){
const int n = s.dim();
unique_ptr<TH1D> values(new TH1D(hname.c_str(), hname.c_str(), n, 0, n));
for(int i=0; i<n; ++i){
values->SetBinContent(i+1, s[i]);
if(set_errors){
double err = sqrt(s.cov()(i,i));
values->SetBinError(i+1, err);
}
}
return move(values);
}
示例2: result
Spectrum operator*(const Matrix & R, const Spectrum & t){
const size_t ngen = R.get_n_cols();
const size_t nrec = R.get_n_rows();
Spectrum result(nrec);
if(t.dim() != ngen){
throw runtime_error("response * gen: wrong dimensions");
}
for(size_t i=0; i<nrec; ++i){
for(size_t j=0; j<ngen; ++j){
result[i] += R(i,j) * t[j];
}
}
return result;
}
示例3: update
void MeanCov::update(const Spectrum & d, size_t weight){
assert(d.dim() == npar);
double factor = count * 1.0 / (count + 1);
for(size_t i=1; i<weight; ++i){
factor += (count*count*1.0) / ((count+i) * (count+i+1));
}
for(size_t i=0; i<npar; ++i){
if(!isfinite(d[i])){
throw runtime_error("MeanCov::update: Spectrum has non-finite entries");
}
double diff_i = d[i] - means_[i];
for(size_t j=i; j<npar; ++j){
double diff_j = d[j] - means_[j];
count_covariance(i,j) += factor * diff_i * diff_j;
}
//the old means[i] is now no longer needed, as j>=i ...
means_[i] += weight * 1.0 / (count + weight) * diff_i;
}
count += weight;
}