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;
		}
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;
}
	void Initializer::apply(Param& param) {
		param.init();
		for (Piece p = Piece::PAWN; p <= Piece::DRAGON; p.toNext()) {
			param.setPiece(p, pieceValues[p]);
		}
		param.cumulate();
	}
Exemple #4
0
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);
    }

}
Exemple #5
0
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;
}
Exemple #6
0
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);
};
  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());
      }
    }
  }
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];
                }
            }
        }
    }
}
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;
}
Exemple #10
0
 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;
 }
////////////////////////////////////////////////////////////////////////////////
// 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 );
}
Exemple #12
0
// 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
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
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;
}
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;
}
Exemple #16
0
int main(int argc, char **argv) {

    Var x("x");
    Func f("f");

    Param<float> u;

    f(x) = u;

    std::string target = get_target();
    if (target == "ptx" || target == "ptx-debug") {
        f.cuda_tile(x, 256);
    }

    u.set(17.0f);
    Image<float> out_17 = f.realize(1024);

    u.set(123.0f);
    Image<float> out_123 = f.realize(1024);

    for (int i = 0; i < 1024; i++) {
        if (out_17(i) != 17.0f || out_123(i) != 123.0f) {
            printf("Failed!\n");
            for (int i = 0; i < 1024; i++) {
                printf("%f %f\n", out_17(i), out_123(i));
            }
            return -1;
        }
    }

    printf("Success!\n");
    return 0;
}
Param*
_TParamDef::param_get_ptr_suffix( ParamList* inList, const char* inName, long inSuffix )
{                                                                               
  Param* result = NULL;
  string _name = inName,
         _blankName = _name;
  unsigned int _replacePos = _name.find( RUNTIME_SUFFIX );
  assert( _replacePos != string::npos );
  _blankName.erase( _replacePos, sizeof( RUNTIME_SUFFIX ) - 1 );
  ostringstream _suffix;
  _suffix << inSuffix;
  _name.replace( _replacePos, sizeof( RUNTIME_SUFFIX ) - 1, _suffix.str() );
  if( inList->Exists( _name ) )
    result = &( *inList )[ _name ];
  else
  {
    static Param p;
    if( inList->Exists( _blankName ) )
    {
      Param& param = ( *inList )[ _blankName ];
      p.SetType( "list" );
      p.SetNumValues( param.NumValues() );
      for( int i = 0; i < param.NumColumns(); ++i )
        p.Value( i ) = param.Value( inSuffix, i );
      result = &p;
    }
  }
  return result;
}
Exemple #18
0
void Session::_BindParameter(sqlite3_stmt *statement, const Param &param, int position)
{
	Param::ParamType type = param.GetType();
	int result;
	switch(type)
	{
	case Param::TYPE_STRING:
#ifdef UNICODE
		result = sqlite3_bind_text16(statement, position, param.GetValue(),-1,NULL);
#else 
		sqlite3_bind_text(statement, position, (TCHAR)param.GetValue()),-1,NULL);
#endif
		break;
	case Param::TYPE_INT:
		result = sqlite3_bind_int(statement, position, *((int*)param.GetValue()));
		break;
	default:
		result = sqlite3_bind_double(statement, position, *((double*)param.GetValue()));
		break;
	}

	if(result != SQLITE_OK)
	{
		throw SessionException(_T("Could not bind parameter"));
	}

}
Exemple #19
0
  void testOutput() {
    Tokens::Unless* token = new Tokens::Unless(0);

    token->add(new Tokens::Text("hi world"));

    Param* param = new Param(0);
    param->add(true, operatorNone, operatorNone);
    token->addArg(0, param);

    CPPUNIT_ASSERT(token->output() == "");

    param = new Param(0);
    param->add(false, operatorNone, operatorNone);
    token->setArg(0, param);

    CPPUNIT_ASSERT(token->output() == "hi world");

    iBlock* block = new iBlock((iBlock*) 0);
    block->add(new Tokens::Text("hi hell"));

    token->setAltToken(block);
    CPPUNIT_ASSERT(token->output() == "hi world");

    param = new Param(0);
    param->add(true, operatorNone, operatorNone);
    token->setArg(0, param);

    CPPUNIT_ASSERT(token->output() == "hi hell");

    delete token;
  }
