text: // Generated by using Rcpp::compileAttributes() -> do not edit by hand
  // Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
  
  #include <Rcpp.h>
  
  using namespace Rcpp;
  
  // create_inward_dir_matrix
  IntegerMatrix create_inward_dir_matrix(const IntegerMatrix& directions, bool wrapX, bool wrapY);
  RcppExport SEXP _wsim_lsm_create_inward_dir_matrix(SEXP directionsSEXP, SEXP wrapXSEXP, SEXP wrapYSEXP) {
  BEGIN_RCPP
      Rcpp::RObject rcpp_result_gen;
      Rcpp::RNGScope rcpp_rngScope_gen;
      Rcpp::traits::input_parameter< const IntegerMatrix& >::type directions(directionsSEXP);
      Rcpp::traits::input_parameter< bool >::type wrapX(wrapXSEXP);
      Rcpp::traits::input_parameter< bool >::type wrapY(wrapYSEXP);
      rcpp_result_gen = Rcpp::wrap(create_inward_dir_matrix(directions, wrapX, wrapY));
      return rcpp_result_gen;
  END_RCPP
  }
  // aggregate_flows
  Rcpp::NumericMatrix aggregate_flows(const Rcpp::NumericMatrix& flows, const Rcpp::IntegerMatrix& directions, std::size_t factor, bool wrapX, bool wrapY);
  RcppExport SEXP _wsim_lsm_aggregate_flows(SEXP flowsSEXP, SEXP directionsSEXP, SEXP factorSEXP, SEXP wrapXSEXP, SEXP wrapYSEXP) {
  BEGIN_RCPP
      Rcpp::RObject rcpp_result_gen;
      Rcpp::RNGScope rcpp_rngScope_gen;
      Rcpp::traits::input_parameter< const Rcpp::NumericMatrix& >::type flows(flowsSEXP);
      Rcpp::traits::input_parameter< const Rcpp::IntegerMatrix& >::type directions(directionsSEXP);
      Rcpp::traits::input_parameter< std::size_t >::type factor(factorSEXP);
      Rcpp::traits::input_parameter< bool >::type wrapX(wrapXSEXP);
      Rcpp::traits::input_parameter< bool >::type wrapY(wrapYSEXP);
      rcpp_result_gen = Rcpp::wrap(aggregate_flows(flows, directions, factor, wrapX, wrapY));
      return rcpp_result_gen;
  END_RCPP
  }
  // disaggregate_amount
  Rcpp::NumericMatrix disaggregate_amount(const Rcpp::NumericMatrix& mat, size_t factor);
  RcppExport SEXP _wsim_lsm_disaggregate_amount(SEXP matSEXP, SEXP factorSEXP) {
  BEGIN_RCPP
      Rcpp::RObject rcpp_result_gen;
      Rcpp::RNGScope rcpp_rngScope_gen;
      Rcpp::traits::input_parameter< const Rcpp::NumericMatrix& >::type mat(matSEXP);
      Rcpp::traits::input_parameter< size_t >::type factor(factorSEXP);
      rcpp_result_gen = Rcpp::wrap(disaggregate_amount(mat, factor));
      return rcpp_result_gen;
  END_RCPP
  }
  // accumulate_flow
  NumericMatrix accumulate_flow(const IntegerMatrix& directions, const NumericMatrix& weights, bool wrapX, bool wrapY);
  RcppExport SEXP _wsim_lsm_accumulate_flow(SEXP directionsSEXP, SEXP weightsSEXP, SEXP wrapXSEXP, SEXP wrapYSEXP) {
  BEGIN_RCPP
      Rcpp::RObject rcpp_result_gen;
      Rcpp::RNGScope rcpp_rngScope_gen;
      Rcpp::traits::input_parameter< const IntegerMatrix& >::type directions(directionsSEXP);
      Rcpp::traits::input_parameter< const NumericMatrix& >::type weights(weightsSEXP);
      Rcpp::traits::input_parameter< bool >::type wrapX(wrapXSEXP);
      Rcpp::traits::input_parameter< bool >::type wrapY(wrapYSEXP);
      rcpp_result_gen = Rcpp::wrap(accumulate_flow(directions, weights, wrapX, wrapY));
      return rcpp_result_gen;
  END_RCPP
  }
  // accumulate
  NumericVector accumulate(const IntegerVector& basin_ids, const IntegerVector& downstream_ids, const NumericVector& flows);
  RcppExport SEXP _wsim_lsm_accumulate(SEXP basin_idsSEXP, SEXP downstream_idsSEXP, SEXP flowsSEXP) {
  BEGIN_RCPP
      Rcpp::RObject rcpp_result_gen;
      Rcpp::RNGScope rcpp_rngScope_gen;
      Rcpp::traits::input_parameter< const IntegerVector& >::type basin_ids(basin_idsSEXP);
      Rcpp::traits::input_parameter< const IntegerVector& >::type downstream_ids(downstream_idsSEXP);
      Rcpp::traits::input_parameter< const NumericVector& >::type flows(flowsSEXP);
      rcpp_result_gen = Rcpp::wrap(accumulate(basin_ids, downstream_ids, flows));
      return rcpp_result_gen;
  END_RCPP
  }
  // downstream_flow
  NumericVector downstream_flow(const IntegerVector& basin_ids, const IntegerVector& downstream_ids, const NumericVector& flows);
  RcppExport SEXP _wsim_lsm_downstream_flow(SEXP basin_idsSEXP, SEXP downstream_idsSEXP, SEXP flowsSEXP) {
  BEGIN_RCPP
      Rcpp::RObject rcpp_result_gen;
      Rcpp::RNGScope rcpp_rngScope_gen;
      Rcpp::traits::input_parameter< const IntegerVector& >::type basin_ids(basin_idsSEXP);
      Rcpp::traits::input_parameter< const IntegerVector& >::type downstream_ids(downstream_idsSEXP);
      Rcpp::traits::input_parameter< const NumericVector& >::type flows(flowsSEXP);
      rcpp_result_gen = Rcpp::wrap(downstream_flow(basin_ids, downstream_ids, flows));
      return rcpp_result_gen;
  END_RCPP
  }
  // coalesce
  NumericVector coalesce(const NumericVector& v, const NumericVector& replacement_value);
  RcppExport SEXP _wsim_lsm_coalesce(SEXP vSEXP, SEXP replacement_valueSEXP) {
  BEGIN_RCPP
      Rcpp::RObject rcpp_result_gen;
      Rcpp::RNGScope rcpp_rngScope_gen;
      Rcpp::traits::input_parameter< const NumericVector& >::type v(vSEXP);
      Rcpp::traits::input_parameter< const NumericVector& >::type replacement_value(replacement_valueSEXP);
      rcpp_result_gen = Rcpp::wrap(coalesce(v, replacement_value));
      return rcpp_result_gen;
  END_RCPP
  }
  // is_leap_year
  bool is_leap_year(int y);
  RcppExport SEXP _wsim_lsm_is_leap_year(SEXP ySEXP) {
  BEGIN_RCPP
      Rcpp::RObject rcpp_result_gen;
      Rcpp::RNGScope rcpp_rngScope_gen;
      Rcpp::traits::input_parameter< int >::type y(ySEXP);
      rcpp_result_gen = Rcpp::wrap(is_leap_year(y));
      return rcpp_result_gen;
  END_RCPP
  }
  // day_hours
  double day_hours(double sun_lat, double earth_lat);
  RcppExport SEXP _wsim_lsm_day_hours(SEXP sun_latSEXP, SEXP earth_latSEXP) {
  BEGIN_RCPP
      Rcpp::RObject rcpp_result_gen;
      Rcpp::RNGScope rcpp_rngScope_gen;
      Rcpp::traits::input_parameter< double >::type sun_lat(sun_latSEXP);
      Rcpp::traits::input_parameter< double >::type earth_lat(earth_latSEXP);
      rcpp_result_gen = Rcpp::wrap(day_hours(sun_lat, earth_lat));
      return rcpp_result_gen;
  END_RCPP
  }
  // day_length
  NumericVector day_length(const NumericVector& latitudes, int year, int month, int day);
  RcppExport SEXP _wsim_lsm_day_length(SEXP latitudesSEXP, SEXP yearSEXP, SEXP monthSEXP, SEXP daySEXP) {
  BEGIN_RCPP
      Rcpp::RObject rcpp_result_gen;
      Rcpp::RNGScope rcpp_rngScope_gen;
      Rcpp::traits::input_parameter< const NumericVector& >::type latitudes(latitudesSEXP);
      Rcpp::traits::input_parameter< int >::type year(yearSEXP);
      Rcpp::traits::input_parameter< int >::type month(monthSEXP);
      Rcpp::traits::input_parameter< int >::type day(daySEXP);
      rcpp_result_gen = Rcpp::wrap(day_length(latitudes, year, month, day));
      return rcpp_result_gen;
  END_RCPP
  }
  // average_day_length
  NumericVector average_day_length(const NumericVector& latitudes, int year, int month);
  RcppExport SEXP _wsim_lsm_average_day_length(SEXP latitudesSEXP, SEXP yearSEXP, SEXP monthSEXP) {
  BEGIN_RCPP
      Rcpp::RObject rcpp_result_gen;
      Rcpp::RNGScope rcpp_rngScope_gen;
      Rcpp::traits::input_parameter< const NumericVector& >::type latitudes(latitudesSEXP);
      Rcpp::traits::input_parameter< int >::type year(yearSEXP);
      Rcpp::traits::input_parameter< int >::type month(monthSEXP);
      rcpp_result_gen = Rcpp::wrap(average_day_length(latitudes, year, month));
      return rcpp_result_gen;
  END_RCPP
  }
  // daily_hydro
  List daily_hydro(double P, double Sa, double Sm, double E0, double Ws, double Wc, int nDays, double pWetDays);
  RcppExport SEXP _wsim_lsm_daily_hydro(SEXP PSEXP, SEXP SaSEXP, SEXP SmSEXP, SEXP E0SEXP, SEXP WsSEXP, SEXP WcSEXP, SEXP nDaysSEXP, SEXP pWetDaysSEXP) {
  BEGIN_RCPP
      Rcpp::RObject rcpp_result_gen;
      Rcpp::RNGScope rcpp_rngScope_gen;
      Rcpp::traits::input_parameter< double >::type P(PSEXP);
      Rcpp::traits::input_parameter< double >::type Sa(SaSEXP);
      Rcpp::traits::input_parameter< double >::type Sm(SmSEXP);
      Rcpp::traits::input_parameter< double >::type E0(E0SEXP);
      Rcpp::traits::input_parameter< double >::type Ws(WsSEXP);
      Rcpp::traits::input_parameter< double >::type Wc(WcSEXP);
      Rcpp::traits::input_parameter< int >::type nDays(nDaysSEXP);
      Rcpp::traits::input_parameter< double >::type pWetDays(pWetDaysSEXP);
      rcpp_result_gen = Rcpp::wrap(daily_hydro(P, Sa, Sm, E0, Ws, Wc, nDays, pWetDays));
      return rcpp_result_gen;
  END_RCPP
  }
  // daily_hydro_loop
  List daily_hydro_loop(const NumericMatrix& P, const NumericMatrix& Sa, const NumericMatrix& Sm, const NumericMatrix& E0, const NumericMatrix& Ws, const NumericMatrix& Wc, int nDays, const NumericMatrix& pWetDays);
  RcppExport SEXP _wsim_lsm_daily_hydro_loop(SEXP PSEXP, SEXP SaSEXP, SEXP SmSEXP, SEXP E0SEXP, SEXP WsSEXP, SEXP WcSEXP, SEXP nDaysSEXP, SEXP pWetDaysSEXP) {
  BEGIN_RCPP
      Rcpp::RObject rcpp_result_gen;
      Rcpp::RNGScope rcpp_rngScope_gen;
      Rcpp::traits::input_parameter< const NumericMatrix& >::type P(PSEXP);
      Rcpp::traits::input_parameter< const NumericMatrix& >::type Sa(SaSEXP);
      Rcpp::traits::input_parameter< const NumericMatrix& >::type Sm(SmSEXP);
      Rcpp::traits::input_parameter< const NumericMatrix& >::type E0(E0SEXP);
      Rcpp::traits::input_parameter< const NumericMatrix& >::type Ws(WsSEXP);
      Rcpp::traits::input_parameter< const NumericMatrix& >::type Wc(WcSEXP);
      Rcpp::traits::input_parameter< int >::type nDays(nDaysSEXP);
      Rcpp::traits::input_parameter< const NumericMatrix& >::type pWetDays(pWetDaysSEXP);
      rcpp_result_gen = Rcpp::wrap(daily_hydro_loop(P, Sa, Sm, E0, Ws, Wc, nDays, pWetDays));
      return rcpp_result_gen;
  END_RCPP
  }
  // make_wet_day_list
  IntegerVector make_wet_day_list(int nDays, double pWetDays);
  RcppExport SEXP _wsim_lsm_make_wet_day_list(SEXP nDaysSEXP, SEXP pWetDaysSEXP) {
  BEGIN_RCPP
      Rcpp::RObject rcpp_result_gen;
      Rcpp::RNGScope rcpp_rngScope_gen;
      Rcpp::traits::input_parameter< int >::type nDays(nDaysSEXP);
      Rcpp::traits::input_parameter< double >::type pWetDays(pWetDaysSEXP);
      rcpp_result_gen = Rcpp::wrap(make_wet_day_list(nDays, pWetDays));
      return rcpp_result_gen;
  END_RCPP
  }
  // make_daily_precip
  NumericVector make_daily_precip(double P_total, int nDays, double pWetDays);
  RcppExport SEXP _wsim_lsm_make_daily_precip(SEXP P_totalSEXP, SEXP nDaysSEXP, SEXP pWetDaysSEXP) {
  BEGIN_RCPP
      Rcpp::RObject rcpp_result_gen;
      Rcpp::RNGScope rcpp_rngScope_gen;
      Rcpp::traits::input_parameter< double >::type P_total(P_totalSEXP);
      Rcpp::traits::input_parameter< int >::type nDays(nDaysSEXP);
      Rcpp::traits::input_parameter< double >::type pWetDays(pWetDaysSEXP);
      rcpp_result_gen = Rcpp::wrap(make_daily_precip(P_total, nDays, pWetDays));
      return rcpp_result_gen;
  END_RCPP
  }
  // runoff_detained_snowpack_cpp
  double runoff_detained_snowpack_cpp(double Ds, double Xs, int melt_month, double z);
  RcppExport SEXP _wsim_lsm_runoff_detained_snowpack_cpp(SEXP DsSEXP, SEXP XsSEXP, SEXP melt_monthSEXP, SEXP zSEXP) {
  BEGIN_RCPP
      Rcpp::RObject rcpp_result_gen;
      Rcpp::RNGScope rcpp_rngScope_gen;
      Rcpp::traits::input_parameter< double >::type Ds(DsSEXP);
      Rcpp::traits::input_parameter< double >::type Xs(XsSEXP);
      Rcpp::traits::input_parameter< int >::type melt_month(melt_monthSEXP);
      Rcpp::traits::input_parameter< double >::type z(zSEXP);
      rcpp_result_gen = Rcpp::wrap(runoff_detained_snowpack_cpp(Ds, Xs, melt_month, z));
      return rcpp_result_gen;
  END_RCPP
  }
  // calc_detained
  List calc_detained(const NumericVector& R, const NumericVector& Pr, const NumericVector& P, const NumericVector& Sm, const NumericVector& Dr, const NumericVector& Ds, const NumericVector& z, const IntegerVector& melt_month);
  RcppExport SEXP _wsim_lsm_calc_detained(SEXP RSEXP, SEXP PrSEXP, SEXP PSEXP, SEXP SmSEXP, SEXP DrSEXP, SEXP DsSEXP, SEXP zSEXP, SEXP melt_monthSEXP) {
  BEGIN_RCPP
      Rcpp::RObject rcpp_result_gen;
      Rcpp::RNGScope rcpp_rngScope_gen;
      Rcpp::traits::input_parameter< const NumericVector& >::type R(RSEXP);
      Rcpp::traits::input_parameter< const NumericVector& >::type Pr(PrSEXP);
      Rcpp::traits::input_parameter< const NumericVector& >::type P(PSEXP);
      Rcpp::traits::input_parameter< const NumericVector& >::type Sm(SmSEXP);
      Rcpp::traits::input_parameter< const NumericVector& >::type Dr(DrSEXP);
      Rcpp::traits::input_parameter< const NumericVector& >::type Ds(DsSEXP);
      Rcpp::traits::input_parameter< const NumericVector& >::type z(zSEXP);
      Rcpp::traits::input_parameter< const IntegerVector& >::type melt_month(melt_monthSEXP);
      rcpp_result_gen = Rcpp::wrap(calc_detained(R, Pr, P, Sm, Dr, Ds, z, melt_month));
      return rcpp_result_gen;
  END_RCPP
  }
  // snow_accum
  NumericVector snow_accum(const NumericVector& Pr, const NumericVector& T);
  RcppExport SEXP _wsim_lsm_snow_accum(SEXP PrSEXP, SEXP TSEXP) {
  BEGIN_RCPP
      Rcpp::RObject rcpp_result_gen;
      Rcpp::RNGScope rcpp_rngScope_gen;
      Rcpp::traits::input_parameter< const NumericVector& >::type Pr(PrSEXP);
      Rcpp::traits::input_parameter< const NumericVector& >::type T(TSEXP);
      rcpp_result_gen = Rcpp::wrap(snow_accum(Pr, T));
      return rcpp_result_gen;
  END_RCPP
  }
  // snow_melt
  NumericVector snow_melt(const NumericVector& snowpack, const IntegerVector& melt_month, const NumericVector& T, const NumericVector& z);
  RcppExport SEXP _wsim_lsm_snow_melt(SEXP snowpackSEXP, SEXP melt_monthSEXP, SEXP TSEXP, SEXP zSEXP) {
  BEGIN_RCPP
      Rcpp::RObject rcpp_result_gen;
      Rcpp::RNGScope rcpp_rngScope_gen;
      Rcpp::traits::input_parameter< const NumericVector& >::type snowpack(snowpackSEXP);
      Rcpp::traits::input_parameter< const IntegerVector& >::type melt_month(melt_monthSEXP);
      Rcpp::traits::input_parameter< const NumericVector& >::type T(TSEXP);
      Rcpp::traits::input_parameter< const NumericVector& >::type z(zSEXP);
      rcpp_result_gen = Rcpp::wrap(snow_melt(snowpack, melt_month, T, z));
      return rcpp_result_gen;
  END_RCPP
  }
  // g
  double g(double Ws, double Wc, double E0, double P);
  RcppExport SEXP _wsim_lsm_g(SEXP WsSEXP, SEXP WcSEXP, SEXP E0SEXP, SEXP PSEXP) {
  BEGIN_RCPP
      Rcpp::RObject rcpp_result_gen;
      Rcpp::RNGScope rcpp_rngScope_gen;
      Rcpp::traits::input_parameter< double >::type Ws(WsSEXP);
      Rcpp::traits::input_parameter< double >::type Wc(WcSEXP);
      Rcpp::traits::input_parameter< double >::type E0(E0SEXP);
      Rcpp::traits::input_parameter< double >::type P(PSEXP);
      rcpp_result_gen = Rcpp::wrap(g(Ws, Wc, E0, P));
      return rcpp_result_gen;
  END_RCPP
  }
  // soil_moisture_change
  double soil_moisture_change(double P, double E0, double Ws, double Wc);
  RcppExport SEXP _wsim_lsm_soil_moisture_change(SEXP PSEXP, SEXP E0SEXP, SEXP WsSEXP, SEXP WcSEXP) {
  BEGIN_RCPP
      Rcpp::RObject rcpp_result_gen;
      Rcpp::RNGScope rcpp_rngScope_gen;
      Rcpp::traits::input_parameter< double >::type P(PSEXP);
      Rcpp::traits::input_parameter< double >::type E0(E0SEXP);
      Rcpp::traits::input_parameter< double >::type Ws(WsSEXP);
      Rcpp::traits::input_parameter< double >::type Wc(WcSEXP);
      rcpp_result_gen = Rcpp::wrap(soil_moisture_change(P, E0, Ws, Wc));
      return rcpp_result_gen;
  END_RCPP
  }
  
  static const R_CallMethodDef CallEntries[] = {
      {"_wsim_lsm_create_inward_dir_matrix", (DL_FUNC) &_wsim_lsm_create_inward_dir_matrix, 3},
      {"_wsim_lsm_aggregate_flows", (DL_FUNC) &_wsim_lsm_aggregate_flows, 5},
      {"_wsim_lsm_disaggregate_amount", (DL_FUNC) &_wsim_lsm_disaggregate_amount, 2},
      {"_wsim_lsm_accumulate_flow", (DL_FUNC) &_wsim_lsm_accumulate_flow, 4},
      {"_wsim_lsm_accumulate", (DL_FUNC) &_wsim_lsm_accumulate, 3},
      {"_wsim_lsm_downstream_flow", (DL_FUNC) &_wsim_lsm_downstream_flow, 3},
      {"_wsim_lsm_coalesce", (DL_FUNC) &_wsim_lsm_coalesce, 2},
      {"_wsim_lsm_is_leap_year", (DL_FUNC) &_wsim_lsm_is_leap_year, 1},
      {"_wsim_lsm_day_hours", (DL_FUNC) &_wsim_lsm_day_hours, 2},
      {"_wsim_lsm_day_length", (DL_FUNC) &_wsim_lsm_day_length, 4},
      {"_wsim_lsm_average_day_length", (DL_FUNC) &_wsim_lsm_average_day_length, 3},
      {"_wsim_lsm_daily_hydro", (DL_FUNC) &_wsim_lsm_daily_hydro, 8},
      {"_wsim_lsm_daily_hydro_loop", (DL_FUNC) &_wsim_lsm_daily_hydro_loop, 8},
      {"_wsim_lsm_make_wet_day_list", (DL_FUNC) &_wsim_lsm_make_wet_day_list, 2},
      {"_wsim_lsm_make_daily_precip", (DL_FUNC) &_wsim_lsm_make_daily_precip, 3},
      {"_wsim_lsm_runoff_detained_snowpack_cpp", (DL_FUNC) &_wsim_lsm_runoff_detained_snowpack_cpp, 4},
      {"_wsim_lsm_calc_detained", (DL_FUNC) &_wsim_lsm_calc_detained, 8},
      {"_wsim_lsm_snow_accum", (DL_FUNC) &_wsim_lsm_snow_accum, 2},
      {"_wsim_lsm_snow_melt", (DL_FUNC) &_wsim_lsm_snow_melt, 4},
      {"_wsim_lsm_g", (DL_FUNC) &_wsim_lsm_g, 4},
      {"_wsim_lsm_soil_moisture_change", (DL_FUNC) &_wsim_lsm_soil_moisture_change, 4},
      {NULL, NULL, 0}
  };
  
  RcppExport void R_init_wsim_lsm(DllInfo *dll) {
      R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
      R_useDynamicSymbols(dll, FALSE);
  }
  