本文整理汇总了C++中Param类的典型用法代码示例。如果您正苦于以下问题:C++ Param类的具体用法?C++ Param怎么用?C++ Param使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Param类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnCmdMenuColorChange
ibool Preferences::OnCmdMenuColorChange(Param& param)
{
if (param.Button().Clicked())
{
static COLORREF customColors[16] = {0};
Object::Pod<CHOOSECOLOR> cc;
MenuColorWindow& type = menuColorWindows[param.Button().GetId() == IDC_PREFERENCES_MENUCOLOR_FULLSCREEN_CHANGE];
cc.lStructSize = sizeof(cc);
cc.hwndOwner = dialog;
cc.lpCustColors = customColors;
cc.rgbResult = type.color;
cc.Flags = CC_FULLOPEN|CC_RGBINIT;
if (::ChooseColor( &cc ))
{
type.color = cc.rgbResult;
UpdateColors();
}
}
return true;
}
示例2: main
int main(int argc, char **argv) {
ImageParam im1(UInt(8), 1);
Buffer<uint8_t> im2(10), im3(20);
Param<int> j;
assert(im1.dimensions() == 1);
assert(im2.dimensions() == 1);
assert(im3.dimensions() == 1);
Func f;
Var x;
f(x) = x + im1.width();
RDom r(0, clamp(im2(j), 0, 99));
f(r) = 37;
im2(3) = 10;
j.set(3);
im1.set(im3);
Buffer<int> result = f.realize(100);
for (int i = 0; i < 100; i++) {
int correct = i < im2(3) ? 37 : (i+20);
if (result(i) != correct) {
printf("result(%d) = %d instead of %d\n", i, result(i), correct);
return -1;
}
}
printf("Success!\n");
return 0;
}
示例3: apply
void Initializer::apply(Param& param) {
param.init();
for (Piece p = Piece::PAWN; p <= Piece::DRAGON; p.toNext()) {
param.setPiece(p, pieceValues[p]);
}
param.cumulate();
}
示例4: check
void check(MemoryType t1, MemoryType t2, MemoryType t3) {
Var x;
// By default, small constant-sized allocations, or
// allocations that can be bounded with a small constant size,
// go on the stack. Other allocations go on the heap.
Func f1, f2, f3;
f1(x) = x;
f1.compute_root().store_in(t1);
f2(x) = x;
f2.compute_root().store_in(t2);
f3(x) = x;
f3.compute_root().store_in(t3);
Func f;
Param<bool> p;
f(x) = (f1(0) + f1(1)) + f2(select(p, 0, 2)) + f2(0) + f3(x % 1000);
p.set(true);
int expected_mallocs = ((t1 == MemoryType::Heap ? 1 : 0) +
(t2 == MemoryType::Heap ? 1 : 0) +
(t3 == MemoryType::Heap ? 1 : 0));
mallocs = 0;
f.set_custom_allocator(my_malloc, my_free);
f.realize(1024);
if (mallocs != expected_mallocs) {
std::cerr << "Wrong number of mallocs for " << t1 << ", " << t2 << ", " << t3 << "\n"
<< "Expected " << expected_mallocs << " got " << mallocs << "\n";
exit(-1);
}
}
示例5: main
int main(int argc, char **argv) {
Var x, y, z;
Func f;
Param<int> k;
k.set(3);
f(x, y, z) = x*y+z*k+1;
f.parallel(x);
f.parallel(y);
f.parallel(z);
Image<int> im = f.realize(64, 64, 64);
for (int x = 0; x < 64; x++) {
for (int y = 0; y < 64; y++) {
for (int z = 0; z < 64; z++) {
if (im(x, y, z) != x*y+z*3+1) {
printf("im(%d, %d, %d) = %d\n", x, y, z, im(x, y, z));
return -1;
}
}
}
}
printf("Success!\n");
return 0;
}
示例6: main
int main()
{
Param * p = NULL;
bool result = false;
// show structure size
std::cout << "size of Param: " << sizeof(Param) << std::endl;
// param1
result = Param::getDict().get("param1", p);
assert(result);
assert(p->getType() == Param::FLOAT);
assert(fabs(p->getFloat() - 1.0f) < 1e-20);
assert(p->getInt() == 1);
// param2
result = Param::getDict().get("param2", p);
assert(result);
assert(p->getType() == Param::INT);
assert(fabs(p->getFloat() - 2.0f) < 1e-20);
assert(p->getInt() == 2);
// param3
result = Param::getDict().get("param3", p);
assert(result);
assert(p->getType() == Param::FLOAT);
assert(fabs(p->getFloat() - 1.3f) < 1e-20);
assert(p->getInt() == 1);
};
示例7: checkReferenceIds_
void InternalCalibration::calibrateMapGlobally(const FeatureMap<> & feature_map, FeatureMap<> & calibrated_feature_map, std::vector<PeptideIdentification> & ref_ids, String trafo_file_name)
{
checkReferenceIds_(ref_ids);
calibrated_feature_map = feature_map;
// clear the ids
for (Size f = 0; f < calibrated_feature_map.size(); ++f)
{
calibrated_feature_map[f].getPeptideIdentifications().clear();
}
// map the reference ids onto the features
IDMapper mapper;
Param param;
param.setValue("rt_tolerance", (DoubleReal)param_.getValue("rt_tolerance"));
param.setValue("mz_tolerance", param_.getValue("mz_tolerance"));
param.setValue("mz_measure", param_.getValue("mz_tolerance_unit"));
mapper.setParameters(param);
std::vector<ProteinIdentification> vec;
mapper.annotate(calibrated_feature_map, ref_ids, vec);
// calibrate
calibrateMapGlobally(calibrated_feature_map, calibrated_feature_map, trafo_file_name);
// copy the old ids
calibrated_feature_map.setUnassignedPeptideIdentifications(feature_map.getUnassignedPeptideIdentifications());
for (Size f = 0; f < feature_map.size(); ++f)
{
calibrated_feature_map[f].getPeptideIdentifications().clear();
if (!feature_map[f].getPeptideIdentifications().empty())
{
calibrated_feature_map[f].setPeptideIdentifications(feature_map[f].getPeptideIdentifications());
}
}
}
示例8: diff2
void diff2(Param<T> out, CParam<T> in, int const dim)
{
af::dim4 dims = out.dims();
// Bool for dimension
bool is_dim0 = dim == 0;
bool is_dim1 = dim == 1;
bool is_dim2 = dim == 2;
bool is_dim3 = dim == 3;
T const * const inPtr = in.get();
T * outPtr = out.get();
// TODO: Improve this
for(dim_t l = 0; l < dims[3]; l++) {
for(dim_t k = 0; k < dims[2]; k++) {
for(dim_t j = 0; j < dims[1]; j++) {
for(dim_t i = 0; i < dims[0]; i++) {
// Operation: out[index] = in[index + 1 * dim_size] - in[index]
int idx = getIdx(in.strides(), i, j, k, l);
int jdx = getIdx(in.strides(),
i + is_dim0, j + is_dim1,
k + is_dim2, l + is_dim3);
int kdx = getIdx(in.strides(),
i + 2 * is_dim0, j + 2 * is_dim1,
k + 2 * is_dim2, l + 2 * is_dim3);
int odx = getIdx(out.strides(), i, j, k, l);
outPtr[odx] = inPtr[kdx] + inPtr[idx] - inPtr[jdx] - inPtr[jdx];
}
}
}
}
}
示例9: non_trivial_allocate_predicate_test
int non_trivial_allocate_predicate_test(bool toggle_val, int index) {
buffer_index = index;
Param<bool> toggle;
Func f1("f1_" + std::to_string(index)), f2("f2_" + std::to_string(index));
Func f3("f3_" + std::to_string(index));
Var x;
// Generate allocate f1[...] if toggle
f1(x) = 2*x;
f2(x) = select(toggle, f1(x), 1);
f3(x) = select(toggle, f2(x), 1);
f1.compute_root().memoize();
f2.compute_root().memoize();
f3.set_custom_trace(&double_toggle_trace);
f1.trace_stores();
f2.trace_stores();
f3.compile_jit();
set_toggle1 = toggle_val;
set_toggle2 = toggle_val;
toggle.set(set_toggle1);
Image<int> out = f3.realize(10);
if (check_correctness_single(out, set_toggle1) != 0) {
return -1;
}
return 0;
}
示例10: getSubsectionDefaults_
Param getSubsectionDefaults_(const String& /*section*/) const
{
// there is only one subsection: 'algorithm' (s.a) .. and in it belongs the PeakPicker param
Param tmp;
tmp.insert("PeakPicker:", PeakPickerCWT().getDefaults());
return tmp;
}
示例11:
////////////////////////////////////////////////////////////////////////////////
// MatlabEngine::StringMatrix definitions //
////////////////////////////////////////////////////////////////////////////////
MatlabEngine::StringMatrix::StringMatrix( const Param& p )
: vector<vector<string> >( p.NumRows(), vector<string>( p.NumColumns() ) )
{
for( size_t row = 0; row < size(); ++row )
for( size_t column = 0; column < ( *this )[ row ].size(); ++column )
( *this )[ row ][ column ] = p.Value( row, column );
}
示例12: getBYSeries
// for SWATH -- get the theoretical b and y series masses for a sequence
void getBYSeries(AASequence& a, //
std::vector<double>& bseries, //
std::vector<double>& yseries, //
UInt charge //
)
{
OPENMS_PRECONDITION(charge > 0, "Charge is a positive integer");
TheoreticalSpectrumGenerator generator;
Param p;
p.setValue("add_metainfo", "true",
"Adds the type of peaks as metainfo to the peaks, like y8+, [M-H2O+2H]++");
generator.setParameters(p);
RichPeakSpectrum rich_spec;
generator.addPeaks(rich_spec, a, Residue::BIon, charge);
generator.addPeaks(rich_spec, a, Residue::YIon, charge);
for (RichPeakSpectrum::iterator it = rich_spec.begin();
it != rich_spec.end(); ++it)
{
if (it->getMetaValue("IonName").toString()[0] == 'y')
{
yseries.push_back(it->getMZ());
}
else if (it->getMetaValue("IonName").toString()[0] == 'b')
{
bseries.push_back(it->getMZ());
}
}
} // end getBYSeries
示例13: main
int main(int argc, const char** argv)
{
if (argc < 2) return 1;
// the path to the data should be given on the command line
String tutorial_data_path(argv[1]);
PeakMap exp_raw;
PeakMap exp_picked;
MzMLFile mzml_file;
mzml_file.load(tutorial_data_path + "/data/Tutorial_PeakPickerCWT.mzML", exp_raw);
PeakPickerCWT pp;
Param param;
param.setValue("peak_width", 0.1);
pp.setParameters(param);
pp.pickExperiment(exp_raw, exp_picked);
exp_picked.updateRanges();
cout << "\nMinimal fwhm of a mass spectrometric peak: " << (DoubleReal)param.getValue("peak_width")
<< "\n\nNumber of picked peaks " << exp_picked.getSize() << std::endl;
return 0;
} //end of main
示例14: single_memoize_test
int single_memoize_test(bool toggle_val, int index) {
buffer_index = index;
Param<bool> toggle;
Func f1("f1_" + std::to_string(index)), f2("f2_" + std::to_string(index));
Var x;
f1(x) = 2*x;
f2(x) = select(toggle, f1(x), 1);
f1.compute_root().memoize();
f2.set_custom_trace(&single_toggle_trace);
f1.trace_stores();
f2.compile_jit();
set_toggle1 = toggle_val;
toggle.set(set_toggle1);
Image<int> out = f2.realize(10);
if (check_correctness_single(out, set_toggle1) != 0) {
return -1;
}
return 0;
}
示例15: tuple_memoize_test
int tuple_memoize_test(bool toggle_val, int index) {
buffer_index = index;
Param<bool> toggle;
Func f1("f1_" + std::to_string(index)), f2("f2_" + std::to_string(index));
Var x;
f1(x) = Tuple(2*x, 2*x);
f2(x) = Tuple(select(toggle, f1(x)[0], 1),
select(toggle, f1(x)[1], 1));
f1.compute_root().memoize();
f2.set_custom_trace(&single_toggle_trace);
f1.trace_stores();
f2.compile_jit();
set_toggle1 = toggle_val;
toggle.set(set_toggle1);
Realization out = f2.realize(128);
Image<int> out0 = out[0];
Image<int> out1 = out[1];
if (check_correctness_single(out0, set_toggle1) != 0) {
return -1;
}
if (check_correctness_single(out1, set_toggle1) != 0) {
return -1;
}
return 0;
}