Exemple #20
0
bool ParamManager::load_from_file(std::string filename)
{
  try
  {
    YAML::Node root = YAML::LoadFile(filename);
    assert(root.IsSequence());

    for (int i = 0; i < root.size(); i++)
    {
      if (root[i].IsMap() && root[i]["name"] && root[i]["type"] && root[i]["value"])
      {
        if (is_param_id(root[i]["name"].as<std::string>()))
        {
          Param param = params_.find(root[i]["name"].as<std::string>())->second;
          if ((MAV_PARAM_TYPE) root[i]["type"].as<int>() == param.getType())
          {
            set_param_value(root[i]["name"].as<std::string>(), root[i]["value"].as<double>());
          }
        }
      }
    }

    return true;
  }
  catch (...)
  {
    return false;
  }
}
Exemple #21
0
int main(int argc, char **argv) {

    Var x("x");
    Func f("f");

    Param<float> u;

    f(x) = u;

    Target target = get_target_from_environment();
    if (target.features & Target::CUDA) {
        f.cuda_tile(x, 256);
    }

    u.set(17.0f);
    Image<float> out_17 = f.realize(1024);

    u.set(123.0f);
    Image<float> out_123 = f.realize(1024);

    for (int i = 0; i < 1024; i++) {
        if (out_17(i) != 17.0f || out_123(i) != 123.0f) {
            printf("Failed!\n");
            for (int i = 0; i < 1024; i++) {
                printf("%f %f\n", out_17(i), out_123(i));
            }
            return -1;
        }
    }

    printf("Success!\n");
    return 0;
}
Exemple #22
0
Point3d<T> Cone<T>::getPoint(const Param<T> u, const Param<T> v) const
{
	const auto pos = getPosition(u, v);
	const auto norm = getNormal(u, v);
	const Vector2d<T> param(u.get(), v.get());
	return Point3d<T>(pos, norm, param);
}
Exemple #23
0
void transpose_inplace(Param<T> input) {
    const dim4 idims    = input.dims();
    const dim4 istrides = input.strides();

    T *in = input.get();

    for (dim_t l = 0; l < idims[3]; ++l) {
        for (dim_t k = 0; k < idims[2]; ++k) {
            // Outermost loop handles batch mode
            // if input has no data along third dimension
            // this loop runs only once
            //
            // Run only bottom triangle. std::swap swaps with upper triangle
            for (dim_t j = 0; j < idims[1]; ++j) {
                for (dim_t i = j + 1; i < idims[0]; ++i) {
                    // calculate array indices based on offsets and strides
                    // the helper getIdx takes care of indices
                    const dim_t iIdx = getIdx(istrides, j, i, k, l);
                    const dim_t oIdx = getIdx(istrides, i, j, k, l);
                    if (conjugate) {
                        in[iIdx] = getConjugate(in[iIdx]);
                        in[oIdx] = getConjugate(in[oIdx]);
                        std::swap(in[iIdx], in[oIdx]);
                    } else {
                        std::swap(in[iIdx], in[oIdx]);
                    }
                }
            }
        }
    }
}
  Param getSubsectionDefaults_(const String& /*section*/) const override
  {
    Param combined;
    Param p_com;
    p_com.setValue("noise_threshold_int", 10.0, "Intensity threshold below which peaks are regarded as noise.");
    p_com.setValue("chrom_peak_snr", 3.0, "Minimum signal-to-noise a mass trace should have.");
    p_com.setValue("chrom_fwhm", 5.0, "Expected chromatographic peak width (in seconds).");

    combined.insert("common:", p_com);

    Param p_mtd = MassTraceDetection().getDefaults();
    p_mtd.remove("noise_threshold_int");
    p_mtd.remove("chrom_peak_snr");

    combined.insert("mtd:", p_mtd);

    Param p_epd = ElutionPeakDetection().getDefaults();
    p_epd.remove("noise_threshold_int");
    p_epd.remove("chrom_peak_snr");
    p_epd.remove("chrom_fwhm");

    p_epd.setValue("enabled", "true", "Enables/disables the chromatographic peak detection of mass traces");
    p_epd.setValidStrings("enabled", ListUtils::create<String>("true,false"));
    combined.insert("epd:", p_epd);

    return combined;
  }
Exemple #25
0
void transpose(Param<T> output, CParam<T> input) {
    const dim4 odims    = output.dims();
    const dim4 ostrides = output.strides();
    const dim4 istrides = input.strides();

    T *out            = output.get();
    T const *const in = input.get();

    for (dim_t l = 0; l < odims[3]; ++l) {
        for (dim_t k = 0; k < odims[2]; ++k) {
            // Outermost loop handles batch mode
            // if input has no data along third dimension
            // this loop runs only once
            for (dim_t j = 0; j < odims[1]; ++j) {
                for (dim_t i = 0; i < odims[0]; ++i) {
                    // calculate array indices based on offsets and strides
                    // the helper getIdx takes care of indices
                    const dim_t inIdx  = getIdx(istrides, j, i, k, l);
                    const dim_t outIdx = getIdx(ostrides, i, j, k, l);
                    if (conjugate)
                        out[outIdx] = getConjugate(in[inIdx]);
                    else
                        out[outIdx] = in[inIdx];
                }
            }
            // outData and inData pointers doesn't need to be
            // offset as the getIdx function is taking care
            // of the batch parameter
        }
    }
}
Exemple #26
0
int  AmContentType::parseParams(const char* c, const char* end)
{
  list<sip_avp*> avp_params;
  if(parse_gen_params_sc(&avp_params, &c, end-c, '\0') < 0) {
    if(!avp_params.empty()) free_gen_params(&avp_params);
    return -1;
  }
  
  for(list<sip_avp*>::iterator it_ct_param = avp_params.begin();
      it_ct_param != avp_params.end();++it_ct_param) {

    DBG("parsed new content-type parameter: <%.*s>=<%.*s>",
	(*it_ct_param)->name.len,(*it_ct_param)->name.s,
	(*it_ct_param)->value.len,(*it_ct_param)->value.s);

    Param* p = new Param(c2stlstr((*it_ct_param)->name),
			 c2stlstr((*it_ct_param)->value));

    if(p->parseType()) {
      free_gen_params(&avp_params);
      delete p;
      return -1;
    }
    
    if(p->type == Param::BOUNDARY)
      mp_boundary = p;

    params.push_back(p);
  }

  free_gen_params(&avp_params);
  return 0;
}
Exemple #27
0
int simple_rfactor_with_specialize_test(bool compile_module) {
    Func f("f"), g("g");
    Var x("x"), y("y");

    f(x, y) = x + y;
    f.compute_root();

    g(x, y) = 40;
    RDom r(10, 20, 30, 40);
    g(r.x, r.y) = min(f(r.x, r.y) + 2, g(r.x, r.y));

    Param<int> p;
    Var u("u");
    Func intm = g.update(0).specialize(p >= 10).rfactor(r.y, u);
    intm.compute_root();
    intm.vectorize(u, 8);
    intm.update(0).vectorize(r.x, 2);

    if (compile_module) {
        p.set(20);
        // Check the call graphs.
        Module m = g.compile_to_module({g.infer_arguments()});
        CheckCalls checker;
        m.functions().front().body.accept(&checker);

        CallGraphs expected = {
            {g.name(), {}},
            {g.update(0).name(), {f.name(), intm.name(), g.name()}},
            {intm.name(), {}},
            {intm.update(0).name(), {f.name(), intm.name()}},
            {f.name(), {}},
        };
        if (check_call_graphs(checker.calls, expected) != 0) {
            return -1;
        }
    } else {
        {
            p.set(0);
            Image<int> im = g.realize(80, 80);
            auto func = [](int x, int y, int z) {
                return (10 <= x && x <= 29) && (30 <= y && y <= 69) ? std::min(x + y + 2, 40) : 40;
            };
            if (check_image(im, func)) {
                return -1;
            }
        }
        {
            p.set(20);
            Image<int> im = g.realize(80, 80);
            auto func = [](int x, int y, int z) {
                return (10 <= x && x <= 29) && (30 <= y && y <= 69) ? std::min(x + y + 2, 40) : 40;
            };
            if (check_image(im, func)) {
                return -1;
            }
        }
    }
    return 0;
}
Exemple #28
0
void wrap_dim(Param<T> out, CParam<T> in, const dim_t wx, const dim_t wy,
              const dim_t sx, const dim_t sy, const dim_t px, const dim_t py) {
    const T* inPtr = in.get();
    T* outPtr      = out.get();

    af::dim4 idims    = in.dims();
    af::dim4 odims    = out.dims();
    af::dim4 istrides = in.strides();
    af::dim4 ostrides = out.strides();

    dim_t nx = (odims[0] + 2 * px - wx) / sx + 1;

    for (dim_t w = 0; w < idims[3]; w++) {
        for (dim_t z = 0; z < idims[2]; z++) {
            dim_t cIn      = w * istrides[3] + z * istrides[2];
            dim_t cOut     = w * ostrides[3] + z * ostrides[2];
            const T* iptr_ = inPtr + cIn;
            T* optr        = outPtr + cOut;

            for (dim_t col = 0; col < idims[d]; col++) {
                // Offset output ptr
                const T* iptr = iptr_ + col * istrides[d];

                // Calculate input window index
                dim_t winy = (col / nx);
                dim_t winx = (col % nx);

                dim_t startx = winx * sx;
                dim_t starty = winy * sy;

                dim_t spx = startx - px;
                dim_t spy = starty - py;

                // Short cut condition ensuring all values within input
                // dimensions
                bool cond = (spx >= 0 && spx + wx < odims[0] && spy >= 0 &&
                             spy + wy < odims[1]);

                for (dim_t y = 0; y < wy; y++) {
                    for (dim_t x = 0; x < wx; x++) {
                        dim_t xpad = spx + x;
                        dim_t ypad = spy + y;

                        dim_t iloc = (y * wx + x);
                        if (d == 0) iloc *= istrides[1];

                        if (cond || (xpad >= 0 && xpad < odims[0] &&
                                     ypad >= 0 && ypad < odims[1])) {
                            dim_t oloc =
                                (ypad * ostrides[1] + xpad * ostrides[0]);
                            // FIXME: When using threads, atomize this
                            optr[oloc] += iptr[iloc];
                        }
                    }
                }
            }
        }
    }
}
 void TransformationModelLinear::getDefaultParameters(Param& params)
 {
   params.clear();
   params.setValue("symmetric_regression", "false", "Perform linear regression"
                                                    " on 'y - x' vs. 'y + x', instead of on 'y' vs. 'x'.");
   params.setValidStrings("symmetric_regression",
                          ListUtils::create<String>("true,false"));
 }
// **************************************************************************
// Function:   Add
// Purpose:    adds a new parameter to the list of parameters
//             if a parameter with the same name already exists,
//             it updates the currently stored parameter with the provided values
// Parameters: inParam       - reference to a Param object representing the
//                             parameter,
//             inSortingHint - float value used as an additional sorting
//                             criterion.
// Returns:    N/A
// **************************************************************************
void
ParamList::Add( const Param& inParam, float inSortingHint )
{
  ByName( inParam.Name() );
  ParamEntry& entry = mParams[inParam.Name()];
  entry.Param = inParam;
  entry.SortingHint = inSortingHint;
}