hexsha stringlengths 40 40 | size int64 7 1.05M | ext stringclasses 13
values | lang stringclasses 1
value | max_stars_repo_path stringlengths 4 269 | max_stars_repo_name stringlengths 5 108 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 9 | max_stars_count int64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringlengths 24 24 ⌀ | max_stars_repo_stars_event_max_datetime stringlengths 24 24 ⌀ | max_issues_repo_path stringlengths 4 269 | max_issues_repo_name stringlengths 5 116 | max_issues_repo_head_hexsha stringlengths 40 40 | max_issues_repo_licenses listlengths 1 9 | max_issues_count int64 1 67k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 4 269 | max_forks_repo_name stringlengths 5 116 | max_forks_repo_head_hexsha stringlengths 40 40 | max_forks_repo_licenses listlengths 1 9 | max_forks_count int64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringlengths 24 24 ⌀ | max_forks_repo_forks_event_max_datetime stringlengths 24 24 ⌀ | content stringlengths 7 1.05M | avg_line_length float64 1.21 330k | max_line_length int64 6 990k | alphanum_fraction float64 0.01 0.99 | author_id stringlengths 2 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
d65780e66d8d03a36e25019eac73196f8c759a69 | 25,659 | cpp | C++ | src/RcppExports.cpp | hillarykoch/CLIMB | da6cc77ff8be48ceeb63247506467911d6130ac2 | [
"Artistic-2.0"
] | 3 | 2021-11-29T08:05:48.000Z | 2022-01-08T16:16:35.000Z | src/RcppExports.cpp | hillarykoch/CLIMB | da6cc77ff8be48ceeb63247506467911d6130ac2 | [
"Artistic-2.0"
] | null | null | null | src/RcppExports.cpp | hillarykoch/CLIMB | da6cc77ff8be48ceeb63247506467911d6130ac2 | [
"Artistic-2.0"
] | 2 | 2020-02-24T19:18:06.000Z | 2020-09-08T14:29:27.000Z | // Generated by using Rcpp::compileAttributes() -> do not edit by hand
// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
#include <RcppArmadillo.h>
#include <Rcpp.h>
using namespace Rcpp;
// cgetPaths
arma::mat cgetPaths(std::string filepath);
RcppExport SEXP _CLIMB_cgetPaths(SEXP filepathSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< std::string >::type filepath(filepathSEXP);
rcpp_result_gen = Rcpp::wrap(cgetPaths(filepath));
return rcpp_result_gen;
END_RCPP
}
// crowMatch
arma::uvec crowMatch(arma::mat assoc, arma::mat nonconsec);
RcppExport SEXP _CLIMB_crowMatch(SEXP assocSEXP, SEXP nonconsecSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< arma::mat >::type assoc(assocSEXP);
Rcpp::traits::input_parameter< arma::mat >::type nonconsec(nonconsecSEXP);
rcpp_result_gen = Rcpp::wrap(crowMatch(assoc, nonconsec));
return rcpp_result_gen;
END_RCPP
}
// get_list_names
std::vector<std::string> get_list_names(Rcpp::List L);
RcppExport SEXP _CLIMB_get_list_names(SEXP LSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< Rcpp::List >::type L(LSEXP);
rcpp_result_gen = Rcpp::wrap(get_list_names(L));
return rcpp_result_gen;
END_RCPP
}
// cpaste0
std::string cpaste0(std::vector<std::string> str1);
RcppExport SEXP _CLIMB_cpaste0(SEXP str1SEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< std::vector<std::string> >::type str1(str1SEXP);
rcpp_result_gen = Rcpp::wrap(cpaste0(str1));
return rcpp_result_gen;
END_RCPP
}
// cstr_split
arma::mat cstr_split(std::vector<std::string> strings, std::string split);
RcppExport SEXP _CLIMB_cstr_split(SEXP stringsSEXP, SEXP splitSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< std::vector<std::string> >::type strings(stringsSEXP);
Rcpp::traits::input_parameter< std::string >::type split(splitSEXP);
rcpp_result_gen = Rcpp::wrap(cstr_split(strings, split));
return rcpp_result_gen;
END_RCPP
}
// trans_func
int trans_func(double& x);
RcppExport SEXP _CLIMB_trans_func(SEXP xSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< double& >::type x(xSEXP);
rcpp_result_gen = Rcpp::wrap(trans_func(x));
return rcpp_result_gen;
END_RCPP
}
// caccept
arma::vec caccept(arma::mat x, arma::colvec y);
RcppExport SEXP _CLIMB_caccept(SEXP xSEXP, SEXP ySEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< arma::mat >::type x(xSEXP);
Rcpp::traits::input_parameter< arma::colvec >::type y(ySEXP);
rcpp_result_gen = Rcpp::wrap(caccept(x, y));
return rcpp_result_gen;
END_RCPP
}
// cget_prior_count
arma::colvec cget_prior_count(arma::mat red_class, Rcpp::List mus, arma::mat labels, int d, int n, int dist_tol);
RcppExport SEXP _CLIMB_cget_prior_count(SEXP red_classSEXP, SEXP musSEXP, SEXP labelsSEXP, SEXP dSEXP, SEXP nSEXP, SEXP dist_tolSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< arma::mat >::type red_class(red_classSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type mus(musSEXP);
Rcpp::traits::input_parameter< arma::mat >::type labels(labelsSEXP);
Rcpp::traits::input_parameter< int >::type d(dSEXP);
Rcpp::traits::input_parameter< int >::type n(nSEXP);
Rcpp::traits::input_parameter< int >::type dist_tol(dist_tolSEXP);
rcpp_result_gen = Rcpp::wrap(cget_prior_count(red_class, mus, labels, d, n, dist_tol));
return rcpp_result_gen;
END_RCPP
}
// creduce_by_hamming
arma::colvec creduce_by_hamming(arma::mat red_class, arma::colvec fullidx, int hamming_tol, int M);
RcppExport SEXP _CLIMB_creduce_by_hamming(SEXP red_classSEXP, SEXP fullidxSEXP, SEXP hamming_tolSEXP, SEXP MSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< arma::mat >::type red_class(red_classSEXP);
Rcpp::traits::input_parameter< arma::colvec >::type fullidx(fullidxSEXP);
Rcpp::traits::input_parameter< int >::type hamming_tol(hamming_tolSEXP);
Rcpp::traits::input_parameter< int >::type M(MSEXP);
rcpp_result_gen = Rcpp::wrap(creduce_by_hamming(red_class, fullidx, hamming_tol, M));
return rcpp_result_gen;
END_RCPP
}
// cget_true_assoc_idx
arma::colvec cget_true_assoc_idx(arma::mat red_class, arma::mat true_assoc);
RcppExport SEXP _CLIMB_cget_true_assoc_idx(SEXP red_classSEXP, SEXP true_assocSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< arma::mat >::type red_class(red_classSEXP);
Rcpp::traits::input_parameter< arma::mat >::type true_assoc(true_assocSEXP);
rcpp_result_gen = Rcpp::wrap(cget_true_assoc_idx(red_class, true_assoc));
return rcpp_result_gen;
END_RCPP
}
// cassociate
arma::mat cassociate(arma::mat& paths, std::string filepath, int len_filt_h);
RcppExport SEXP _CLIMB_cassociate(SEXP pathsSEXP, SEXP filepathSEXP, SEXP len_filt_hSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< arma::mat& >::type paths(pathsSEXP);
Rcpp::traits::input_parameter< std::string >::type filepath(filepathSEXP);
Rcpp::traits::input_parameter< int >::type len_filt_h(len_filt_hSEXP);
rcpp_result_gen = Rcpp::wrap(cassociate(paths, filepath, len_filt_h));
return rcpp_result_gen;
END_RCPP
}
// abs3
double abs3(double val);
RcppExport SEXP _CLIMB_abs3(SEXP valSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< double >::type val(valSEXP);
rcpp_result_gen = Rcpp::wrap(abs3(val));
return rcpp_result_gen;
END_RCPP
}
// SCAD_1d
arma::rowvec SCAD_1d(arma::rowvec prop, double lambda, int k, double a);
RcppExport SEXP _CLIMB_SCAD_1d(SEXP propSEXP, SEXP lambdaSEXP, SEXP kSEXP, SEXP aSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< arma::rowvec >::type prop(propSEXP);
Rcpp::traits::input_parameter< double >::type lambda(lambdaSEXP);
Rcpp::traits::input_parameter< int >::type k(kSEXP);
Rcpp::traits::input_parameter< double >::type a(aSEXP);
rcpp_result_gen = Rcpp::wrap(SCAD_1d(prop, lambda, k, a));
return rcpp_result_gen;
END_RCPP
}
// double_SCAD_1d
double double_SCAD_1d(double prop, double lambda, double a);
RcppExport SEXP _CLIMB_double_SCAD_1d(SEXP propSEXP, SEXP lambdaSEXP, SEXP aSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< double >::type prop(propSEXP);
Rcpp::traits::input_parameter< double >::type lambda(lambdaSEXP);
Rcpp::traits::input_parameter< double >::type a(aSEXP);
rcpp_result_gen = Rcpp::wrap(double_SCAD_1d(prop, lambda, a));
return rcpp_result_gen;
END_RCPP
}
// SCAD
arma::rowvec SCAD(arma::rowvec prop, double lambda, int k, double a);
RcppExport SEXP _CLIMB_SCAD(SEXP propSEXP, SEXP lambdaSEXP, SEXP kSEXP, SEXP aSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< arma::rowvec >::type prop(propSEXP);
Rcpp::traits::input_parameter< double >::type lambda(lambdaSEXP);
Rcpp::traits::input_parameter< int >::type k(kSEXP);
Rcpp::traits::input_parameter< double >::type a(aSEXP);
rcpp_result_gen = Rcpp::wrap(SCAD(prop, lambda, k, a));
return rcpp_result_gen;
END_RCPP
}
// double_SCAD
double double_SCAD(double prop, double lambda, double a);
RcppExport SEXP _CLIMB_double_SCAD(SEXP propSEXP, SEXP lambdaSEXP, SEXP aSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< double >::type prop(propSEXP);
Rcpp::traits::input_parameter< double >::type lambda(lambdaSEXP);
Rcpp::traits::input_parameter< double >::type a(aSEXP);
rcpp_result_gen = Rcpp::wrap(double_SCAD(prop, lambda, a));
return rcpp_result_gen;
END_RCPP
}
// Mahalanobis
arma::vec Mahalanobis(arma::mat x, arma::rowvec mu, arma::mat sigma);
RcppExport SEXP _CLIMB_Mahalanobis(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< arma::mat >::type x(xSEXP);
Rcpp::traits::input_parameter< arma::rowvec >::type mu(muSEXP);
Rcpp::traits::input_parameter< arma::mat >::type sigma(sigmaSEXP);
rcpp_result_gen = Rcpp::wrap(Mahalanobis(x, mu, sigma));
return rcpp_result_gen;
END_RCPP
}
// cdmvnorm
arma::vec cdmvnorm(arma::mat x, arma::rowvec mu, arma::mat sigma);
RcppExport SEXP _CLIMB_cdmvnorm(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< arma::mat >::type x(xSEXP);
Rcpp::traits::input_parameter< arma::rowvec >::type mu(muSEXP);
Rcpp::traits::input_parameter< arma::mat >::type sigma(sigmaSEXP);
rcpp_result_gen = Rcpp::wrap(cdmvnorm(x, mu, sigma));
return rcpp_result_gen;
END_RCPP
}
// cget_constr_sigma
arma::mat cget_constr_sigma(arma::rowvec sigma, double rho, arma::rowvec combos, int d);
RcppExport SEXP _CLIMB_cget_constr_sigma(SEXP sigmaSEXP, SEXP rhoSEXP, SEXP combosSEXP, SEXP dSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< arma::rowvec >::type sigma(sigmaSEXP);
Rcpp::traits::input_parameter< double >::type rho(rhoSEXP);
Rcpp::traits::input_parameter< arma::rowvec >::type combos(combosSEXP);
Rcpp::traits::input_parameter< int >::type d(dSEXP);
rcpp_result_gen = Rcpp::wrap(cget_constr_sigma(sigma, rho, combos, d));
return rcpp_result_gen;
END_RCPP
}
// func_to_optim
double func_to_optim(const arma::colvec& init_val, arma::mat& x, arma::mat& h_est, arma::mat& combos);
RcppExport SEXP _CLIMB_func_to_optim(SEXP init_valSEXP, SEXP xSEXP, SEXP h_estSEXP, SEXP combosSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const arma::colvec& >::type init_val(init_valSEXP);
Rcpp::traits::input_parameter< arma::mat& >::type x(xSEXP);
Rcpp::traits::input_parameter< arma::mat& >::type h_est(h_estSEXP);
Rcpp::traits::input_parameter< arma::mat& >::type combos(combosSEXP);
rcpp_result_gen = Rcpp::wrap(func_to_optim(init_val, x, h_est, combos));
return rcpp_result_gen;
END_RCPP
}
// optim_rcpp
arma::vec optim_rcpp(const arma::vec& init_val, arma::mat& x, arma::mat& h_est, arma::mat& combos);
RcppExport SEXP _CLIMB_optim_rcpp(SEXP init_valSEXP, SEXP xSEXP, SEXP h_estSEXP, SEXP combosSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const arma::vec& >::type init_val(init_valSEXP);
Rcpp::traits::input_parameter< arma::mat& >::type x(xSEXP);
Rcpp::traits::input_parameter< arma::mat& >::type h_est(h_estSEXP);
Rcpp::traits::input_parameter< arma::mat& >::type combos(combosSEXP);
rcpp_result_gen = Rcpp::wrap(optim_rcpp(init_val, x, h_est, combos));
return rcpp_result_gen;
END_RCPP
}
// func_to_optim_bound
double func_to_optim_bound(const arma::colvec& init_val, arma::mat& x, arma::mat& h_est, arma::mat& combos, double& bound);
RcppExport SEXP _CLIMB_func_to_optim_bound(SEXP init_valSEXP, SEXP xSEXP, SEXP h_estSEXP, SEXP combosSEXP, SEXP boundSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const arma::colvec& >::type init_val(init_valSEXP);
Rcpp::traits::input_parameter< arma::mat& >::type x(xSEXP);
Rcpp::traits::input_parameter< arma::mat& >::type h_est(h_estSEXP);
Rcpp::traits::input_parameter< arma::mat& >::type combos(combosSEXP);
Rcpp::traits::input_parameter< double& >::type bound(boundSEXP);
rcpp_result_gen = Rcpp::wrap(func_to_optim_bound(init_val, x, h_est, combos, bound));
return rcpp_result_gen;
END_RCPP
}
// optim_rcpp_bound
arma::vec optim_rcpp_bound(const arma::vec& init_val, arma::mat& x, arma::mat& h_est, arma::mat& combos, double& bound);
RcppExport SEXP _CLIMB_optim_rcpp_bound(SEXP init_valSEXP, SEXP xSEXP, SEXP h_estSEXP, SEXP combosSEXP, SEXP boundSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const arma::vec& >::type init_val(init_valSEXP);
Rcpp::traits::input_parameter< arma::mat& >::type x(xSEXP);
Rcpp::traits::input_parameter< arma::mat& >::type h_est(h_estSEXP);
Rcpp::traits::input_parameter< arma::mat& >::type combos(combosSEXP);
Rcpp::traits::input_parameter< double& >::type bound(boundSEXP);
rcpp_result_gen = Rcpp::wrap(optim_rcpp_bound(init_val, x, h_est, combos, bound));
return rcpp_result_gen;
END_RCPP
}
// cfconstr_pgmm
Rcpp::List cfconstr_pgmm(arma::mat& x, arma::rowvec prop, arma::mat mu, arma::mat sigma, double rho, arma::mat combos, int k, arma::rowvec df, int lambda, int citermax, double tol, unsigned int LASSO, double bound);
RcppExport SEXP _CLIMB_cfconstr_pgmm(SEXP xSEXP, SEXP propSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP rhoSEXP, SEXP combosSEXP, SEXP kSEXP, SEXP dfSEXP, SEXP lambdaSEXP, SEXP citermaxSEXP, SEXP tolSEXP, SEXP LASSOSEXP, SEXP boundSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< arma::mat& >::type x(xSEXP);
Rcpp::traits::input_parameter< arma::rowvec >::type prop(propSEXP);
Rcpp::traits::input_parameter< arma::mat >::type mu(muSEXP);
Rcpp::traits::input_parameter< arma::mat >::type sigma(sigmaSEXP);
Rcpp::traits::input_parameter< double >::type rho(rhoSEXP);
Rcpp::traits::input_parameter< arma::mat >::type combos(combosSEXP);
Rcpp::traits::input_parameter< int >::type k(kSEXP);
Rcpp::traits::input_parameter< arma::rowvec >::type df(dfSEXP);
Rcpp::traits::input_parameter< int >::type lambda(lambdaSEXP);
Rcpp::traits::input_parameter< int >::type citermax(citermaxSEXP);
Rcpp::traits::input_parameter< double >::type tol(tolSEXP);
Rcpp::traits::input_parameter< unsigned int >::type LASSO(LASSOSEXP);
Rcpp::traits::input_parameter< double >::type bound(boundSEXP);
rcpp_result_gen = Rcpp::wrap(cfconstr_pgmm(x, prop, mu, sigma, rho, combos, k, df, lambda, citermax, tol, LASSO, bound));
return rcpp_result_gen;
END_RCPP
}
// cduvnorm
arma::colvec cduvnorm(arma::colvec x, double mu, double sigma);
RcppExport SEXP _CLIMB_cduvnorm(SEXP xSEXP, SEXP muSEXP, SEXP sigmaSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< arma::colvec >::type x(xSEXP);
Rcpp::traits::input_parameter< double >::type mu(muSEXP);
Rcpp::traits::input_parameter< double >::type sigma(sigmaSEXP);
rcpp_result_gen = Rcpp::wrap(cduvnorm(x, mu, sigma));
return rcpp_result_gen;
END_RCPP
}
// cmarg_ll_gmm
double cmarg_ll_gmm(arma::mat& z, arma::mat mu, arma::mat sigma, arma::rowvec prop, arma::mat combos, int k);
RcppExport SEXP _CLIMB_cmarg_ll_gmm(SEXP zSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP propSEXP, SEXP combosSEXP, SEXP kSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< arma::mat& >::type z(zSEXP);
Rcpp::traits::input_parameter< arma::mat >::type mu(muSEXP);
Rcpp::traits::input_parameter< arma::mat >::type sigma(sigmaSEXP);
Rcpp::traits::input_parameter< arma::rowvec >::type prop(propSEXP);
Rcpp::traits::input_parameter< arma::mat >::type combos(combosSEXP);
Rcpp::traits::input_parameter< int >::type k(kSEXP);
rcpp_result_gen = Rcpp::wrap(cmarg_ll_gmm(z, mu, sigma, prop, combos, k));
return rcpp_result_gen;
END_RCPP
}
// cll_gmm
double cll_gmm(arma::mat& z, arma::mat mu, arma::mat sigma, double rho, arma::rowvec prop, arma::mat combos, int k);
RcppExport SEXP _CLIMB_cll_gmm(SEXP zSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP rhoSEXP, SEXP propSEXP, SEXP combosSEXP, SEXP kSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< arma::mat& >::type z(zSEXP);
Rcpp::traits::input_parameter< arma::mat >::type mu(muSEXP);
Rcpp::traits::input_parameter< arma::mat >::type sigma(sigmaSEXP);
Rcpp::traits::input_parameter< double >::type rho(rhoSEXP);
Rcpp::traits::input_parameter< arma::rowvec >::type prop(propSEXP);
Rcpp::traits::input_parameter< arma::mat >::type combos(combosSEXP);
Rcpp::traits::input_parameter< int >::type k(kSEXP);
rcpp_result_gen = Rcpp::wrap(cll_gmm(z, mu, sigma, rho, prop, combos, k));
return rcpp_result_gen;
END_RCPP
}
// get_mu_optim
arma::colvec get_mu_optim(arma::mat mu_in, arma::mat combos);
RcppExport SEXP _CLIMB_get_mu_optim(SEXP mu_inSEXP, SEXP combosSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< arma::mat >::type mu_in(mu_inSEXP);
Rcpp::traits::input_parameter< arma::mat >::type combos(combosSEXP);
rcpp_result_gen = Rcpp::wrap(get_mu_optim(mu_in, combos));
return rcpp_result_gen;
END_RCPP
}
// func_to_optim0
double func_to_optim0(const arma::colvec& init_val, const arma::mat& x, const arma::mat& h_est, const arma::mat& combos, const int& a, const arma::uvec& negidx);
RcppExport SEXP _CLIMB_func_to_optim0(SEXP init_valSEXP, SEXP xSEXP, SEXP h_estSEXP, SEXP combosSEXP, SEXP aSEXP, SEXP negidxSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const arma::colvec& >::type init_val(init_valSEXP);
Rcpp::traits::input_parameter< const arma::mat& >::type x(xSEXP);
Rcpp::traits::input_parameter< const arma::mat& >::type h_est(h_estSEXP);
Rcpp::traits::input_parameter< const arma::mat& >::type combos(combosSEXP);
Rcpp::traits::input_parameter< const int& >::type a(aSEXP);
Rcpp::traits::input_parameter< const arma::uvec& >::type negidx(negidxSEXP);
rcpp_result_gen = Rcpp::wrap(func_to_optim0(init_val, x, h_est, combos, a, negidx));
return rcpp_result_gen;
END_RCPP
}
// optim0_rcpp
arma::vec optim0_rcpp(const arma::vec& init_val, arma::mat& x, arma::mat& h_est, arma::mat& combos, int& a, arma::uvec& negidx);
RcppExport SEXP _CLIMB_optim0_rcpp(SEXP init_valSEXP, SEXP xSEXP, SEXP h_estSEXP, SEXP combosSEXP, SEXP aSEXP, SEXP negidxSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const arma::vec& >::type init_val(init_valSEXP);
Rcpp::traits::input_parameter< arma::mat& >::type x(xSEXP);
Rcpp::traits::input_parameter< arma::mat& >::type h_est(h_estSEXP);
Rcpp::traits::input_parameter< arma::mat& >::type combos(combosSEXP);
Rcpp::traits::input_parameter< int& >::type a(aSEXP);
Rcpp::traits::input_parameter< arma::uvec& >::type negidx(negidxSEXP);
rcpp_result_gen = Rcpp::wrap(optim0_rcpp(init_val, x, h_est, combos, a, negidx));
return rcpp_result_gen;
END_RCPP
}
// func_to_optim0_bound
double func_to_optim0_bound(const arma::colvec& init_val, const arma::mat& x, const arma::mat& h_est, const arma::mat& combos, const int& a, const arma::uvec& negidx, double& bound);
RcppExport SEXP _CLIMB_func_to_optim0_bound(SEXP init_valSEXP, SEXP xSEXP, SEXP h_estSEXP, SEXP combosSEXP, SEXP aSEXP, SEXP negidxSEXP, SEXP boundSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const arma::colvec& >::type init_val(init_valSEXP);
Rcpp::traits::input_parameter< const arma::mat& >::type x(xSEXP);
Rcpp::traits::input_parameter< const arma::mat& >::type h_est(h_estSEXP);
Rcpp::traits::input_parameter< const arma::mat& >::type combos(combosSEXP);
Rcpp::traits::input_parameter< const int& >::type a(aSEXP);
Rcpp::traits::input_parameter< const arma::uvec& >::type negidx(negidxSEXP);
Rcpp::traits::input_parameter< double& >::type bound(boundSEXP);
rcpp_result_gen = Rcpp::wrap(func_to_optim0_bound(init_val, x, h_est, combos, a, negidx, bound));
return rcpp_result_gen;
END_RCPP
}
// optim0_rcpp_bound
arma::vec optim0_rcpp_bound(const arma::vec& init_val, arma::mat& x, arma::mat& h_est, arma::mat& combos, int& a, arma::uvec& negidx, double& bound);
RcppExport SEXP _CLIMB_optim0_rcpp_bound(SEXP init_valSEXP, SEXP xSEXP, SEXP h_estSEXP, SEXP combosSEXP, SEXP aSEXP, SEXP negidxSEXP, SEXP boundSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const arma::vec& >::type init_val(init_valSEXP);
Rcpp::traits::input_parameter< arma::mat& >::type x(xSEXP);
Rcpp::traits::input_parameter< arma::mat& >::type h_est(h_estSEXP);
Rcpp::traits::input_parameter< arma::mat& >::type combos(combosSEXP);
Rcpp::traits::input_parameter< int& >::type a(aSEXP);
Rcpp::traits::input_parameter< arma::uvec& >::type negidx(negidxSEXP);
Rcpp::traits::input_parameter< double& >::type bound(boundSEXP);
rcpp_result_gen = Rcpp::wrap(optim0_rcpp_bound(init_val, x, h_est, combos, a, negidx, bound));
return rcpp_result_gen;
END_RCPP
}
// cfconstr0_pGMM
Rcpp::List cfconstr0_pGMM(arma::mat& x, arma::rowvec prop, arma::mat mu, arma::mat sigma, double rho, arma::mat combos, int k, arma::rowvec df, int lambda, int citermax, double tol, unsigned int LASSO, double bound);
RcppExport SEXP _CLIMB_cfconstr0_pGMM(SEXP xSEXP, SEXP propSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP rhoSEXP, SEXP combosSEXP, SEXP kSEXP, SEXP dfSEXP, SEXP lambdaSEXP, SEXP citermaxSEXP, SEXP tolSEXP, SEXP LASSOSEXP, SEXP boundSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< arma::mat& >::type x(xSEXP);
Rcpp::traits::input_parameter< arma::rowvec >::type prop(propSEXP);
Rcpp::traits::input_parameter< arma::mat >::type mu(muSEXP);
Rcpp::traits::input_parameter< arma::mat >::type sigma(sigmaSEXP);
Rcpp::traits::input_parameter< double >::type rho(rhoSEXP);
Rcpp::traits::input_parameter< arma::mat >::type combos(combosSEXP);
Rcpp::traits::input_parameter< int >::type k(kSEXP);
Rcpp::traits::input_parameter< arma::rowvec >::type df(dfSEXP);
Rcpp::traits::input_parameter< int >::type lambda(lambdaSEXP);
Rcpp::traits::input_parameter< int >::type citermax(citermaxSEXP);
Rcpp::traits::input_parameter< double >::type tol(tolSEXP);
Rcpp::traits::input_parameter< unsigned int >::type LASSO(LASSOSEXP);
Rcpp::traits::input_parameter< double >::type bound(boundSEXP);
rcpp_result_gen = Rcpp::wrap(cfconstr0_pGMM(x, prop, mu, sigma, rho, combos, k, df, lambda, citermax, tol, LASSO, bound));
return rcpp_result_gen;
END_RCPP
}
static const R_CallMethodDef CallEntries[] = {
{"_CLIMB_cgetPaths", (DL_FUNC) &_CLIMB_cgetPaths, 1},
{"_CLIMB_crowMatch", (DL_FUNC) &_CLIMB_crowMatch, 2},
{"_CLIMB_get_list_names", (DL_FUNC) &_CLIMB_get_list_names, 1},
{"_CLIMB_cpaste0", (DL_FUNC) &_CLIMB_cpaste0, 1},
{"_CLIMB_cstr_split", (DL_FUNC) &_CLIMB_cstr_split, 2},
{"_CLIMB_trans_func", (DL_FUNC) &_CLIMB_trans_func, 1},
{"_CLIMB_caccept", (DL_FUNC) &_CLIMB_caccept, 2},
{"_CLIMB_cget_prior_count", (DL_FUNC) &_CLIMB_cget_prior_count, 6},
{"_CLIMB_creduce_by_hamming", (DL_FUNC) &_CLIMB_creduce_by_hamming, 4},
{"_CLIMB_cget_true_assoc_idx", (DL_FUNC) &_CLIMB_cget_true_assoc_idx, 2},
{"_CLIMB_cassociate", (DL_FUNC) &_CLIMB_cassociate, 3},
{"_CLIMB_abs3", (DL_FUNC) &_CLIMB_abs3, 1},
{"_CLIMB_SCAD_1d", (DL_FUNC) &_CLIMB_SCAD_1d, 4},
{"_CLIMB_double_SCAD_1d", (DL_FUNC) &_CLIMB_double_SCAD_1d, 3},
{"_CLIMB_SCAD", (DL_FUNC) &_CLIMB_SCAD, 4},
{"_CLIMB_double_SCAD", (DL_FUNC) &_CLIMB_double_SCAD, 3},
{"_CLIMB_Mahalanobis", (DL_FUNC) &_CLIMB_Mahalanobis, 3},
{"_CLIMB_cdmvnorm", (DL_FUNC) &_CLIMB_cdmvnorm, 3},
{"_CLIMB_cget_constr_sigma", (DL_FUNC) &_CLIMB_cget_constr_sigma, 4},
{"_CLIMB_func_to_optim", (DL_FUNC) &_CLIMB_func_to_optim, 4},
{"_CLIMB_optim_rcpp", (DL_FUNC) &_CLIMB_optim_rcpp, 4},
{"_CLIMB_func_to_optim_bound", (DL_FUNC) &_CLIMB_func_to_optim_bound, 5},
{"_CLIMB_optim_rcpp_bound", (DL_FUNC) &_CLIMB_optim_rcpp_bound, 5},
{"_CLIMB_cfconstr_pgmm", (DL_FUNC) &_CLIMB_cfconstr_pgmm, 13},
{"_CLIMB_cduvnorm", (DL_FUNC) &_CLIMB_cduvnorm, 3},
{"_CLIMB_cmarg_ll_gmm", (DL_FUNC) &_CLIMB_cmarg_ll_gmm, 6},
{"_CLIMB_cll_gmm", (DL_FUNC) &_CLIMB_cll_gmm, 7},
{"_CLIMB_get_mu_optim", (DL_FUNC) &_CLIMB_get_mu_optim, 2},
{"_CLIMB_func_to_optim0", (DL_FUNC) &_CLIMB_func_to_optim0, 6},
{"_CLIMB_optim0_rcpp", (DL_FUNC) &_CLIMB_optim0_rcpp, 6},
{"_CLIMB_func_to_optim0_bound", (DL_FUNC) &_CLIMB_func_to_optim0_bound, 7},
{"_CLIMB_optim0_rcpp_bound", (DL_FUNC) &_CLIMB_optim0_rcpp_bound, 7},
{"_CLIMB_cfconstr0_pGMM", (DL_FUNC) &_CLIMB_cfconstr0_pGMM, 13},
{NULL, NULL, 0}
};
RcppExport void R_init_CLIMB(DllInfo *dll) {
R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
R_useDynamicSymbols(dll, FALSE);
}
| 49.439306 | 233 | 0.735921 | hillarykoch |
d6591b7d7273ba95880cb7a69c1c6087505dc037 | 2,025 | cc | C++ | components/arc/compat_mode/overlay_dialog.cc | DamieFC/chromium | 54ce2d3c77723697efd22cfdb02aea38f9dfa25c | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 1 | 2020-10-18T02:33:40.000Z | 2020-10-18T02:33:40.000Z | components/arc/compat_mode/overlay_dialog.cc | DamieFC/chromium | 54ce2d3c77723697efd22cfdb02aea38f9dfa25c | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 3 | 2021-05-17T16:28:52.000Z | 2021-05-21T22:42:22.000Z | components/arc/compat_mode/overlay_dialog.cc | DamieFC/chromium | 54ce2d3c77723697efd22cfdb02aea38f9dfa25c | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | // Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/arc/compat_mode/overlay_dialog.h"
#include "components/arc/compat_mode/style/arc_color_provider.h"
#include "components/exo/shell_surface_base.h"
#include "components/exo/shell_surface_util.h"
#include "ui/views/background.h"
#include "ui/views/layout/flex_layout_view.h"
namespace arc {
namespace {
std::unique_ptr<views::View> MakeOverlayDialogContainerView(
std::unique_ptr<views::View> dialog_view) {
const SkColor kScrimColor = GetShieldLayerColor(ShieldLayerType::kShield60);
auto container = views::Builder<views::FlexLayoutView>()
.SetInteriorMargin(gfx::Insets(0, 32))
.SetMainAxisAlignment(views::LayoutAlignment::kCenter)
.SetCrossAxisAlignment(views::LayoutAlignment::kCenter)
.SetBackground(views::CreateSolidBackground(kScrimColor))
.Build();
dialog_view->SetProperty(
views::kFlexBehaviorKey,
views::FlexSpecification(views::MinimumFlexSizeRule::kScaleToZero));
container->AddChildView(std::move(dialog_view));
return container;
}
} // namespace
void ShowOverlayDialog(aura::Window* base_window,
std::unique_ptr<views::View> dialog_view) {
auto* shell_surface_base = exo::GetShellSurfaceBaseForWindow(base_window);
if (!shell_surface_base || shell_surface_base->HasOverlay())
return;
exo::ShellSurfaceBase::OverlayParams params(
MakeOverlayDialogContainerView(std::move(dialog_view)));
params.translucent = true;
shell_surface_base->AddOverlay(std::move(params));
}
void CloseOverlayDialogIfAny(aura::Window* base_window) {
auto* shell_surface_base = exo::GetShellSurfaceBaseForWindow(base_window);
if (shell_surface_base && shell_surface_base->HasOverlay())
shell_surface_base->RemoveOverlay();
}
} // namespace arc
| 35.526316 | 80 | 0.725432 | DamieFC |
d6593134ae4e81ea2bbfb8998ab503d06aee4013 | 3,169 | cpp | C++ | examples/jack-analyzer/cpp/main.cpp | lierdakil/parser-generator | 0d3f8903e52d0671388d11c7f660957dbb7cc159 | [
"MIT"
] | 3 | 2020-11-27T20:18:26.000Z | 2021-05-24T20:41:52.000Z | examples/jack-analyzer/cpp/main.cpp | lierdakil/alpaca-parser-generator | eca53c6de7afa397af0e75e146a08f7e4665ed53 | [
"MIT"
] | null | null | null | examples/jack-analyzer/cpp/main.cpp | lierdakil/alpaca-parser-generator | eca53c6de7afa397af0e75e146a08f7e4665ed53 | [
"MIT"
] | null | null | null | #include "lexer.h"
#include "parser.h"
#include <any>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <regex>
#include <string>
#define debug false
std::string tokenClass(TokenType t) {
switch (t) {
case TokenType::eof:
return "";
case TokenType::Tok_binOp:
return "symbol";
case TokenType::Tok_c:
return "symbol";
case TokenType::Tok_class:
return "keyword";
case TokenType::Tok_do:
return "keyword";
case TokenType::Tok_dot:
return "symbol";
case TokenType::Tok_else:
return "keyword";
case TokenType::Tok_equals:
return "symbol";
case TokenType::Tok_identifier:
return "identifier";
case TokenType::Tok_if:
return "keyword";
case TokenType::Tok_integerConstant:
return "integerConstant";
case TokenType::Tok_lb:
return "symbol";
case TokenType::Tok_lbr:
return "symbol";
case TokenType::Tok_let:
return "keyword";
case TokenType::Tok_lp:
return "symbol";
case TokenType::Tok_methodCategory:
return "keyword";
case TokenType::Tok_minus:
return "symbol";
case TokenType::Tok_not:
return "symbol";
case TokenType::Tok_primType:
return "keyword";
case TokenType::Tok_primVal:
return "keyword";
case TokenType::Tok_propType:
return "keyword";
case TokenType::Tok_rb:
return "symbol";
case TokenType::Tok_rbr:
return "symbol";
case TokenType::Tok_return:
return "keyword";
case TokenType::Tok_rp:
return "symbol";
case TokenType::Tok_sc:
return "symbol";
case TokenType::Tok_stringConstant:
return "stringConstant";
case TokenType::Tok_var:
return "keyword";
case TokenType::Tok_void:
return "keyword";
case TokenType::Tok_while:
return "keyword";
}
}
void analyzeFile(std::string fn) {
std::cout << "<!-- Analyzing " << fn << " #-->\n";
// Lexer part
std::ifstream t(fn);
std::string content((std::istreambuf_iterator<char>(t)),
std::istreambuf_iterator<char>());
auto lex = new Lexer(content, debug);
auto [tok, s] = lex->getNextToken();
std::cout << "<tokens>\n";
while (tok != TokenType::eof) {
auto t = tokenClass(tok);
auto str = std::any_cast<std::string>(s);
if (t == "symbol")
str = escape(str);
else if (t == "stringConstant") {
auto a = str.begin();
a++;
auto b = str.end();
b--;
str = std::string(a, b);
}
std::cout << "<" << t << ">" << str << "</" << t << ">\n";
auto x = lex->getNextToken();
tok = x.first;
s = x.second;
}
std::cout << "</tokens>\n";
// Parser part
auto lex1 = new Lexer(content, debug);
auto parser = new Parser(lex1, debug);
std::cout << parser->parse();
}
int main(int argc, char *argv[]) {
if (argc <= 1) {
std::cerr << "argument required\n";
return 1;
}
auto fn = argv[1];
const std::string ext = ".jack";
if (std::filesystem::is_directory(fn)) {
for (auto &i : std::filesystem::directory_iterator(fn)) {
if (std::equal(ext.rbegin(), ext.rend(), i.path().string().rbegin())) {
analyzeFile(i.path());
}
}
} else {
analyzeFile(fn);
}
return 0;
}
| 24.19084 | 77 | 0.614705 | lierdakil |
d65f0bc53d20d23240b464d8c89186063601398c | 8,841 | cc | C++ | Validation/RecoPixelVertexing/test/PixelTrackVal.cc | PKUfudawei/cmssw | 8fbb5ce74398269c8a32956d7c7943766770c093 | [
"Apache-2.0"
] | 1 | 2018-08-28T16:51:36.000Z | 2018-08-28T16:51:36.000Z | Validation/RecoPixelVertexing/test/PixelTrackVal.cc | PKUfudawei/cmssw | 8fbb5ce74398269c8a32956d7c7943766770c093 | [
"Apache-2.0"
] | 25 | 2016-06-24T20:55:32.000Z | 2022-02-01T19:24:45.000Z | Validation/RecoPixelVertexing/test/PixelTrackVal.cc | PKUfudawei/cmssw | 8fbb5ce74398269c8a32956d7c7943766770c093 | [
"Apache-2.0"
] | 8 | 2016-03-25T07:17:43.000Z | 2021-07-08T17:11:21.000Z | #include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Utilities/interface/isFinite.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "DataFormats/Math/interface/deltaR.h"
#include "HepMC/GenEvent.h"
#include "HepMC/GenVertex.h"
#include "SimDataFormats/Track/interface/SimTrack.h"
#include "SimDataFormats/Track/interface/SimTrackContainer.h"
#include "SimDataFormats/Vertex/interface/SimVertex.h"
#include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
#include "TFile.h"
#include "TObjArray.h"
#include <TH1.h>
#include <cmath>
#include <iostream>
#include <vector>
template <class T>
T sqr(T t) {
return t * t;
}
class PixelTrackVal : public edm::one::EDAnalyzer<> {
public:
explicit PixelTrackVal(const edm::ParameterSet &conf);
~PixelTrackVal() override;
void beginJob() override;
void analyze(const edm::Event &ev, const edm::EventSetup &es) override;
void endJob() override;
private:
int verbose_;
std::string file_;
TObjArray hList;
edm::EDGetTokenT<reco::TrackCollection> trackCollectionToken_;
edm::EDGetTokenT<edm::SimTrackContainer> simTrackContainerToken_;
edm::EDGetTokenT<edm::SimVertexContainer> simVertexContainerToken_;
};
PixelTrackVal::PixelTrackVal(const edm::ParameterSet &conf)
: verbose_(conf.getUntrackedParameter<unsigned int>("Verbosity",
0)) // How noisy?
,
file_(conf.getUntrackedParameter<std::string>("HistoFile", "pixelTrackHistos.root")),
hList(0),
trackCollectionToken_(
consumes<reco::TrackCollection>(edm::InputTag(conf.getParameter<std::string>("TrackCollection")))),
simTrackContainerToken_(consumes<edm::SimTrackContainer>(conf.getParameter<edm::InputTag>("simG4"))),
simVertexContainerToken_(consumes<edm::SimVertexContainer>(conf.getParameter<edm::InputTag>("simG4"))) {
edm::LogInfo("PixelTrackVal") << " CTOR";
}
PixelTrackVal::~PixelTrackVal() { edm::LogInfo("PixelTrackVal") << " DTOR"; }
void PixelTrackVal::beginJob() {
hList.Add(new TH1F("h_Pt", "h_Pt", 31, -2., 1.2));
hList.Add(new TH1F("h_dR", "h_dR", 30, 0., 0.06));
hList.Add(new TH1F("h_TIP", "h_TIP", 100, -0.1, 0.1));
hList.Add(new TH1F("h_VtxZ", "h_VtxZ", 100, -0.1, 0.1));
hList.Add(new TH1F("h_VtxZ_Pull", "h_VtxZ_Pull", 80, 0., 8));
hList.Add(new TH1F("h_Nan", "Illegal values for x,y,z,xx,xy,xz,yy,yz,zz", 9, 0.5, 9.5));
hList.SetOwner();
}
void PixelTrackVal::analyze(const edm::Event &ev, const edm::EventSetup &es) {
LogTrace("PixelTrackVal") << "*** PixelTrackVal, analyze event: " << ev.id() << std::endl;
//------------------------ simulated tracks
edm::Handle<reco::TrackCollection> trackCollection;
ev.getByToken(trackCollectionToken_, trackCollection);
const reco::TrackCollection tracks = *(trackCollection.product());
typedef reco::TrackCollection::const_iterator IT;
if (verbose_ > 0) {
// std::cout << *(trackCollection.provenance()) << std::endl;
edm::LogInfo("PixelTrackVal") << "Reconstructed " << tracks.size() << " tracks" << std::endl;
}
for (unsigned int idx = 0; idx < tracks.size(); idx++) {
const reco::Track *it = &tracks[idx];
TH1 *h = static_cast<TH1 *>(hList.FindObject("h_Nan"));
h->Fill(1., edm::isNotFinite(it->momentum().x()) * 1.);
h->Fill(2., edm::isNotFinite(it->momentum().y()) * 1.);
h->Fill(3., edm::isNotFinite(it->momentum().z()) * 1.);
bool problem = false;
int index = 3;
for (int i = 0; i != 3; i++) {
for (int j = i; j != 3; j++) {
index++;
static_cast<TH1 *>(hList.FindObject("h_Nan"))->Fill(index * 1., edm::isNotFinite(it->covariance(i, j)) * 1.);
if (edm::isNotFinite(it->covariance(i, j)))
problem = true;
// in addition, diagonal element must be positive
if (j == i && it->covariance(i, j) < 0) {
static_cast<TH1 *>(hList.FindObject("h_Nan"))->Fill(index * 1., 1.);
problem = true;
}
}
}
if (problem)
edm::LogInfo("PixelTrackVal") << " *** PROBLEM **" << std::endl;
if (verbose_ > 0) {
edm::LogInfo("PixelTrackVal") << "\tmomentum: " << tracks[idx].momentum() << "\tPT: " << tracks[idx].pt()
<< std::endl;
edm::LogInfo("PixelTrackVal") << "\tvertex: " << tracks[idx].vertex() << "\tTIP: " << tracks[idx].d0() << " +- "
<< tracks[idx].d0Error() << "\tZ0: " << tracks[idx].dz() << " +- "
<< tracks[idx].dzError() << std::endl;
edm::LogInfo("PixelTrackVal") << "\tcharge: " << tracks[idx].charge() << std::endl;
}
}
//------------------------ simulated vertices and tracks
edm::Handle<edm::SimVertexContainer> simVtcs;
ev.getByToken(simVertexContainerToken_, simVtcs);
// edm::LogInfo("PixelTrackVal") << "SimVertex " << simVtcs->size() << std::endl;
// for(edm::SimVertexContainer::const_iterator v=simVtcs->begin();
// v!=simVtcs->end(); ++v){
// edm::LogInfo("PixelTrackVal") << "simvtx " << std::setw(10) << std::setprecision(3)
// << v->position().x() << " " << v->position().y() << " " <<
// v->position().z() << " "
// << v->parentIndex() << " " << v->noParent() << " " << std::endl; }
edm::Handle<edm::SimTrackContainer> simTrks;
ev.getByToken(simTrackContainerToken_, simTrks);
edm::LogInfo("PixelTrackVal") << "simtrks " << simTrks->size() << std::endl;
//-------------- association
// matching cuts from Marcin
float detaMax = 0.012;
float dRMax = 0.025;
typedef edm::SimTrackContainer::const_iterator IP;
for (IP p = simTrks->begin(); p != simTrks->end(); p++) {
if ((*p).noVertex())
continue;
if ((*p).type() == -99)
continue;
if ((*p).vertIndex() != 0)
continue;
math::XYZVector mom_gen((*p).momentum().x(), (*p).momentum().y(), (*p).momentum().z());
float phi_gen = (*p).momentum().phi();
// float pt_gen = (*p).momentum().Pt();
float pt_gen = sqrt((*p).momentum().x() * (*p).momentum().x() + (*p).momentum().y() * (*p).momentum().y());
float eta_gen = (*p).momentum().eta();
math::XYZTLorentzVectorD vtx((*simVtcs)[p->vertIndex()].position().x(),
(*simVtcs)[p->vertIndex()].position().y(),
(*simVtcs)[p->vertIndex()].position().z(),
(*simVtcs)[p->vertIndex()].position().e());
float z_gen = vtx.z();
// cout << "\tmomentum: " << (*p).momentum()
// <<" vtx: "<<(*p).vertIndex()<<" type: "<<(*p).type()
// << endl;
typedef reco::TrackCollection::const_iterator IT;
for (IT it = tracks.begin(); it != tracks.end(); it++) {
math::XYZVector mom_rec = (*it).momentum();
float phi_rec = (*it).momentum().phi();
float pt_rec = (*it).pt();
float z_rec = (*it).vertex().z();
float eta_rec = (*it).momentum().eta();
// float chi2 = (*it).chi2();
float dphi = phi_gen - phi_rec;
while (dphi > M_PI)
dphi -= 2 * M_PI;
while (dphi < -M_PI)
dphi += 2 * M_PI;
float deta = eta_gen - eta_rec;
float dz = z_gen - z_rec;
double dR = deltaR(mom_gen, mom_rec);
//
// matched track
//
if (fabs(deta) < 0.3 && fabs(dphi) < 0.3)
static_cast<TH1 *>(hList.FindObject("h_dR"))->Fill(dR);
if (fabs(deta) < detaMax && dR < dRMax) {
static_cast<TH1 *>(hList.FindObject("h_Pt"))->Fill((pt_gen - pt_rec) / pt_gen);
static_cast<TH1 *>(hList.FindObject("h_TIP"))->Fill(it->d0());
static_cast<TH1 *>(hList.FindObject("h_VtxZ"))->Fill(dz);
static_cast<TH1 *>(hList.FindObject("h_VtxZ_Pull"))->Fill(fabs(dz / it->dzError()));
}
}
}
}
void PixelTrackVal::endJob() {
// Make my little tree
TFile f(file_.c_str(), "RECREATE");
hList.Write();
f.Close();
}
// float PixelTrackVal::deltaRR(const math::XYZVector & m1, const
// math::XYZVector & m2) const
//{
// float dphi = m1.phi()-m2.phi();
// while (dphi > 2*M_PI) dphi-=2*M_PI;
// while (dphi < -2*M_PI) dphi+=2*M_PI;
// float deta = m1.eta() - m2.eta();
// float dr = sqrt( sqr(dphi) + sqr(deta));
// return dr;
//}
DEFINE_FWK_MODULE(PixelTrackVal);
| 39.64574 | 118 | 0.598462 | PKUfudawei |
d66816f61036fa557cbba4ecf6912b1e6481e942 | 2,635 | hpp | C++ | src/log.hpp | j-martina/machinate | 145d8df7a6ccf085a625805dc745f5afd9f5c9c6 | [
"MIT"
] | null | null | null | src/log.hpp | j-martina/machinate | 145d8df7a6ccf085a625805dc745f5afd9f5c9c6 | [
"MIT"
] | null | null | null | src/log.hpp | j-martina/machinate | 145d8df7a6ccf085a625805dc745f5afd9f5c9c6 | [
"MIT"
] | null | null | null | /**
* @file log.hpp
* @brief Quill-based logger, shortcut macros, related symbols.
*/
#pragma once
#include "preproc.hpp"
#include <quill/Quill.h>
namespace mxn
{
extern quill::Logger* qlog;
/**
* @brief Prepare for logging via Quill.
*
* Calls `quill::enable_console_colours()`, `quill::start()`,
* and `quill::preallocate()` before finally constructing handlers and the
* logger object.
*/
void log_init(std::initializer_list<quill::Handler*>);
} // namespace mxn
/**
* @brief Print to cout and console; prepend with "INFO: "
* @remark Use to record information from the average user's runtime wherever
* that information may be useful to developer/modder debugging.
*/
#define MXN_LOG(msg) LOG_INFO(mxn::qlog, "{}", msg)
/**
* @brief Print to cout and console; prepend with "WARN: "
* @remark Use to inform that something undesirable has happened but the user's
* experience is unlikely to be affected.
*/
#define MXN_WARN(msg) LOG_WARNING(mxn::qlog, "{}", msg)
/**
* @brief Print to cout and console; prepend with "ERROR: "
* @remark Use to inform that an error has occurred but the application's state
* is recoverable.
*/
#define MXN_ERR(msg) LOG_ERROR(mxn::qlog, "{}", msg)
/**
* @brief Print to cout and console; prepend with "CRITICAL: "
* @remark Use to inform that the application is in a compromised state, and is
* either liable to crash or not capable of being useful anymore.
*/
#define MXN_CRIT(msg) LOG_CRITICAL(mxn::qlog, "{}", msg)
/** @brief Like `MXN_LOG`, but allows {fmt}-style variadic formatting. */
#define MXN_LOGF(msg, ...) LOG_INFO(mxn::qlog, msg, __VA_ARGS__)
/** @brief Like `MXN_WARN`, but allows {fmt}-style variadic formatting. */
#define MXN_WARNF(msg, ...) LOG_WARNING(mxn::qlog, msg, __VA_ARGS__)
/** @brief Like `MXN_ERR`, but allows {fmt}-style variadic formatting. */
#define MXN_ERRF(msg, ...) LOG_ERROR(mxn::qlog, msg, __VA_ARGS__)
/** @brief Like `MXN_CRIT`, but allows {fmt}-style variadic formatting. */
#define MXN_CRITF(msg, ...) LOG_CRITICAL(mxn::qlog, msg, __VA_ARGS__)
#ifndef NDEBUG
/**
* @brief Print to cout and console; prepend with "DEBUG: "
* @note Preprocessed away when `NDEBUG` is set (i.e., in the Release build).
* @remark Should only be used to generate a record of information which may be
* useful in future debugging efforts by developers or modders.
*/
#define MXN_DEBUG(msg) LOG_DEBUG(mxn::qlog, "{}", msg)
/** @brief Like `MXN_DEBUG`, but allows {fmt}-style variadic formatting. */
#define MXN_DEBUGF(msg, ...) LOG_DEBUG(mxn::qlog, msg, ##__VA_ARGS__)
#else
#define MXN_DEBUG(msg)
#define MXN_DEBUGF(msg, ...)
#endif | 34.220779 | 79 | 0.702467 | j-martina |
d66a421821157c81551727d26af2be86b80ceb6f | 612 | cpp | C++ | c++/77.cpp | Crazyokd/leetcode-solution | 3aed88651fec391a02aba490ce72454c6f9e5409 | [
"MIT"
] | 1 | 2022-02-26T04:56:00.000Z | 2022-02-26T04:56:00.000Z | c++/77.cpp | Crazyokd/leetcode-solution | 3aed88651fec391a02aba490ce72454c6f9e5409 | [
"MIT"
] | null | null | null | c++/77.cpp | Crazyokd/leetcode-solution | 3aed88651fec391a02aba490ce72454c6f9e5409 | [
"MIT"
] | null | null | null | #include<iostream>
using namespace std;
class Solution {
public:
int countPrimeSetBits(int left, int right) {
int res = 0;
for (int i = left; i <= right; i++) {
if (check(i)) res++;
}
return res;
}
bool check(int value) {
int cnt = 0;
for (int i = 0; pow(2, i) <= value; i++) {
if ((value >> i) & 1) cnt++;
}
if (cnt == 2 || cnt == 3 || cnt == 5 || cnt == 7 || cnt == 11 || cnt == 13 || cnt == 17 || cnt == 19) {
return true;
}
return false;
}
};
int main() {
return 0;
} | 20.4 | 111 | 0.423203 | Crazyokd |
69921e1b36c4cbb83f381fe26e9b561d61887926 | 516 | cpp | C++ | game/client/c_advisor.cpp | RoyaleNoir/manwich-oddyssey-src | c8873d137c0400540ea3671a3dabc26ed0bccbd9 | [
"Unlicense"
] | 2 | 2021-02-13T08:18:48.000Z | 2021-04-17T00:10:15.000Z | game/client/c_advisor.cpp | RoyaleNoir/manwich-oddyssey-src | c8873d137c0400540ea3671a3dabc26ed0bccbd9 | [
"Unlicense"
] | 21 | 2021-04-10T17:39:12.000Z | 2022-03-26T18:01:28.000Z | game/client/c_advisor.cpp | RoyaleNoir/manwich-oddyssey-src | c8873d137c0400540ea3671a3dabc26ed0bccbd9 | [
"Unlicense"
] | null | null | null | #include "cbase.h"
#include "c_ai_basenpc.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
class C_Advisor : public C_AI_BaseNPC
{
public:
DECLARE_CLASS( C_Advisor, C_AI_BaseNPC );
DECLARE_CLIENTCLASS();
C_Advisor();
virtual ~C_Advisor();
private:
C_Advisor( const C_Advisor & ); // not defined, not accessible
};
IMPLEMENT_CLIENTCLASS_DT(C_Advisor, DT_NPC_Advisor, CNPC_Advisor)
END_RECV_TABLE()
C_Advisor::C_Advisor()
{
}
C_Advisor::~C_Advisor()
{
}
| 15.176471 | 65 | 0.724806 | RoyaleNoir |
6994bda8c6a281a09a1f00812013746b998bb699 | 6,395 | cpp | C++ | src/mame/drivers/rf51w14cg.cpp | Robbbert/messui | 49b756e2140d8831bc81335298ee8c5471045e79 | [
"BSD-3-Clause"
] | 26 | 2015-03-31T06:25:51.000Z | 2021-12-14T09:29:04.000Z | src/mame/drivers/rf51w14cg.cpp | Robbbert/messui | 49b756e2140d8831bc81335298ee8c5471045e79 | [
"BSD-3-Clause"
] | null | null | null | src/mame/drivers/rf51w14cg.cpp | Robbbert/messui | 49b756e2140d8831bc81335298ee8c5471045e79 | [
"BSD-3-Clause"
] | 10 | 2015-03-27T05:45:51.000Z | 2022-02-04T06:57:36.000Z | // license:BSD-3-Clause
// copyright-holders:
/******************************************************************************
Skeleton driver for Recreativos Franco "RF51W14-CG".
"RF51W14-CG" is the legal registry name, the game commercial name is unknown.
TODO:
- Everything
________________________________________________________________
| ___J16_____ ___J17____ __J18__ _______________________ |
| | ······ · | | ···· ·· | | ·· · | | :::::::::::::::::::: | |
| ____ |
| __ __________ |___| ____ __________________ : <- JMP4
|| | | PIA 5 | |___| | RAM | |
||J| | OKI | ____ | M48T08/M48T18 | |
||1| | 82C55A | |___| |_________________| |
||5| |_________| __________________ : <- JMP3
||_| | LOW | : <- JMP2
| __ __________ ____________ | | |
||J| | PIA 4 | XTAL | Intel | |_________________| |
||11 | OKI | 32.000 |M80C188XL20| __________________ : <- JMP1
| __ | 82C55A | MHz | | | HIGH |__ |
||J| |_________| | | | ||J||
||1| |___________| |_________________||1||
||4| __________ ____ |9||
| __ | PIA 6 | ____ ____ ______ |___| |_||
||J| | OKI | HC573A HC573A |OKI | ____ __ |
||6| | 82C55A | 82C51A| |___| |J||
||_| |_________| __________________ ____ |8||
| __ _______ | SONIDO 2 | |___| |_||
|| |SW3->DIPSx4| | | __ |
||J| __________ |________________| |J||
||7| | PIA 3 | __________________ __________ |9||
||_| | OKI | | SONIDO 1 | |ULN2803A_| |_||
| __ | 82C55A | | | :: ________ __ |
|| | |_________| |________________| JMP8 |74HC238E| |J||
||J| _____ |5||
||4| __________ |____| __ |
|| | | PIA 1 | ___________ ......<-JMP10 |J||
||_| | OKI | | OKI | |1||
| __ | 82C55A | | M6376 | XTAL 9.8304 |2||
||J| |_________| |__________| MHz __ |
||2| _____SW2__ ____JMP7 RS232-2 RS232-1 ____ |J||
||0| |_DIPSx8__| HC4040 : :::: :::: |___| |1||
||_| __________ ____ ______ ____ ____ |0||
| __ | PIA 2 | |___| |OKI | |___| |___| __ |
||J| | OKI | ____ 82C51A| ____ |J||
||3| | 82C55A | |___| _ |___| |1||
|| | |_________| VOLUMEN->(_) _________ |3||
||_| |_LM380N_| |_||
| _______ ____________ ____________ ______ |
|SW1->DIPSx4| |___________| |___________| |_____| |
|_______________________________________________________________|
JPM7 = CLK/128 / CLK/64
*******************************************************************************/
#include "emu.h"
#include "cpu/i86/i186.h"
#include "sound/okim6376.h"
#include "speaker.h"
namespace
{
class rf51w14cg_state : public driver_device
{
public:
rf51w14cg_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag)
, m_maincpu(*this, "maincpu")
, m_okim6376(*this, "oki")
{
}
void rf51w14cg(machine_config &config);
protected:
required_device <cpu_device> m_maincpu;
required_device <okim6376_device> m_okim6376;
};
static INPUT_PORTS_START( rf51w14cg )
PORT_START("DSW1")
PORT_DIPUNKNOWN_DIPLOC(0x01, 0x01, "SW1:1")
PORT_DIPUNKNOWN_DIPLOC(0x02, 0x02, "SW1:2")
PORT_DIPUNKNOWN_DIPLOC(0x04, 0x04, "SW1:3")
PORT_DIPUNKNOWN_DIPLOC(0x08, 0x08, "SW1:4")
PORT_START("DSW2")
PORT_DIPUNKNOWN_DIPLOC(0x01, 0x01, "SW1:1")
PORT_DIPUNKNOWN_DIPLOC(0x02, 0x02, "SW1:2")
PORT_DIPUNKNOWN_DIPLOC(0x04, 0x04, "SW1:3")
PORT_DIPUNKNOWN_DIPLOC(0x08, 0x08, "SW1:4")
PORT_DIPUNKNOWN_DIPLOC(0x10, 0x10, "SW1:5")
PORT_DIPUNKNOWN_DIPLOC(0x20, 0x20, "SW1:6")
PORT_DIPUNKNOWN_DIPLOC(0x40, 0x40, "SW1:7")
PORT_DIPUNKNOWN_DIPLOC(0x80, 0x80, "SW1:8")
PORT_START("DSW3")
PORT_DIPUNKNOWN_DIPLOC(0x01, 0x01, "SW1:1")
PORT_DIPUNKNOWN_DIPLOC(0x02, 0x02, "SW1:2")
PORT_DIPUNKNOWN_DIPLOC(0x04, 0x04, "SW1:3")
PORT_DIPUNKNOWN_DIPLOC(0x08, 0x08, "SW1:4")
INPUT_PORTS_END
void rf51w14cg_state::rf51w14cg(machine_config &config)
{
I80188(config, m_maincpu, 32_MHz_XTAL / 2); // Intel N80C188XL-20, guess divisor
SPEAKER(config, "mono").front_center();
OKIM6376(config, m_okim6376, XTAL(9'830'400)/64).add_route(ALL_OUTPUTS, "mono", 1.0); // Frecuency divisor as per JMP7
}
// The board was found with the program ROMs sockets unpopulated and the M48T08 with the battery dead
ROM_START( rf51w14cg )
ROM_REGION( 0x100000, "maincpu", 0 )
ROM_LOAD( "high.bin", 0x00000, 0x80000, NO_DUMP )
ROM_LOAD( "low.bin", 0x80000, 0x80000, NO_DUMP )
ROM_REGION( 0x100000, "oki", 0 )
ROM_LOAD( "recreativos_franco_sonido-1_321dabf_01083c.u3", 0x00000, 0x80000, CRC(bd9bb391) SHA1(f08da81544e6b8c518634d081bf68d862b90c099) )
ROM_LOAD( "recreativos_franco_sonido-2_7c8bced_01083d.u4", 0x80000, 0x80000, CRC(cf8e7957) SHA1(5d30d7f15c1690b819e467fc308f12f97577b906) )
ROM_REGION( 0x2000, "nvram", 0 )
ROM_LOAD( "recreativos_franco_mod_rf51w14-cg_2003_m48t08.bin", 0x0000, 0x2000, NO_DUMP )
ROM_END
} // anonymous namespace
// YEAR NAME PARENT MACHINE INPUT CLASS INIT ROT COMPANY FULLNAME FLAGS
GAME( 2003, rf51w14cg, 0, rf51w14cg, rf51w14cg, rf51w14cg_state, empty_init, ROT0, "Recreativos Franco", "unknown Recreativos Franco slot machine (model RF51W14-CG)", MACHINE_IS_SKELETON_MECHANICAL )
| 46.007194 | 205 | 0.516497 | Robbbert |
69953ecd401a7ac62deaa84853f5c226ffadeddd | 1,409 | cpp | C++ | test/dioptre/application.cpp | tobscher/rts | 7f30faf6a13d309e4db828be8be3c05d28c05364 | [
"MIT"
] | 2 | 2015-05-14T16:07:30.000Z | 2015-07-27T21:08:48.000Z | test/dioptre/application.cpp | tobscher/rts | 7f30faf6a13d309e4db828be8be3c05d28c05364 | [
"MIT"
] | null | null | null | test/dioptre/application.cpp | tobscher/rts | 7f30faf6a13d309e4db828be8be3c05d28c05364 | [
"MIT"
] | null | null | null | #include <gtest/gtest.h>
#include "dioptre/application.h"
#include "test_object.h"
#include "another_test_object.h"
TEST(Application, IsRunning) {
char empty[1] = {0};
char *argv[] = {empty, 0};
int argc = 1;
dioptre::Application application(argc, argv);
EXPECT_FALSE(application.isRunning());
}
TEST(Application, Initialization) {
char empty[1] = {0};
char *argv[] = {empty, 0};
int argc = 1;
TestObject* object1 = new TestObject();
TestObject* object2 = new TestObject();
EXPECT_FALSE(object1->getIsInitialized());
EXPECT_FALSE(object2->getIsInitialized());
dioptre::Application application(argc, argv);
application.addObject(object1);
application.addObject(object2);
application.initialize();
EXPECT_TRUE(application.getIsInitialized());
EXPECT_TRUE(object1->getIsInitialized());
EXPECT_TRUE(object2->getIsInitialized());
}
TEST(Application, getObjectByName) {
char empty[1] = {0};
char *argv[] = {empty, 0};
int argc = 1;
TestObject* object1 = new TestObject();
AnotherTestObject* object2 = new AnotherTestObject();
dioptre::Application application(argc, argv);
application.addObject(object1);
application.addObject(object2);
EXPECT_TRUE(application.getObjectByName("test_object") == object1);
EXPECT_TRUE(application.getObjectByName("another_test_object") == object2);
EXPECT_TRUE(application.getObjectByName("foo") == nullptr);
}
| 26.092593 | 77 | 0.723208 | tobscher |
69960d798e7064a10ca53671299c21fce929820f | 841 | cpp | C++ | src/format.cpp | dashboardvision/aspose-php | e2931773cbb1f47ae4086d632faa3012bd952b99 | [
"MIT"
] | null | null | null | src/format.cpp | dashboardvision/aspose-php | e2931773cbb1f47ae4086d632faa3012bd952b99 | [
"MIT"
] | null | null | null | src/format.cpp | dashboardvision/aspose-php | e2931773cbb1f47ae4086d632faa3012bd952b99 | [
"MIT"
] | 1 | 2021-06-23T08:02:03.000Z | 2021-06-23T08:02:03.000Z | #include "../include/aspose.h"
#include "../include/format.h"
#include "../include/fill-format.h"
#include <phpcpp.h>
#include "../include/line-format.h"
using namespace Aspose::Slides::Charts;
using namespace std;
namespace AsposePhp
{
/**
* @brief Returns fill style properties of a chart
*
* @return Php::Value
*/
Php::Value Format::get_Fill()
{
return Php::Object("AsposePhp\\Slides\\Charts\\FillFormat", wrapObject<IFillFormat, AsposePhp::FillFormat, &IFormat::get_Fill>());
}
/**
* @brief Returns line style properties of a chart
*
* @return Php::Value
*/
Php::Value Format::get_Line()
{
return Php::Object("AsposePhp\\Slides\\LineFormat", wrapObject<ILineFormat, AsposePhp::LineFormat, &IFormat::get_Line>());
}
} // namespace AsposePhp
| 24.735294 | 138 | 0.638526 | dashboardvision |
69966892be1942dae20ef69d1cbb666dcaf702e9 | 11,356 | cpp | C++ | examples/ecies-example.cpp | istepic/MoCOCrW | db7d291cec2d85566a6f34a19f6120974c021e73 | [
"Apache-2.0"
] | 19 | 2018-05-15T09:01:13.000Z | 2022-02-16T16:36:16.000Z | examples/ecies-example.cpp | istepic/MoCOCrW | db7d291cec2d85566a6f34a19f6120974c021e73 | [
"Apache-2.0"
] | 39 | 2018-05-28T10:22:04.000Z | 2021-07-26T11:27:36.000Z | examples/ecies-example.cpp | istepic/MoCOCrW | db7d291cec2d85566a6f34a19f6120974c021e73 | [
"Apache-2.0"
] | 26 | 2018-05-15T10:08:18.000Z | 2022-03-31T08:33:03.000Z | /*
* #%L
* %%
* Copyright (C) 2020 BMW Car IT GmbH
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
#include <mococrw/ecies.h>
#include <mococrw/hash.h>
#include <mococrw/util.h>
#include <mococrw/openssl_wrap.h>
#include <iostream>
using namespace mococrw;
struct EciesEncryptResult {
std::vector<uint8_t> ephemeralKey;
std::vector<uint8_t> ciphertext;
std::vector<uint8_t> mac;
};
EciesEncryptResult encrypt_data(const std::vector<uint8_t> &message)
{
const std::string pubKeyPem = R"(
-----BEGIN PUBLIC KEY-----
MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAELGj/fqXab+amxDOcbDWMArPBsUMOPons
9NePVyS9CbIkI8e3nPYi3ytHjJm03M22vM5R4XAxI9cMv5biylFJW0HBlyf/cZTO
xOVCTvRDUHLGTdGXNlz74YtWLF+CMX5A
-----END PUBLIC KEY-----
)";
/* The standard for ECIES (IEEE 1363a-2004) doesn't specify the details of the different cipher blocks.
* Thus it is up to the implementer to define its own protocol (hash-function, key derivation function,
* message authentication code, symmetric cipher, key serialization) used for encryption and decryption.
* In the current example the following is used:
* - SHA512 everywhere where a hash function is required
* - X963(SHA512) as key derivation function
* - HMAC(SHA512) as message authentication code
* - AES CBC with PKCS padding, zero IV and 256 bit key size
* - Additionally salts for KDF and MAC can be set (optional value, default: empty)
*
* The defaults if the builder is invoked without any optional parameters are:
* - X963(SHA512) as key derivation function
* - HMAC(SHA512)
* - AES CBC with PKCS padding, zero IV and 256 bit key size
* - empty salts for KDF and MAC
*/
/* Read the public key */
auto pubKey = AsymmetricPublicKey::readPublicKeyFromPEM(pubKeyPem);
/* Get the encryption context */
std::unique_ptr<ECIESEncryptionCtx> encCtx = ECIESCtxBuilder{}
/* This is optional. The default is X963 with SHA512 */
.setKDF(std::make_shared<X963KDF>(DigestTypes::SHA512))
/* This is optional. The default is HMAC with SHA512
* Dependency injection function, as the key for MAC is generated based on a random ECC key in the
* ECIES class */
.setMacFactoryFunction(
[](const std::vector<uint8_t> &key) -> std::unique_ptr<MessageAuthenticationCode> {
return std::make_unique<mococrw::HMAC>(DigestTypes::SHA512, key);
}
)
/* This is optional. The default key length is 512 / 8 bytes (length of hash sum) */
.setMacKeySize(Hash::getDigestSize(DigestTypes::SHA512))
/* The next two lines are optional. Default: AES CBC with PKCS padding, zero IV and 256 bit key size */
.setSymmetricCipherFactoryFunction(
[](const std::vector<uint8_t> &key) -> std::unique_ptr<SymmetricCipherI> {
return AESCipherBuilder(SymmetricCipherMode::CBC, SymmetricCipherKeySize::S_256, key)
.setIV(std::vector<uint8_t>(AESCipherBuilder::getDefaultIVLength(SymmetricCipherMode::CBC)))
.setPadding(SymmetricCipherPadding::PKCS)
.buildEncryptor();
}
)
.setSymmetricCipherKeySize(getSymmetricCipherKeySize(SymmetricCipherKeySize::S_256))
.buildEncryptionCtx(pubKey);
std::vector<uint8_t> encryptedData;
try {
encCtx->update(message);
encryptedData = encCtx->finish();
} catch (const openssl::OpenSSLException &e) {
/* low level OpenSSL failure */
std::cerr << "Error encrypting data." << std::endl;
std::cerr << e.what() << std::endl;
exit(EXIT_FAILURE);
} catch (const MoCOCrWException &e) {
/* Possible reasons:
* - symmetric cipher is not initalized
* - update is invoked after finish
* - symmetric cipher's finish() is already invoked
* - symmetric cipher's update() is invoked after its finish()
* - Message is too big
* - finish is invoked twice
* - MAC's finish() is already invoked
* - MAC's update() is invoked after MAC's finish()
*/
std::cerr << "Error encrypting data." << std::endl;
std::cerr << e.what() << std::endl;
exit(EXIT_FAILURE);
}
std::vector<uint8_t> ephemeralKey;
try {
ephemeralKey = encCtx->getEphemeralKey().toECPoint(openssl::EllipticCurvePointConversionForm::uncompressed);
} catch (const openssl::OpenSSLException &e) {
/* low level OpenSSL failure */
std::cerr << "Failure transforming EC key." << std::endl;
std::cerr << e.what() << std::endl;
exit(EXIT_FAILURE);
} catch (const MoCOCrWException &e) {
/* Possible reasons:
* - Key object doesn't contain an EC key
*/
std::cerr << "Failure transforming EC key." << std::endl;
std::cerr << e.what() << std::endl;
exit(EXIT_FAILURE);
}
return EciesEncryptResult{
/* The serialization of the ephemeral key's public component is up to the implementer. The standard is not
* defining a format. Available formats in MoCOCrW are:
* - uncompressed (used here)
* - compressed
* - hybrid
*/
ephemeralKey,
encryptedData,
encCtx->getMAC(),
};
}
void decrypt_data(const EciesEncryptResult &eciesData)
{
/* We need
* - mac value
* - ephemeral key
* - ciphertext
* - private key
*/
const std::string privKeyPem = R"(
-----BEGIN EC PARAMETERS-----
BgUrgQQAIg==
-----END EC PARAMETERS-----
-----BEGIN EC PRIVATE KEY-----
MIGkAgEBBDDP/GdwmJa6KFj/R7QJRi7wNNG+viSMos2B+4zIi7fO5BUpIMZObh6/
ujDnPKFx4SugBwYFK4EEACKhZANiAAQsaP9+pdpv5qbEM5xsNYwCs8GxQw4+iez0
149XJL0JsiQjx7ec9iLfK0eMmbTczba8zlHhcDEj1wy/luLKUUlbQcGXJ/9xlM7E
5UJO9ENQcsZN0Zc2XPvhi1YsX4IxfkA=
-----END EC PRIVATE KEY-----
)";
/* The standard for ECIES (IEEE 1363a-2004) doesn't specify the details of the different cipher blocks.
* Thus it is up to the user to define its own set of cipher blocks (hash-function, key derivation function,
* message authentication code, symmetric cipher) used for encryption and decryption.
* In the current example the following is used:
* - SHA512 everywhere where a hash function is required
* - X963(SHA512) as key derivation function
* - HMAC(SHA512) as message authentication code
* - AES CBC with PKCS padding, zero IV and 256 bit key size
* - Additionally salts for KDF and MAC can be set (optional value, default: empty)
*
* The defaults if the builder is invoked without any optional parameters are:
* - X963(SHA512) as key derivation function
* - HMAC(SHA512)
* - AES CBC with PKCS padding, zero IV and 256 bit key size
* - empty salts for KDF and MAC
*/
/* Read the private key and thet the ECC specification of the private key.
* The elliptic curve of the ephemeral key is the same as the private key's one as it is derived from the
* corresponding public key. */
auto privKey = AsymmetricPrivateKey::readPrivateKeyFromPEM(privKeyPem, "");
std::shared_ptr<AsymmetricKey::Spec> spec = privKey.getKeySpec();
auto eccSpec = std::dynamic_pointer_cast<ECCSpec>(spec);
if (!eccSpec) {
std::cerr << "Given key is no ECC key." << std::endl;
exit(EXIT_FAILURE);
}
/* The underlying openssl function recognizes the used serialization format of the ephemeral key reading the first
* byte of the serialized data, which defines the format.
* The variable eccSpec contains the used elliptic curve of the ephemeral key */
auto _ephemeralKey = AsymmetricPublicKey::fromECPoint(eccSpec, eciesData.ephemeralKey);
/* Get the decryption context */
auto decCtx = ECIESCtxBuilder{}
// This is optional. The default is X963 with SHA512
.setKDF(std::make_shared<X963KDF>(DigestTypes::SHA512))
// This is optional. The default is HMAC with SHA512
.setMacFactoryFunction(
[](const std::vector<uint8_t> &key) -> std::unique_ptr<MessageAuthenticationCode> {
return std::make_unique<mococrw::HMAC>(DigestTypes::SHA512, key);
}
)
// This is optional. The default key length is 512 / 8 bytes (length of hash sum)
.setMacKeySize(Hash::getDigestSize(DigestTypes::SHA512))
// This is optional. Default: AES CBC with PKCS padding, zero IV and 256 bit key size
.setSymmetricCipherFactoryFunction(
[](const std::vector<uint8_t> &key) -> std::unique_ptr<SymmetricCipherI> {
return AESCipherBuilder(SymmetricCipherMode::CBC, SymmetricCipherKeySize::S_256, key)
.setIV(std::vector<uint8_t>(AESCipherBuilder::getDefaultIVLength(SymmetricCipherMode::CBC)))
.setPadding(SymmetricCipherPadding::PKCS)
.buildDecryptor();
}
)
.setSymmetricCipherKeySize(getSymmetricCipherKeySize(SymmetricCipherKeySize::S_256))
.buildDecryptionCtx(privKey, _ephemeralKey);
/* Decrypt the data and verify the MAC */
std::vector<uint8_t> decryptedData;
try {
/* Decrypt the ciphertext */
decCtx->update(eciesData.ciphertext);
/* Set the received mac value */
decCtx->setMAC(eciesData.mac);
/* Get the plaintext and verify the MAC */
decryptedData = decCtx->finish();
} catch (const openssl::OpenSSLException &e) {
/* low level OpenSSL failure */
std::cerr << "Failure decrypting data." << std::endl;
std::cerr << e.what() << std::endl;
exit(EXIT_FAILURE);
} catch (const MoCOCrWException &e) {
/* Possible reasons:
* - symmetric cipher is not initalized
* - update is invoked after finish
* - symmetric cipher's finish() is already invoked
* - symmetric cipher's update() is invoked after its finish()
* - Message is too big
* - finish is invoked twice
* - MAC's finish() is already invoked
* - MAC's update() is invoked after MAC's finish()
* - MAC is not set before invoking finish()
* - MAC verification failed
*/
std::cerr << "Error decrypting integrated encryption scheme." << std::endl;
std::cerr << e.what();
exit(EXIT_FAILURE);
}
}
int main(void)
{
std::vector<uint8_t> message = utility::fromHex("deadbeef");
auto eciesData = encrypt_data(message);
decrypt_data(eciesData);
return 0;
}
| 42.85283 | 120 | 0.642568 | istepic |
699943947100979ae07aefc1d5143c60e6b59993 | 13,446 | cpp | C++ | Desktop/piMASS/piMASScmplrSLN/backup/gpcpic.cpp | AliveMOon/piMASSpub | 5b87752b9d224f4033e33635f527b842b454f012 | [
"MIT"
] | 2 | 2019-06-17T10:40:53.000Z | 2019-06-18T12:50:29.000Z | Desktop/piMASS/piMASScmplrSLN/backup/gpcpic.cpp | AliveMOon/piMASSpub | 5b87752b9d224f4033e33635f527b842b454f012 | [
"MIT"
] | 3 | 2019-06-17T10:20:46.000Z | 2019-06-18T18:10:41.000Z | Desktop/piMASS/piMASScmplrSLNpi4/backup/gpcpic.cpp | AliveMOon/piMASSpub | 5b87752b9d224f4033e33635f527b842b454f012 | [
"MIT"
] | null | null | null | #include "gpcpic.h"
#include "gpcSRC.h"
bool gpfSRFjpgSAVE( U1* pFILE, SDL_Surface* pSRF, I4 q )
{
if( pSRF ? (pFILE ? !*pFILE : false ) : true )
return false;
struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr;
FILE* pOUT;
JSAMPROW aROW[1];
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_compress(&cinfo);
if( !(pOUT = fopen( (char*)pFILE, "wb")) )
return false;
jpeg_stdio_dest(&cinfo, pOUT);
cinfo.image_width = pSRF->w;
cinfo.image_height = pSRF->h;
if( pSRF->format->BytesPerPixel != 3 )
return false;
cinfo.input_components = pSRF->format->BytesPerPixel; // 3;
cinfo.in_color_space = JCS_RGB;
jpeg_set_defaults(&cinfo);
jpeg_set_quality( &cinfo, q, true );
jpeg_start_compress(&cinfo,true);
int rowSTRD = pSRF->pitch;
while(cinfo.next_scanline < cinfo.image_height ) {
aROW[0] = ((U1*)pSRF->pixels)+(cinfo.next_scanline*rowSTRD);
jpeg_write_scanlines(&cinfo, aROW, 1 );
}
jpeg_finish_compress(&cinfo);
fclose(pOUT);
jpeg_destroy_compress(&cinfo);
return true;
}
std::vector<JOCTET> jpgBUFF;
#define gpdJPGsiz 0x4000
void my_init_destination( j_compress_ptr pINF )
{
jpgBUFF.resize(gpdJPGsiz);
pINF->dest->next_output_byte = &jpgBUFF[0];
pINF->dest->free_in_buffer = jpgBUFF.size();
}
boolean my_empty_output_buffer(j_compress_ptr pINF )
{
size_t oSIZ = jpgBUFF.size();
jpgBUFF.resize(oSIZ+gpdJPGsiz);
pINF->dest->next_output_byte = &jpgBUFF[oSIZ];
pINF->dest->free_in_buffer = jpgBUFF.size()-oSIZ;
return true;
}
void my_term_destination(j_compress_ptr pINF )
{
jpgBUFF.resize(jpgBUFF.size()-pINF->dest->free_in_buffer);
}
gpcLZY* gpfSRF2JPG( gpcLZY* pBUFF, SDL_Surface* pSRF, I4 q )
{
if( !pSRF )
return pBUFF;
U8 s = -1, nMEM = 0;
JSAMPROW aROW[1];
struct jpeg_compress_struct INF;
struct jpeg_error_mgr jerr;
INF.err = jpeg_std_error(&jerr);
struct jpeg_destination_mgr dst;
//INF->dest = jpeg_stdio_dest( &dst );
jpeg_create_compress(&INF);
//jpeg_mem_dest(&INF, )
if( !INF.dest )
INF.dest = &dst;
INF.dest->init_destination = &my_init_destination;
INF.dest->empty_output_buffer = &my_empty_output_buffer;
INF.dest->term_destination = &my_term_destination;
INF.image_width = pSRF->w;
INF.image_height = pSRF->h;
if( pSRF->format->BytesPerPixel != 3 )
return pBUFF;
INF.input_components = pSRF->format->BytesPerPixel; // 3;
INF.in_color_space = JCS_RGB;
jpeg_set_defaults(&INF);
jpeg_set_quality( &INF, q, true );
jpeg_start_compress(&INF, true);
int rowSTRD = pSRF->pitch;
while(INF.next_scanline < INF.image_height ) {
aROW[0] = ((U1*)pSRF->pixels)+(INF.next_scanline*rowSTRD);
jpeg_write_scanlines(&INF, aROW, 1 );
}
jpeg_finish_compress(&INF);
pBUFF = pBUFF->lzyADD( &jpgBUFF[0], jpgBUFF.size(), s = -1 );
/*U1 *pMEM;
jpeg_mem_dest( &INF, pMEM, &nMEM );
pBUFF = pBUFF->lzyADD( pMEM, nMEM, s = -1 );
gpmDELary(pMEM);*/
return pBUFF;
}
#ifdef gpdSYSubi
//#ifndef gpdSYSpi
U4 gpcCAMubi::getImageTypeSize( RASPICAM_FORMAT f )
{
if( f != RASPICAM_FORMAT_RGB )
return 0;
return queryBuffer.length; //bufferinfo.bytesused;
}
bool gpcCAMubi::openCAM()
{
if( bOPEN )
return bOPEN;
/// 1. Open the device ---------------
if(bSTDcout){std::cout << "1. Open the device ---------------" << std::endl;}
fd = open("/dev/video0",O_RDWR);
if(fd < 0){
perror("Failed to open device, OPEN");
return bOPEN;
}
/// 2. Ask the device if it can capture frames
if(bSTDcout){std::cout << "2. Ask the device if it can capture frames" << std::endl;}
if(ioctl(fd, VIDIOC_QUERYCAP, &capability) < 0){
// something went wrong... exit
perror("Failed to get device capabilities, VIDIOC_QUERYCAP");
return bOPEN;
} else {
if(bSTDcout){std::cout << "driver:" << (char*)capability.driver << std::endl;}
}
bool bGD = false;
/// 3. ------------------------------------------------------
fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
int r = ioctl(fd,VIDIOC_ENUM_FMT,&fmtdesc);
while( r > -1 ) {
if(bSTDcout){std::cout << fmtdesc.description << std::endl;}
frmsize.type = fmtdesc.type;
frmsize.pixel_format = fmtdesc.pixelformat;
frmsize.index = 0;
/// 4. ------------------------------------------------------
r = ioctl(fd, VIDIOC_ENUM_FRAMESIZES, &frmsize);
while( r > -1 ) {
if(frmsize.type == V4L2_FRMSIZE_TYPE_DISCRETE) {
if(bSTDcout){std::cout << "discrete w:" << frmsize.discrete.width << " h:" << frmsize.discrete.height << std::endl;}
} else {
if(bSTDcout){std::cout << "-------- w:" << frmsize.stepwise.min_width << " h:" << frmsize.stepwise.min_height << std::endl
<< "-------- w:" << frmsize.stepwise.max_width << " h:" << frmsize.stepwise.max_height << std::endl;}
if( frmsize.pixel_format == V4L2_PIX_FMT_RGB24 ) {
wh0.x = gpmMAX( frmsize.stepwise.min_width, gpmMIN(wh0.x,frmsize.stepwise.max_width) );
wh0.y = gpmMAX( frmsize.stepwise.min_height, gpmMIN(wh0.y,frmsize.stepwise.max_height) );
bGD = true;
break;
}
}
if( bGD )
break;
frmsize.index++;
r = ioctl(fd, VIDIOC_ENUM_FRAMESIZES, &frmsize);
}
if( bGD )
break;
fmtdesc.index++;
r = ioctl(fd,VIDIOC_ENUM_FMT,&fmtdesc);
}
if( !bGD )
return bOPEN;
wip = 0;
bGD = ( setCaptureSize( wh0.x, wh0.y, frmsize.pixel_format ) > -1 );
if( !bGD )
return bOPEN;
//grab();
return bOPEN = true;
}
int gpcCAMubi::setCaptureSize( U4 w, U4 h, U4 picFRM ) {
if( wh == wh0 )
return 0;
/// 5. Set Image format
if(bSTDcout){std::cout << "5. Set Image format ----------" << std::endl;}
gpmZ(format);
format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
format.fmt.pix.width = w;
format.fmt.pix.height = h;
format.fmt.pix.pixelformat = picFRM;
format.fmt.pix.field = V4L2_FIELD_NONE;
int res = ioctl(fd, VIDIOC_S_FMT, &format);
if( res < 0){
closeCAM();
return res;
}
if( pBUFF ) {
munmap(pBUFF, queryBuffer.length);
}
/// 6. VIDIOC_REQBUFS ----------
if(bSTDcout){std::cout << "6. VIDIOC_REQBUFS ----------" << std::endl;}
requestBuffer.count = 1; // one request buffer
requestBuffer.type = format.type ; // request a buffer wich we an use for capturing frames
requestBuffer.memory = V4L2_MEMORY_MMAP;
res = ioctl(fd, VIDIOC_REQBUFS, &requestBuffer);
if( res < 0){
return res;
}
if(bSTDcout){std::cout << "7. VIDIOC_QUERYBUF ----------------" << std::endl;}
/// 7. VIDIOC_QUERYBUF ----------
queryBuffer.type = format.type ;
queryBuffer.memory = V4L2_MEMORY_MMAP;
queryBuffer.index = 0;
res = ioctl(fd, VIDIOC_QUERYBUF, &queryBuffer);
if( res < 0){
return res;
}
pBUFF = (char*)mmap( NULL, queryBuffer.length,
PROT_READ | PROT_WRITE,
MAP_SHARED,
fd, queryBuffer.m.offset );
/// 8. VIDIOC_STREAMON ----------------
if(bSTDcout){std::cout << " 8. VIDIOC_STREAMON ----------------" << std::endl;}
type = format.type;
res = ioctl(fd, VIDIOC_STREAMON, &type);
if( res < 0 ){
return res;
}
if( wip != 9 ) {
/// 9. VIDIOC_QBUF ----------------
bufferinfo.type = type;
bufferinfo.memory = V4L2_MEMORY_MMAP;
bufferinfo.index = 0;
//if(bSTDcout){std::cout << " 9. VIDIOC_QBUF ----------------" << std::endl;}
res = ioctl(fd, VIDIOC_QBUF, &bufferinfo);
if( res < 0){
return res;
}
wip = 9;
}
wh = wh0;
return res;
}
U4 gpcCAMubi::grab()
{
int res;
if( wip == 9 ) {
/// 10. VIDIOC_DQBUF --------------------
if(bSTDcout){std::cout << "10.1 VIDIOC_DQBUF --------------------" << std::endl;}
res = ioctl(fd, VIDIOC_DQBUF, &bufferinfo);
if( res < 0){
return nGRB++;
}
if(bSTDcout){std::cout << "10.2 VIDIOC_DQBUF --------------------" << std::endl;}
wip = 10;
}
//if(bSTDcout){std::cout << "Buffer has: " << (double)bufferinfo.bytesused / 1024
// << " KBytes of data" << std::endl;}
return nGRB++;
}
void* gpcCAMubi::retrieve( void *pPIX, RASPICAM_FORMAT f )
{
if(bSTDcout){std::cout << "CPY" << std::endl;}
int res ;
gpmMcpy(pPIX, pBUFF, queryBuffer.length );
if( wip != 9 ) {
wip = 9;
/// 9.1 VIDIOC_QBUF ----------------
bufferinfo.type = type;
bufferinfo.memory = V4L2_MEMORY_MMAP;
bufferinfo.index = 0;
if(bSTDcout){std::cout << " 9.1 VIDIOC_QBUF ----------------" << std::endl;}
res = ioctl(fd, VIDIOC_QBUF, &bufferinfo);
if(res < 0)
return NULL;
if(bSTDcout){std::cout << " 9.2 VIDIOC_QBUF ----------------" << std::endl;}
}
return pPIX;
}
#endif // gpdSYSpi
class gpcTHRD_CAM {
public:
gpcPICAM* pC;
SDL_Surface* pSRF;
gpcTHRD_CAM(){ gpmCLR; };
};
void call_cam( gpcTHRD_CAM* pTC ) {
gpcTHRD_CAM cpy = *pTC;
//SDL_Surface srf =
gpdCAMu& cam = cpy.pC->cam;
U1 *pPIX, *pDAT;
U4 iCNT = 0, p = cpy.pSRF->pitch, p2 = p*2, h = cpy.pSRF->h, e = p*h;
while( cpy.pC )
{
pPIX = cpy.pSRF ? (U1*)cpy.pSRF->pixels : NULL;
usleep(1000/30);
cam.grab();
if( !pPIX )
continue;
#ifdef gpdSYSpi
pDAT = cam.getImageBufferData();
#else
pDAT = NULL;
#endif
if( pDAT )
{
memcpy( pPIX, pDAT, p*h );
/*for( U4 i = p*(iCNT&1); i < e; i += p2 )
memcpy( pPIX+i, pDAT+i, p );*/
iCNT++;
continue;
}
//memcpy ( cpy.pSRF->pixels, cpy.pC->cam.callback_data._buffData.data, getImageTypeSize( RASPICAM_FORMAT_IGNORE ) );
cam.retrieve(
pPIX,
#ifdef gpdSYSpi
raspicam::RASPICAM_FORMAT_IGNORE
#else
RASPICAM_FORMAT_IGNORE
#endif
//RASPICAM_FORMAT_YUV420 );
//RASPICAM_FORMAT_RGB );
);
}
}
U1* gpcPIC::getPIX( gpcPICAM* pC, U4 qc )
{
if( !this )
return NULL;
if( !pC )
return pSRF ? (U1*)pSRF->pixels : NULL;
if( pC->cam.openCAM() )
{
usleep(1*1000);
}
if( aiQC[0] >= qc )
return NULL; //pSRF ? (U1*)pSRF->pixels : NULL;
if( bTHRD )
{
pREF = NULL;
aiQC[0] = qc+ gpdTCP_tOUT;
return pSRF ? (U1*)pSRF->pixels : NULL;
}
nPIX = pC->cam.getImageTypeSize(
#ifdef gpdSYSpi
raspicam::RASPICAM_FORMAT_RGB
#else
RASPICAM_FORMAT_RGB
#endif
);
xyOUT.a4x2[1] = I4x2( pC->cam.getWidth(), pC->cam.getHeight() );
if( nPIXall != nPIX ) {
nPIXall = nPIX;
SDL_FreeSurface(pSRF);
U4 rmask, gmask, bmask, amask;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
int shift = (req_format == STBI_rgb) ? 8 : 0;
rmask = 0xff000000 >> shift;
gmask = 0x00ff0000 >> shift;
bmask = 0x0000ff00 >> shift;
amask = 0x000000ff >> shift;
#else // little endian, like x86
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = 0; //(req_format == STBI_rgb) ? 0 : 0xff000000;
#endif
pSRF = SDL_CreateRGBSurface( 0, xyOUT.z, xyOUT.w, 24, rmask, gmask, bmask, amask );
}
if( pSRF ) {
#ifndef gpdSYSpi
pC->cam.grab();
pC->cam.retrieve(
(U1*)pSRF->pixels,
#ifdef gpdSYSpi
raspicam::RASPICAM_FORMAT_IGNORE
#else
RASPICAM_FORMAT_IGNORE
#endif
//RASPICAM_FORMAT_YUV420 );
//RASPICAM_FORMAT_RGB );
);
//pC->cam.grab();
pREF = NULL;
aiQC[0] = qc+ gpdTCP_tOUT;
return pSRF ? (U1*)pSRF->pixels : NULL;
#else
gpcTHRD_CAM trd;
trd.pC = pC;
trd.pSRF = pSRF;
if( !bTHRD )
{
T = std::thread( call_cam, &trd );
usleep(3*1000);
bTHRD = true;
}
if( !bTHRD )
{
pC->cam.grab();
pC->cam.retrieve(
(U1*)pSRF->pixels,
#ifdef gpdSYSpi
raspicam::RASPICAM_FORMAT_IGNORE
#else
RASPICAM_FORMAT_IGNORE
#endif
//RASPICAM_FORMAT_YUV420 );
//RASPICAM_FORMAT_RGB );
);
}
#endif
}
aiQC[0] = qc;
return pSRF ? (U1*)pSRF->pixels : NULL;
}
U4 gpcPICall::alfFND( U1* pS ) {
I8x2 TnID(0,14);
TnID = pS;
TnID.num = gpfSTR2U8( pS+TnID.num, &pS );
for( U4 p = 0; p < nPICld; p++ )
{
if( !ppPIC[p] )
{
if( iPICfr > p )
iPICfr = p;
continue;
}
if( ppPIC[p]->TnID != TnID )
continue;
return p;
}
return nPICld;
}
gpcPIC* gpcPICall::aluFND( gpcALU& alu ) {
U4 i = alu.bSTR() ?
alfFND( (U1*)alu.pDAT ) // ez a kép neve
: alu.u8();
if( pPIC = PIC(i) )
return pPIC;
I8x2 alfN(0,14);
U1* pS = (U1*)alu.pDAT;
alfN = pS;
alfN.num = gpfSTR2U8( pS+alfN.num, &pS );
return PIC( alfN );
}
| 27.163636 | 141 | 0.548118 | AliveMOon |
69995c41cd65d800e80061499743d123ddcb24dc | 59 | cpp | C++ | leetcode/20.Vaild Parentheses/main.cpp | vaniot-s/code | b2620a9003741c644905d604b85cc4ef66de7486 | [
"BSD-2-Clause"
] | null | null | null | leetcode/20.Vaild Parentheses/main.cpp | vaniot-s/code | b2620a9003741c644905d604b85cc4ef66de7486 | [
"BSD-2-Clause"
] | null | null | null | leetcode/20.Vaild Parentheses/main.cpp | vaniot-s/code | b2620a9003741c644905d604b85cc4ef66de7486 | [
"BSD-2-Clause"
] | null | null | null | //
// Created by vaniot on 18-12-10.
//
#include "main.h"
| 9.833333 | 33 | 0.59322 | vaniot-s |
699a222a84fcdaf444277f4504c5b769676efe11 | 2,870 | cc | C++ | RAVL2/PatternRec/DataSet/testDataSetXMLFactory.cc | isuhao/ravl2 | 317e0ae1cb51e320b877c3bad6a362447b5e52ec | [
"BSD-Source-Code"
] | null | null | null | RAVL2/PatternRec/DataSet/testDataSetXMLFactory.cc | isuhao/ravl2 | 317e0ae1cb51e320b877c3bad6a362447b5e52ec | [
"BSD-Source-Code"
] | null | null | null | RAVL2/PatternRec/DataSet/testDataSetXMLFactory.cc | isuhao/ravl2 | 317e0ae1cb51e320b877c3bad6a362447b5e52ec | [
"BSD-Source-Code"
] | null | null | null | // This file is part of OmniSoft, Pattern recognition software
// Copyright (C) 2009, OmniPerception Ltd.
// file-header-ends-here
#include "Ravl/UnitTest.hh"
#include "Ravl/PatternRec/SampleVector.hh"
#include "Ravl/PatternRec/DataSetVectorLabel.hh"
#include "Ravl/MeanCovariance.hh"
using namespace RavlN;
int testSampleVector(void);
int testDataSetVectorLabel(void);
int main() {
int ln;
if((ln = testSampleVector()) != 0) {
std::cerr << "Test failed on line " << ln << "\n";
return 1;
}
if((ln = testDataSetVectorLabel()) != 0) {
std::cerr << "Test failed on line " << ln << "\n";
return 1;
}
std::cout << "Test passed. \n";
return 0;
}
int testSampleVector(void) {
RavlN::StrIStreamC
ss(
"<?xml version='1.0' encoding='UTF-8' ?>\n"
"<?RAVL class='RavlN::XMLTreeC' ?>\n"
"<Config >\n"
"<Sample typename=\"RavlN::SampleVectorC\" >"
"<stats typename=\"RavlN::MeanCovarianceC\" samples=\"10000\" mean=\"3 4 5 -9\" covariance=\"3 3 4 3 0 3 5 0 0 0 10\" />"
"</Sample>"
"</Config>");
RavlN::XMLTreeC xmlTree(true);
if (!xmlTree.Read(ss))
return __LINE__;
RavlN::XMLFactoryHC mainFactory("test.xml", xmlTree);
RavlN::XMLFactoryContextC context(mainFactory);
SampleVectorC sampleVector;
// get connection to database
if(!context.UseComponent("Sample", sampleVector, true)) {
return __LINE__;
}
// compute mean and covariance of generated data set
MeanCovarianceC meanCovariance = sampleVector.MeanCovariance();
RealT tolerance = 0.5;
// do some tests
if(!TestAlmostEquals(0.0, meanCovariance.Mean().Sum(), tolerance, __FILE__, __LINE__)) {
return __LINE__;
}
// do some tests
if(!TestAlmostEquals(25.0, meanCovariance.Covariance().SumOfAbs(), tolerance, __FILE__, __LINE__)) {
return __LINE__;
}
return 0;
}
int testDataSetVectorLabel(void) {
RavlN::StrIStreamC
ss(
"<?xml version='1.0' encoding='UTF-8' ?>\n"
"<?RAVL class='RavlN::XMLTreeC' ?>\n"
"<Config >\n"
"<DataSet typename=\"RavlN::DataSetVectorLabelC\">"
"<Sample1 typename=\"RavlN::SampleVectorC\" >"
"<stats typename=\"RavlN::MeanCovarianceC\" samples=\"1000\" mean=\"2 1 5\" covariance=\"2 2 1 0 0 1\" />"
"</Sample1>"
"<Sample2 typename=\"RavlN::SampleVectorC\" >"
"<stats typename=\"RavlN::MeanCovarianceC\" samples=\"1000\" mean=\"2 10 50\" covariance=\"2 2 1 0 0 1\" />"
"</Sample2>"
"</DataSet>"
"</Config>");
RavlN::XMLTreeC xmlTree(true);
if (!xmlTree.Read(ss))
return __LINE__;
RavlN::XMLFactoryHC mainFactory("test.xml", xmlTree);
RavlN::XMLFactoryContextC context(mainFactory);
DataSetVectorLabelC dset;
// get connection to database
if(!context.UseComponent("DataSet", dset, true)) {
return __LINE__;
}
return 0;
}
| 28.137255 | 128 | 0.63554 | isuhao |
699fa03222d54f5b871d0b624bbf6d335417dbfe | 157 | cpp | C++ | ch17/592.cpp | mallius/CppPrimer | 0285fabe5934492dfed0a9cf67ba5650982a5f76 | [
"MIT"
] | null | null | null | ch17/592.cpp | mallius/CppPrimer | 0285fabe5934492dfed0a9cf67ba5650982a5f76 | [
"MIT"
] | null | null | null | ch17/592.cpp | mallius/CppPrimer | 0285fabe5934492dfed0a9cf67ba5650982a5f76 | [
"MIT"
] | 1 | 2022-01-25T15:51:34.000Z | 2022-01-25T15:51:34.000Z | #include <memory>
using namespace std;
void f()
{
auto_ptr<int> ap(new int(42));
}
int main(void)
{
f();
auto_ptr<int> pi = new int(1024);
return 0;
}
| 10.466667 | 34 | 0.624204 | mallius |
69a15d5f7731adae6538fbf19b54d0ca2d873fbb | 3,789 | cpp | C++ | src/sprogc/source/gpc_species_comp.cpp | sm453/MOpS | f1a706c6552bbdf3ceab504121a02391a1b51ede | [
"MIT"
] | 3 | 2020-09-08T14:06:33.000Z | 2020-12-04T07:52:19.000Z | src/sprogc/source/gpc_species_comp.cpp | sm453/MOpS | f1a706c6552bbdf3ceab504121a02391a1b51ede | [
"MIT"
] | null | null | null | src/sprogc/source/gpc_species_comp.cpp | sm453/MOpS | f1a706c6552bbdf3ceab504121a02391a1b51ede | [
"MIT"
] | 3 | 2021-11-15T05:18:26.000Z | 2022-03-01T13:51:20.000Z | /*
Author(s): Martin Martin (mm864)
Project: sprog (gas-phase and surface chemical kinetics).
Sourceforge: http://sourceforge.net/projects/mopssuite
Copyright (C) 2012 Martin Martin.
File purpose:
Inline function definitions for Species class.
Licence:
This file is part of "sprog".
sprog is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Contact:
Dr Markus Kraft
Dept of Chemical Engineering
University of Cambridge
New Museums Site
Pembroke Street
Cambridge
CB2 3RA
UK
Email: mk306@cam.ac.uk
Website: http://como.cheng.cam.ac.uk
*/
#include "gpc_species_comp.h"
#include "gpc_species.h"
using namespace Sprog;
using namespace std;
// CONSTRUCTORS AND DESTRUCTORS.
// Default constructor.
SpComp::SpComp(void)
{
m_index = -1; // Invalid index for uninitialised SpComps.
m_count = 0;
}
// Copy constructor.
SpComp::SpComp(const SpComp &sp)
{
m_index = -1;
*this = sp; // Use operator=.
}
// Initialising constructor.
SpComp::SpComp(unsigned int i, unsigned int n)
{
m_index = i;
m_count = n;
}
// Destructor.
SpComp::~SpComp(void)
{
// Nothing to destruct.
}
// OPERATOR OVERLOADING.
// Assignment operator.
SpComp &SpComp::operator=(const Sprog::SpComp &sp)
{
if (this!=&sp) {
m_index = sp.m_index;
m_count = sp.m_count;
}
return *this;
}
// Increment operator: Adds n to the species count.
SpComp &SpComp::operator+=(const unsigned int n)
{
m_count += n;
return *this;
}
// Decrement operator: Removes n from the species count to a zero minimum.
SpComp &SpComp::operator-=(const unsigned int n)
{
if (n > m_count) {
m_count = 0;
} else {
m_count -= n;
}
return *this;
}
// Addition operator: Returns a new SpComp object whose species count
// is this object's count + n.
const SpComp SpComp::operator+(const unsigned int n)
{
SpComp sp(*this);
return sp += n;
}
// Subtraction operator: Returns a new SpComp object whose species count
// is this object's count - n to a minimum of zero.
const SpComp SpComp::operator-(const unsigned int n)
{
SpComp sp(*this);
return sp -= n;
}
// Comparison operator: Returns true if both SpComp objects point to
// the same species.
bool SpComp::operator==(const SpComp &sp) const
{
return (m_index == sp.m_index) && (m_index>=0);
}
// Inequality operator: Returns false if both SpComp objects point to
// the same species.
bool SpComp::operator!=(const SpComp &sp) const
{
return !(*this==sp);
}
// SPECIES INDEX.
// Returns a index to the species referred to by this SpComp object.
int SpComp::Index(void) const
{
return m_index;
}
// Sets the index to the species referred to by this SpComp object.
void Sprog::SpComp::SetIndex(unsigned int sp)
{
m_index = sp;
}
// SPECIES COUNT.
// Returns the species count for this composition.
unsigned int Sprog::SpComp::Count() const
{
return m_count;
}
// Sets the species count for this composition.
void Sprog::SpComp::SetCount(unsigned int n)
{
m_count = n;
}
| 22.553571 | 79 | 0.679863 | sm453 |
69a1943f68b8ee73fa1cce852fe4b6edf8d5fb36 | 1,231 | cc | C++ | src/input/config_ctl.cc | frzifus/sfml-rpic-desktop | c112ed66a711f62ecf1198a221e7a914e413a92b | [
"MIT"
] | null | null | null | src/input/config_ctl.cc | frzifus/sfml-rpic-desktop | c112ed66a711f62ecf1198a221e7a914e413a92b | [
"MIT"
] | null | null | null | src/input/config_ctl.cc | frzifus/sfml-rpic-desktop | c112ed66a711f62ecf1198a221e7a914e413a92b | [
"MIT"
] | null | null | null | /**
* Copyright(c) [2017] <Frzifus> All Rights Reserved.
* Distributed under MIT license.
* See file LICENSE for detail at LICENSE file.
*/
#include "./input/config_ctl.h"
#include "./screen/config.h"
#include "./screen/screen_digits.h"
Input::ConfigCtl::ConfigCtl(::Screen::Config *config_instance) {
config_instance_ = config_instance;
}
void Input::ConfigCtl::Check(sf::RenderWindow &window) {
if (window.pollEvent(event_)) {
// Close window: exit
if (event_.type == sf::Event::Closed) {
config_instance_->next_screen = ::Screen::Digits::CLOSE;
}
CheckKeyboardInput_();
}
}
void Input::ConfigCtl::CheckGamepadInput_() {}
void Input::ConfigCtl::CheckKeyboardInput_() {
if (event_.type == sf::Event::KeyPressed) {
if (event_.key.code == sf::Keyboard::Escape) {
config_instance_->next_screen = ::Screen::Digits::HOME_SCREEN;
} else if (event_.key.code == sf::Keyboard::Up) {
config_instance_->MoveUp();
} else if (event_.key.code == sf::Keyboard::Down) {
config_instance_->MoveDown();
} else if (event_.key.code == sf::Keyboard::Return) {
config_instance_->SaveConfig();
config_instance_->next_screen = ::Screen::Digits::HOME_SCREEN;
}
}
}
| 30.02439 | 68 | 0.669374 | frzifus |
69a2ae3514d7a78968a6c5f5aa9ada6c2483e384 | 901 | cpp | C++ | Array/caiweixiong/cpp/Homework_007.cpp | JessonYue/LeetCodeLearning | 3c22a4fcdfe8b47f9f64b939c8b27742c4e30b79 | [
"MIT"
] | 39 | 2020-05-31T06:14:39.000Z | 2021-01-09T11:06:39.000Z | Array/caiweixiong/cpp/Homework_007.cpp | JessonYue/LeetCodeLearning | 3c22a4fcdfe8b47f9f64b939c8b27742c4e30b79 | [
"MIT"
] | 7 | 2020-06-02T11:04:14.000Z | 2020-06-11T14:11:58.000Z | Array/caiweixiong/cpp/Homework_007.cpp | JessonYue/LeetCodeLearning | 3c22a4fcdfe8b47f9f64b939c8b27742c4e30b79 | [
"MIT"
] | 20 | 2020-05-31T06:21:57.000Z | 2020-10-01T04:48:38.000Z | //
// Created by Vashon on 2020/8/10.
//
#include "Homework_007.h"
ListNode *Homework_007::reverseList_1(ListNode *head) {
if (!head || !head->next) return head;
ListNode tempHead(0), *temp;
// 头插法建链
while (head) {
temp = head;
head = head->next;
temp->next = tempHead.next;
tempHead.next = temp;
}
return tempHead.next;
}
ListNode *Homework_007::reverseList_2(ListNode *head) {
if (!head || !head->next) return head;
ListNode *newHead = reverseList_2(head->next);
head->next->next = head;
head->next = nullptr;
return newHead;
}
void Homework_007::homework_007_206() {
ListNode *head;
createHeadNode(head, 1);
insertNode(head, 2);
insertNode(head, 3);
insertNode(head, 4);
insertNode(head, 5);
displayList(head);
head = reverseList_1(head);
displayList(head);
destroyList(head);
} | 23.102564 | 55 | 0.621532 | JessonYue |
69a70a2e93ed3a12b83d33857adda993fa1c7743 | 468 | cpp | C++ | src/shm/single_producer.cpp | AMDS123/SharedMQ | d58c09c32a45822e4a473b6d6d51d1a51ce3681a | [
"BSD-2-Clause"
] | 4 | 2019-03-19T08:14:35.000Z | 2021-05-25T08:51:54.000Z | src/shm/single_producer.cpp | AMDS123/SharedMQ | d58c09c32a45822e4a473b6d6d51d1a51ce3681a | [
"BSD-2-Clause"
] | null | null | null | src/shm/single_producer.cpp | AMDS123/SharedMQ | d58c09c32a45822e4a473b6d6d51d1a51ce3681a | [
"BSD-2-Clause"
] | 3 | 2019-04-05T10:23:26.000Z | 2021-07-22T01:26:01.000Z | #include "errors.h"
#include "configreader.h"
#include "single_producer.h"
Producer::Producer(const char *conf_path)
{
shmmq_notifier = new ShmBase::ShmMQNotify(conf_path, ShmBase::ShmMQNotify::WRITER);
exit_if(shmmq_notifier == NULL, "new ShmMQNotify");
}
Producer::~Producer()
{
delete shmmq_notifier;
}
int Producer::sendData(const void *data, unsigned data_len, std::string& err_msg)
{
return shmmq_notifier->produce(data, data_len, err_msg);
}
| 23.4 | 87 | 0.735043 | AMDS123 |
69aab84ff423b7f54992bd732cfdec60413d46bd | 1,697 | cpp | C++ | modules/core/container/table/unit/table/release.cpp | psiha/nt2 | 5e829807f6b57b339ca1be918a6b60a2507c54d0 | [
"BSL-1.0"
] | null | null | null | modules/core/container/table/unit/table/release.cpp | psiha/nt2 | 5e829807f6b57b339ca1be918a6b60a2507c54d0 | [
"BSL-1.0"
] | null | null | null | modules/core/container/table/unit/table/release.cpp | psiha/nt2 | 5e829807f6b57b339ca1be918a6b60a2507c54d0 | [
"BSL-1.0"
] | null | null | null | //==============================================================================
// Copyright 2003 - 2012 LASMEA UMR 6602 CNRS/Univ. Clermont II
// Copyright 2009 - 2012 LRI UMR 8623 CNRS/Univ Paris Sud XI
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//==============================================================================
#include <nt2/table.hpp>
#include <nt2/include/functions/extent.hpp>
#include <nt2/sdk/memory/c_allocator.hpp>
#include <nt2/sdk/unit/tests.hpp>
#include <nt2/sdk/unit/module.hpp>
NT2_TEST_CASE_TPL( table_release ,NT2_TYPES)
{
using nt2::table;
typename nt2::table<T>::pointer ptr;
{
nt2::table<T> a(nt2::of_size(3, 3));
for(int i=1; i <= 3; i++)
for(int j=1; j <= 3; j++)
a(i, j) = T(i + 10*j);
ptr = a.release();
NT2_TEST_EQUAL(nt2::extent(a), nt2::of_size(0));
}
for(int j=0; j < 3; j++)
for(int i=0; i < 3; i++)
NT2_TEST_EQUAL( ptr[i+3*j], T(i+1 + 10*(j+1)) );
boost::simd::deallocate(ptr);
}
NT2_TEST_CASE_TPL( table_release_c_style ,NT2_TYPES)
{
using nt2::table;
using nt2::c_allocator;
typename nt2::table<T, c_allocator<T> >::pointer ptr;
{
nt2::table<T,c_allocator<T> > a(nt2::of_size(3, 3));
for(int i=1; i <= 3; i++)
for(int j=1; j <= 3; j++)
a(i, j) = T(i + 10*j);
ptr = a.release();
NT2_TEST_EQUAL(nt2::extent(a), nt2::of_size(0));
}
for(int j=0; j < 3; j++)
for(int i=0; i < 3; i++)
NT2_TEST_EQUAL( ptr[i+3*j], T(i+1 + 10*(j+1)) );
::free(ptr);
}
| 25.712121 | 80 | 0.516205 | psiha |
69ad11e7a6690ad55c9987a8efd262d42e53bcdb | 4,344 | cpp | C++ | local/codes/c1086_2.cpp | Tony031218/OI | 562f5f45d0448f4eab77643b99b825405a123d92 | [
"MIT"
] | 1 | 2021-02-22T03:39:24.000Z | 2021-02-22T03:39:24.000Z | local/codes/c1086_2.cpp | Tony031218/OI | 562f5f45d0448f4eab77643b99b825405a123d92 | [
"MIT"
] | null | null | null | local/codes/c1086_2.cpp | Tony031218/OI | 562f5f45d0448f4eab77643b99b825405a123d92 | [
"MIT"
] | null | null | null | /*************************************************************
* > File Name : c1086_2.cpp
* > Author : Tony
* > Created Time : 2019/11/07 15:32:56
* > Algorithm :
**************************************************************/
#include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0; int f = 1; char ch = getchar();
while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
while (isdigit(ch)) {x = x * 10 + ch - 48; ch = getchar();}
return x * f;
}
const int N = 30010;
const long long inf = 0x3f3f3f3f3f3f3f3f;
int x[N], y[N], c[N], in[N][2];
long long a[N*4][4], add[N*4][4];
int n, _x1, _x2, _y1, _y2, flag;
#define mid ((l+r)>>1)
#define lt (o<<1)
#define rt (o<<1|1)
#define lson lt, l, mid
#define rson rt, mid+1, r
void pushdown(int o, int t) {
a[lt][t] += add[o][t];
a[rt][t] += add[o][t];
add[lt][t] += add[o][t];
add[rt][t] += add[o][t];
add[o][t] = 0;
}
void change(int o, int l, int r, int x, long long d, int t) {
if(l == r && l == x) {
a[o][t] = d;
add[o][t] = 0;
return;
}
if(add[o][t]) pushdown(o, t);
if(x <= mid) change(lson, x, d, t);
else change(rson, x, d, t);
a[o][t] = max(a[lt][t], a[rt][t]);
}
void update(int o, int l, int r, int L, int R, long long d, int t) {
if(L <= l && r <= R) {
add[o][t] += d;
a[o][t] += d;
return;
}
if(add[o][t]) pushdown(o, t);
if(L <= mid) update(lson, L, R, d, t);
if(R > mid) update(rson, L, R, d, t);
a[o][t] = max(a[lt][t], a[rt][t]);
}
void Add(int x, int k) { for(; x <= n; x += x & -x) c[x] += k; }
int ask(int x) { int ans = 0; for(; x; x -= x & -x) ans += c[x]; return ans; }
void dfs(int o, int l, int r, int t) {
if(l == r) {
if(t == 0) {
if(in[l][1]) Add(l, 1);
in[l][0] = 1;
a[o][2] = 0;
change(1, 1, n, l, a[o][t], 2);
}
else if(t == 1) {
if(in[l][0]) Add(l, 1);
in[l][1] = 1;
a[o][3] = 0;
change(1, 1, n, l, a[o][t], 3);
} else if(t == 2) {
if(in[l][0] && in[l][1]) Add(l, -1);
in[l][0] = 0;
} else {
if(in[l][0] && in[l][1]) Add(l, -1);
in[l][1] = 0;
}
a[o][t] = -inf;
return;
}
int lim;
if(t == 0) lim = _x1;
else if(t == 1) lim = _y1;
else if(t == 2) lim = _x2+1;
else lim = _y2+1;
if(a[o][t] >= lim) {
if(add[o][t]) pushdown(o, t);
if(a[lt][t] >= lim) dfs(lson, t);
if(a[rt][t] >= lim) dfs(rson, t);
a[o][t] = max(a[lt][t], a[rt][t]);
}
}
int main() {
int T = read();
while(T--) {
n = read(), _x1 = read(), _y1 = read(), _x2 = read(), _y2 = read();
memset(c, 0, sizeof(c));
memset(add, 0, sizeof(add));
memset(in, 0, sizeof(in));
flag = 0;
for(int t = 0; t < 4; t++)
for(int i = 1; i <= n* 4 - 1; i++)
a[i][t] = -inf;
for(int i = 1; i <= n; i++) x[i] = read(), y[i] = read();
for(int i = 1; i <= n; i++) {
if(x[i] < _x1) {
change(1, 1, n, i, x[i], 0);
}
else if(x[i] <= _x2) {
in[i][0] = 1;
change(1, 1, n, i, x[i], 2);
if(in[i][1])Add(i, 1);
}
if(y[i] < _y1) {
change(1, 1, n, i, y[i], 1);
}
else if(y[i] <= _y2) {
in[i][1] = 1;
change(1, 1, n, i, y[i], 3);
if(in[i][0])Add(i, 1);
}
}
flag = 1;
int m = read();
while(m--) {
int opt = read(), l = read(), r = read();
if(opt == 1) {
int d = read();
update(1, 1, n, l, r, d, 0);
update(1, 1, n, l, r, d, 2);
dfs(1, 1, n, 0);
dfs(1, 1, n, 2);
} else if(opt == 2) {
int d = read();
update(1, 1, n, l, r, d, 1);
update(1, 1, n, l, r, d, 3);
dfs(1, 1, n, 1);
dfs(1, 1, n, 3);
} else {
printf("%d\n", ask(r) - ask(l-1));
}
}
}
return 0;
} | 28.392157 | 78 | 0.35244 | Tony031218 |
69b33e9b2d61a2f538bbd88d6c45c51304a2990e | 448 | inl | C++ | engine/include/xe/serialization/node_view.inl | trbflxr/xe | 13123869a848972e064cb8c6838c4215f034f3d9 | [
"MIT"
] | null | null | null | engine/include/xe/serialization/node_view.inl | trbflxr/xe | 13123869a848972e064cb8c6838c4215f034f3d9 | [
"MIT"
] | null | null | null | engine/include/xe/serialization/node_view.inl | trbflxr/xe | 13123869a848972e064cb8c6838c4215f034f3d9 | [
"MIT"
] | null | null | null | //
// Created by trbflxr on 3/7/2020.
//
#ifndef XE_NODE_VIEW_INL
#define XE_NODE_VIEW_INL
namespace xe {
template<typename T>
void NodeView::setName(const T &value) {
return getNode()->setName<T>(value);
}
template<typename T>
void NodeView::set(const T &value) {
getNode()->set<T>(value);
}
template<typename T>
Node &NodeView::operator=(const T &rhs) {
return *getNode() = rhs;
}
}
#endif //XE_NODE_VIEW_INL
| 16 | 43 | 0.65625 | trbflxr |
69b36f2bf6b05a7a19fc71f5965b6a77b8612532 | 15,698 | cpp | C++ | src/coreclr/src/jit/jitconfig.cpp | abock/runtime | b3346807be96f6089fc1538946b3611f607389e2 | [
"MIT"
] | 6 | 2016-07-25T08:33:10.000Z | 2022-02-10T10:10:51.000Z | src/coreclr/src/jit/jitconfig.cpp | abock/runtime | b3346807be96f6089fc1538946b3611f607389e2 | [
"MIT"
] | 15 | 2017-01-27T20:18:50.000Z | 2019-11-14T00:52:58.000Z | src/coreclr/src/jit/jitconfig.cpp | abock/runtime | b3346807be96f6089fc1538946b3611f607389e2 | [
"MIT"
] | 3 | 2021-02-10T16:20:05.000Z | 2021-03-12T07:55:36.000Z | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#include "jitpch.h"
#ifdef _MSC_VER
#pragma hdrstop
#endif
#include "jitconfig.h"
JitConfigValues JitConfig;
void JitConfigValues::MethodSet::initialize(const WCHAR* list, ICorJitHost* host)
{
assert(m_list == nullptr);
assert(m_names == nullptr);
// Convert the input list to UTF-8
int utf8ListLen = WszWideCharToMultiByte(CP_UTF8, 0, list, -1, nullptr, 0, nullptr, nullptr);
if (utf8ListLen == 0)
{
return;
}
else
{
// char* m_list;
//
m_list = static_cast<char*>(host->allocateMemory(utf8ListLen));
if (WszWideCharToMultiByte(CP_UTF8, 0, list, -1, static_cast<LPSTR>(m_list), utf8ListLen, nullptr, nullptr) ==
0)
{
// Failed to convert the list. Free the memory and ignore the list.
host->freeMemory(static_cast<void*>(m_list));
m_list = nullptr;
return;
}
}
const char SEP_CHAR = ' '; // character used to separate each entry
const char WILD_CHAR = '*'; // character used as the wildcard match everything
char currChar = '?'; // The current character
int nameStart = -1; // Index of the start of the current class or method name
MethodName** lastName = &m_names; // Last entry inserted into the list
bool isQuoted = false; // true while parsing inside a quote "this-is-a-quoted-region"
MethodName currentName; // Buffer used while parsing the current entry
currentName.m_next = nullptr;
currentName.m_methodNameStart = -1;
currentName.m_methodNameLen = -1;
currentName.m_methodNameWildcardAtEnd = false;
currentName.m_classNameStart = -1;
currentName.m_classNameLen = -1;
currentName.m_classNameWildcardAtEnd = false;
currentName.m_numArgs = -1;
enum State
{
NO_NAME,
CLS_NAME,
FUNC_NAME,
ARG_LIST
}; // parsing state machine
State state = NO_NAME;
for (int i = 0; (currChar != '\0'); i++)
{
currChar = m_list[i];
switch (state)
{
case NO_NAME:
// skip over zero or more blanks, then expect CLS_NAME
if (currChar != SEP_CHAR)
{
nameStart = i;
state = CLS_NAME; // we have found the start of the next entry
}
break;
case CLS_NAME:
// Check for a quoted Class Name: (i.e. "MyClass")
if (m_list[nameStart] == '"')
{
// Advance until we see the second "
//
for (; (currChar != '\0'); i++)
{
currChar = m_list[i];
// Advance until we see the second "
if (currChar == '"')
{
break;
}
// or until we see the end of string
if (currChar == '\0')
{
break;
}
}
// skip the initial "
nameStart++;
isQuoted = true;
}
// A colon denotes the end of the Class name and the start of the Method name
if (currChar == ':')
{
// Record the class name
currentName.m_classNameStart = nameStart;
currentName.m_classNameLen = i - nameStart;
// Also accept the double colon syntax as well (i.e class::method)
//
if (m_list[i + 1] == ':')
{
i++;
}
if (isQuoted)
{
// Remove the trailing "
currentName.m_classNameLen--;
isQuoted = false;
}
// Is the first character a wildcard?
if (m_list[currentName.m_classNameStart] == WILD_CHAR)
{
// The class name is a full wildcard; mark it as such.
currentName.m_classNameStart = -1;
currentName.m_classNameLen = -1;
}
// Is there a wildcard at the end of the class name?
//
else if (m_list[currentName.m_classNameStart + currentName.m_classNameLen - 1] == WILD_CHAR)
{
// i.e. bar*:method, will match any class that starts with "bar"
// Remove the trailing WILD_CHAR from class name
currentName.m_classNameWildcardAtEnd = true;
currentName.m_classNameLen--; // backup for WILD_CHAR
}
// The method name will start at the next character
nameStart = i + 1;
// Now expect FUNC_NAME
state = FUNC_NAME;
}
else if ((currChar == '\0') || (currChar == SEP_CHAR) || (currChar == '('))
{
// Treat this as a method name without a class name.
currentName.m_classNameStart = -1;
currentName.m_classNameLen = -1;
goto DONE_FUNC_NAME;
}
break;
case FUNC_NAME:
// Check for a quoted method name: i.e. className:"MyFunc"
//
// Note that we may have already parsed a quoted string above in CLS_NAME, i.e. "Func":
if (!isQuoted && (m_list[nameStart] == '"'))
{
// Advance until we see the second "
//
for (; (currChar != '\0'); i++)
{
currChar = m_list[i];
// Advance until we see the second "
if (currChar == '"')
{
break;
}
// or until we see the end of string
if (currChar == '\0')
{
break;
}
}
// skip the initial "
nameStart++;
isQuoted = true;
}
if ((currChar == '\0') || (currChar == SEP_CHAR) || (currChar == '('))
{
DONE_FUNC_NAME:
assert((currChar == '\0') || (currChar == SEP_CHAR) || (currChar == '('));
// Record the method name
currentName.m_methodNameStart = nameStart;
currentName.m_methodNameLen = i - nameStart;
if (isQuoted)
{
// Remove the trailing "
currentName.m_methodNameLen--;
isQuoted = false;
}
// Is the first character a wildcard?
if (m_list[currentName.m_methodNameStart] == WILD_CHAR)
{
// The method name is a full wildcard; mark it as such.
currentName.m_methodNameStart = -1;
currentName.m_methodNameLen = -1;
}
// Is there a wildcard at the end of the method name?
//
else if (m_list[currentName.m_methodNameStart + currentName.m_methodNameLen - 1] == WILD_CHAR)
{
// i.e. class:foo*, will match any method that starts with "foo"
// Remove the trailing WILD_CHAR from method name
currentName.m_methodNameLen--; // backup for WILD_CHAR
currentName.m_methodNameWildcardAtEnd = true;
}
// should we expect an ARG_LIST?
//
if (currChar == '(')
{
currentName.m_numArgs = -1;
// Expect an ARG_LIST
state = ARG_LIST;
}
else // reached the end of string or a SEP_CHAR
{
assert((currChar == '\0') || (currChar == SEP_CHAR));
currentName.m_numArgs = -1;
// There isn't an ARG_LIST
goto DONE_ARG_LIST;
}
}
break;
case ARG_LIST:
if ((currChar == '\0') || (currChar == ')'))
{
if (currentName.m_numArgs == -1)
{
currentName.m_numArgs = 0;
}
DONE_ARG_LIST:
assert((currChar == '\0') || (currChar == SEP_CHAR) || (currChar == ')'));
// We have parsed an entire method name; create a new entry in the list for it.
MethodName* name = static_cast<MethodName*>(host->allocateMemory(sizeof(MethodName)));
*name = currentName;
assert(name->m_next == nullptr);
*lastName = name;
lastName = &name->m_next;
state = NO_NAME;
// Skip anything after the argument list until we find the next
// separator character. Otherwise if we see "func(a,b):foo" we
// would create entries for "func(a,b)" as well as ":foo".
if (currChar == ')')
{
do
{
currChar = m_list[++i];
} while ((currChar != '\0') && (currChar != SEP_CHAR));
}
}
else // We are looking at the ARG_LIST
{
if ((currChar != SEP_CHAR) && (currentName.m_numArgs == -1))
{
currentName.m_numArgs = 1;
}
// A comma means that there is an additional arg
if (currChar == ',')
{
currentName.m_numArgs++;
}
}
break;
default:
assert(!"Bad state");
break;
}
}
}
void JitConfigValues::MethodSet::destroy(ICorJitHost* host)
{
// Free method names, free the list string, and reset our state
for (MethodName *name = m_names, *next = nullptr; name != nullptr; name = next)
{
next = name->m_next;
host->freeMemory(static_cast<void*>(name));
}
if (m_list != nullptr)
{
host->freeMemory(static_cast<void*>(m_list));
m_list = nullptr;
}
m_names = nullptr;
}
static bool matchesName(const char* const name, int nameLen, bool wildcardAtEnd, const char* const s2)
{
// 's2' must start with 'nameLen' characters of 'name'
if (strncmp(name, s2, nameLen) != 0)
{
return false;
}
// if we don't have a wildcardAtEnd then s2 also need to be zero terminated
if (!wildcardAtEnd && (s2[nameLen] != '\0'))
{
return false;
}
// we have a successful match
return true;
}
bool JitConfigValues::MethodSet::contains(const char* methodName,
const char* className,
CORINFO_SIG_INFO* sigInfo) const
{
int numArgs = sigInfo != nullptr ? sigInfo->numArgs : -1;
// Try to match any the entries in the list.
for (MethodName* name = m_names; name != nullptr; name = name->m_next)
{
// If m_numArgs is valid, check for a mismatch
if (name->m_numArgs != -1 && name->m_numArgs != numArgs)
{
continue;
}
// If m_methodNameStart is valid, check for a mismatch
if (name->m_methodNameStart != -1)
{
const char* expectedMethodName = &m_list[name->m_methodNameStart];
if (!matchesName(expectedMethodName, name->m_methodNameLen, name->m_methodNameWildcardAtEnd, methodName))
{
// C++ embeds the class name into the method name; deal with that here.
const char* colon = strchr(methodName, ':');
if (colon != nullptr && colon[1] == ':' &&
matchesName(expectedMethodName, name->m_methodNameLen, name->m_methodNameWildcardAtEnd, methodName))
{
int classLen = (int)(colon - methodName);
if (name->m_classNameStart == -1 ||
(classLen == name->m_classNameLen &&
strncmp(&m_list[name->m_classNameStart], methodName, classLen) == 0))
{
return true;
}
}
continue;
}
}
// If m_classNameStart is valid, check for a mismatch
if (className == nullptr || name->m_classNameStart == -1 ||
matchesName(&m_list[name->m_classNameStart], name->m_classNameLen, name->m_classNameWildcardAtEnd,
className))
{
return true;
}
#ifdef _DEBUG
// Maybe className doesn't include the namespace. Try to match that
const char* nsSep = strrchr(className, '.');
if (nsSep != nullptr && nsSep != className)
{
const char* onlyClass = nsSep[-1] == '.' ? nsSep : &nsSep[1];
if (matchesName(&m_list[name->m_classNameStart], name->m_classNameLen, name->m_classNameWildcardAtEnd,
onlyClass))
{
return true;
}
}
#endif
}
return false;
}
void JitConfigValues::initialize(ICorJitHost* host)
{
assert(!m_isInitialized);
#define CONFIG_INTEGER(name, key, defaultValue) m_##name = host->getIntConfigValue(key, defaultValue);
#define CONFIG_STRING(name, key) m_##name = host->getStringConfigValue(key);
#define CONFIG_METHODSET(name, key) \
const WCHAR* name##value = host->getStringConfigValue(key); \
m_##name.initialize(name##value, host); \
host->freeStringConfigValue(name##value);
#include "jitconfigvalues.h"
m_isInitialized = true;
}
void JitConfigValues::destroy(ICorJitHost* host)
{
if (!m_isInitialized)
{
return;
}
#define CONFIG_INTEGER(name, key, defaultValue)
#define CONFIG_STRING(name, key) host->freeStringConfigValue(m_##name);
#define CONFIG_METHODSET(name, key) m_##name.destroy(host);
#include "jitconfigvalues.h"
m_isInitialized = false;
}
| 36.849765 | 120 | 0.459485 | abock |
69b5167a792e89900a2af1338999dcf23c49fe65 | 1,000 | hpp | C++ | src/lexer.hpp | JamesWP/anzu | 7894d030d32a6d3c1393756ef80389aa523a0512 | [
"MIT"
] | null | null | null | src/lexer.hpp | JamesWP/anzu | 7894d030d32a6d3c1393756ef80389aa523a0512 | [
"MIT"
] | null | null | null | src/lexer.hpp | JamesWP/anzu | 7894d030d32a6d3c1393756ef80389aa523a0512 | [
"MIT"
] | null | null | null | #pragma once
#include <vector>
#include <string>
#include <unordered_set>
namespace anzu {
static const std::unordered_set<std::string_view> keywords = {
"pop",
"dup",
"swap",
"rot",
"over",
"function",
"if",
"elif",
"else"
"while",
"break",
"continue",
"do",
"end",
"true",
"false",
};
static const std::unordered_set<std::string_view> bin_ops = {
"+",
"-",
"*",
"/",
"%",
"==",
"!=",
"<",
"<=",
">",
">=",
"||",
"&&",
"=",
"->"
};
static const std::unordered_set<std::string_view> symbols = {
"(",
")",
":",
"[",
"]",
","
};
enum class token_type
{
keyword,
bin_op,
symbol,
name,
number,
string
};
auto to_string(token_type type) -> std::string;
struct token
{
std::string text;
int line;
int col;
token_type type;
};
auto lex(const std::string& file) -> std::vector<anzu::token>;
} | 12.820513 | 62 | 0.465 | JamesWP |
69b8abf8ad24267b7ba568e3e1e9a04fc4c51fcf | 1,090 | cpp | C++ | PTA/PAT(Advanced Level)/c++/A1090.cpp | Sunrisepeak/AC-Online-Judge | 5b5ea2eefa2ba48d718957720158fb79134a8fa7 | [
"Apache-2.0"
] | 3 | 2019-03-17T11:47:05.000Z | 2021-12-10T03:41:42.000Z | PTA/PAT(Advanced Level)/c++/A1090.cpp | Sunrisepeak/AC-Online-Judge | 5b5ea2eefa2ba48d718957720158fb79134a8fa7 | [
"Apache-2.0"
] | null | null | null | PTA/PAT(Advanced Level)/c++/A1090.cpp | Sunrisepeak/AC-Online-Judge | 5b5ea2eefa2ba48d718957720158fb79134a8fa7 | [
"Apache-2.0"
] | null | null | null | /*
* @Author: SPeak Shen
* @Date: 2020-06-02 15:35:04
* @Last Modified by: SPeak Shen
* @Last Modified time: 2020-06-02 16:18:32
*/
#include <iostream>
#include <vector>
using namespace std;
struct STreeNode {
//double price;
vector<int> child;
};
STreeNode tree[100000];
int N, number { 0 };
double P, R, maxP { 0.0 };
void countPrice(int root, double price) {
double newPrice = price * (1 + R);
int i = 0;
for (; i < tree[root].child.size(); i++) { // all of child
countPrice(tree[root].child[i], newPrice);
}
if (i == 0) { // leaf Node
if (price == maxP) {
number++;
}
if (price > maxP) {
maxP = price;
number = 1;
}
}
}
int main() {
cin >> N >> P >> R;
int root = -1;
for (int i = 0; i < N; i++) {
int temp;
cin >> temp;
if (temp < 0) {
root = i;
} else {
tree[temp].child.push_back(i);
}
}
R /= 100;
countPrice(root, P);
printf("%.2f %d", maxP, number);
return 0;
} | 19.818182 | 63 | 0.479817 | Sunrisepeak |
69c10b4698fbd8b0ec8bfd85a487868575b9a719 | 4,632 | cpp | C++ | scene.cpp | LuanQBarbosa/ray-tracer-university-project | 9fd8ab9d8e8b98dc186e7353788ed8a93862cb2b | [
"MIT"
] | null | null | null | scene.cpp | LuanQBarbosa/ray-tracer-university-project | 9fd8ab9d8e8b98dc186e7353788ed8a93862cb2b | [
"MIT"
] | null | null | null | scene.cpp | LuanQBarbosa/ray-tracer-university-project | 9fd8ab9d8e8b98dc186e7353788ed8a93862cb2b | [
"MIT"
] | null | null | null | #include "scene.h"
Scene::Scene( void )
{}
Scene::~Scene( void )
{
if ( bvh_ )
{
delete bvh_;
bvh_ = nullptr;
}
}
// bool Scene::intersect( const Ray &ray,
// IntersectionRecord &intersection_record ) const
// {
// bool intersection_result = false;
// IntersectionRecord tmp_intersection_record;
// std::size_t num_primitives = primitives_.size();
// // Loops over the list of primitives, testing the intersection of each primitive against the given ray
// for ( std::size_t primitive_id = 0; primitive_id < num_primitives; primitive_id++ )
// if ( primitives_[primitive_id]->intersect( ray, tmp_intersection_record ) )
// if ( ( tmp_intersection_record.t_ < intersection_record.t_ ) && ( tmp_intersection_record.t_ > 0.0 ) )
// {
// intersection_record = tmp_intersection_record;
// intersection_result = true; // the ray intersects a primitive!
// }
// return intersection_result;
// }
bool Scene::intersect( const Ray &ray,
IntersectionRecord &intersection_record ) const
{
bool intersection_result = false;
IntersectionRecord tmp_intersection_record;
intersection_result = bvh_->intersect( ray, intersection_record);
return intersection_result;
}
void Scene::buildBVH( void )
{
bvh_ = new BVH( primitives_ );
std::clog << std::endl;
}
void Scene::load( void )
{
Material m1{ new Diffuse{ glm::vec3{ 0.5f, 0.5f, 0.5f } }, glm::vec3{ 0.0f, 0.0f, 0.0f } };
Material m2{ new Diffuse{ glm::vec3{ 0.0f, 0.0f, 0.0f } }, glm::vec3{ 40.0f, 40.0f, 40.0f } };
Material m3{ new Diffuse{ glm::vec3{ 0.0f, 0.0f, 1.0f } }, glm::vec3{ 12.5f, 12.5f, 12.5f } };
// Spheres
// Sphere *s1 = new Sphere(glm::vec3(-1.5f, -1.0f, 1.0f), 0.75f, Material{ new SmoothDieletric{ glm::vec3{ 69.0f, 74.0f, 208.0f } / 255.0f }, glm::vec3{ 0.0f, 0.0f, 0.0f } });
// primitives_.push_back(Primitive::PrimitiveUniquePtr(s1));
// Sphere *s2 = new Sphere(glm::vec3(0.0f, -1.0f, 0.0f), 0.75f, Material{ new CookTorrance{ glm::vec3{ 44.0f, 242.0f, 97.0f } / 255.0f }, glm::vec3{ 0.0f, 0.0f, 0.0f } });
// primitives_.push_back(Primitive::PrimitiveUniquePtr(s2));
// Sphere *s3 = new Sphere(glm::vec3(1.5f, -1.0f, 1.0f), 0.75f, Material{ new PerfectReflector{ glm::vec3{ 15.0f, 210.0f, 8.0f } / 255.0f }, glm::vec3{ 0.0f, 0.0f, 0.0f } });
// primitives_.push_back(Primitive::PrimitiveUniquePtr(s3));
// Sphere *s1 = new Sphere(glm::vec3(0.0f, 0.0f, 0.0f), 1.0f, Material{ new SmoothDieletric{ glm::vec3{ 69.0f, 74.0f, 208.0f } / 255.0f }, glm::vec3{ 0.0f, 0.0f, 0.0f } });
// primitives_.push_back(Primitive::PrimitiveUniquePtr(s1));
// Sphere *s2 = new Sphere(glm::vec3(0.0f, 0.0f, 0.0f), 0.99f, Material{ new Diffuse{ glm::vec3{ 255.0f, 0.0f, 0.0f } / 255.0f }, glm::vec3{ 0.0f, 0.0f, 0.0f } });
// primitives_.push_back(Primitive::PrimitiveUniquePtr(s2));
// Lights
// Sphere *s4 = new Sphere(glm::vec3(-0.35f, 3.5f, 0.0f), 1.0f, m3);
// primitives_.push_back(Primitive::PrimitiveUniquePtr(s4));
Sphere *s4 = new Sphere(glm::vec3(-0.95f, 1.0f, 0.75f), 0.15f, m3);
primitives_.push_back(Primitive::PrimitiveUniquePtr(s4));
// Sphere *s5 = new Sphere(glm::vec3(0.0f, 4.0f, -0.75f), 1.5f, m3);
// primitives_.push_back(Primitive::PrimitiveUniquePtr(s5));
// Sphere *s6 = new Sphere(glm::vec3(0.0f, 4.0f, -2.5f), 1.5f, m3);
// primitives_.push_back(Primitive::PrimitiveUniquePtr(s6));
// Sphere *s7 = new Sphere(glm::vec3(0.0f, 4.0f, -4.25f), 1.5f, m3);
// primitives_.push_back(Primitive::PrimitiveUniquePtr(s7));
}
void Scene::loadObj( const char* obj, glm::vec3 position, float size, Material material )
{
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(obj,
aiProcess_CalcTangentSpace |
aiProcess_Triangulate |
aiProcess_JoinIdenticalVertices |
aiProcess_SortByPType);
for (unsigned int j = 0; j < scene->mNumMeshes; j++) {
auto mesh = scene->mMeshes[j];
for (unsigned int i = 0; i < mesh->mNumFaces; i++) {
auto face = mesh->mFaces[i];
auto v1 = mesh->mVertices[face.mIndices[0]];
auto v2 = mesh->mVertices[face.mIndices[1]];
auto v3 = mesh->mVertices[face.mIndices[2]];
Triangle *triangle = new Triangle((glm::vec3(v1.x, v1.y, v1.z)) * size + position,
(glm::vec3(v2.x, v2.y, v2.z)) * size + position,
(glm::vec3(v3.x, v3.y, v3.z)) * size + position,
material);
primitives_.push_back( Primitive::PrimitiveUniquePtr(triangle));
}
}
}
| 38.280992 | 178 | 0.626295 | LuanQBarbosa |
69c34363ead08eb2fa5fb0de93291c399e405049 | 6,027 | cpp | C++ | Engine/Plugins/Media/MediaPlayerEditor/Source/MediaPlayerEditor/Private/Factories/MediaPlayerFactoryNew.cpp | windystrife/UnrealEngine_NVIDIAGameWork | b50e6338a7c5b26374d66306ebc7807541ff815e | [
"MIT"
] | 1 | 2022-01-29T18:36:12.000Z | 2022-01-29T18:36:12.000Z | Engine/Plugins/Media/MediaPlayerEditor/Source/MediaPlayerEditor/Private/Factories/MediaPlayerFactoryNew.cpp | windystrife/UnrealEngine_NVIDIAGameWork | b50e6338a7c5b26374d66306ebc7807541ff815e | [
"MIT"
] | null | null | null | Engine/Plugins/Media/MediaPlayerEditor/Source/MediaPlayerEditor/Private/Factories/MediaPlayerFactoryNew.cpp | windystrife/UnrealEngine_NVIDIAGameWork | b50e6338a7c5b26374d66306ebc7807541ff815e | [
"MIT"
] | null | null | null | // Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "MediaPlayerFactoryNew.h"
#include "AssetToolsModule.h"
#include "Editor.h"
#include "EditorStyleSet.h"
#include "IAssetTools.h"
#include "Input/Reply.h"
#include "Misc/PackageName.h"
#include "Modules/ModuleManager.h"
#include "Layout/Visibility.h"
#include "MediaPlayer.h"
#include "MediaTexture.h"
#include "Styling/SlateTypes.h"
#include "Widgets/DeclarativeSyntaxSupport.h"
#include "Widgets/SBoxPanel.h"
#include "Widgets/SCompoundWidget.h"
#include "Widgets/SWindow.h"
#include "Widgets/Input/SButton.h"
#include "Widgets/Input/SCheckBox.h"
#include "Widgets/Layout/SBorder.h"
#include "Widgets/Layout/SUniformGridPanel.h"
#include "Widgets/Text/STextBlock.h"
#include "Factories/MediaTextureFactoryNew.h"
#define LOCTEXT_NAMESPACE "UMediaPlayerFactoryNew"
/* Local helpers
*****************************************************************************/
class SMediaPlayerFactoryDialog
: public SCompoundWidget
{
public:
SLATE_BEGIN_ARGS(SMediaPlayerFactoryDialog) { }
SLATE_END_ARGS()
/** Construct this widget. */
void Construct(const FArguments& InArgs, FMediaPlayerFactoryNewOptions& InOptions, TSharedRef<SWindow> InWindow)
{
Options = &InOptions;
Window = InWindow;
ChildSlot
[
SNew(SBorder)
.Visibility(EVisibility::Visible)
.BorderImage(FEditorStyle::GetBrush("Menu.Background"))
[
SNew(SVerticalBox)
+ SVerticalBox::Slot()
.FillHeight(1)
.VAlign(VAlign_Top)
[
SNew(SBorder)
.BorderImage(FEditorStyle::GetBrush("ToolPanel.GroupBorder"))
.Padding(4.0f)
.Content()
[
SNew(SVerticalBox)
+ SVerticalBox::Slot()
[
SNew(STextBlock)
.Text(LOCTEXT("CreateAdditionalAssetsLabel", "Additional assets to create and link to the Media Player:"))
]
+ SVerticalBox::Slot()
.Padding(0.0f, 6.0f, 0.0f, 0.0f)
[
SNew(SCheckBox)
.IsChecked(Options->CreateVideoTexture ? ECheckBoxState::Checked : ECheckBoxState::Unchecked)
.OnCheckStateChanged_Lambda([this](ECheckBoxState CheckBoxState) {
Options->CreateVideoTexture = (CheckBoxState == ECheckBoxState::Checked);
})
.Content()
[
SNew(STextBlock)
.Text(LOCTEXT("CreateVideoTextureLabel", "Video output MediaTexture asset"))
]
]
]
]
+ SVerticalBox::Slot()
.AutoHeight()
.HAlign(HAlign_Right)
.VAlign(VAlign_Bottom)
.Padding(8)
[
SNew(SUniformGridPanel)
.SlotPadding(FEditorStyle::GetMargin("StandardDialog.SlotPadding"))
.MinDesiredSlotWidth(FEditorStyle::GetFloat("StandardDialog.MinDesiredSlotWidth"))
.MinDesiredSlotHeight(FEditorStyle::GetFloat("StandardDialog.MinDesiredSlotHeight"))
+ SUniformGridPanel::Slot(0, 0)
[
SNew(SButton)
.HAlign(HAlign_Center)
.ContentPadding(FEditorStyle::GetMargin("StandardDialog.ContentPadding"))
.OnClicked_Lambda([this]() -> FReply { CloseDialog(true); return FReply::Handled(); })
.Text(LOCTEXT("OkButtonLabel", "OK"))
]
+ SUniformGridPanel::Slot(1, 0)
[
SNew(SButton)
.HAlign(HAlign_Center)
.ContentPadding(FEditorStyle::GetMargin("StandardDialog.ContentPadding"))
.OnClicked_Lambda([this]() -> FReply { CloseDialog(false); return FReply::Handled(); })
.Text(LOCTEXT("CancelButtonLabel", "Cancel"))
]
]
]
];
}
protected:
void CloseDialog(bool InOkClicked)
{
Options->OkClicked = InOkClicked;
if (Window.IsValid())
{
Window.Pin()->RequestDestroyWindow();
}
}
private:
FMediaPlayerFactoryNewOptions* Options;
TWeakPtr<SWindow> Window;
};
/* UMediaPlayerFactoryNew structors
*****************************************************************************/
UMediaPlayerFactoryNew::UMediaPlayerFactoryNew( const FObjectInitializer& ObjectInitializer )
: Super(ObjectInitializer)
{
SupportedClass = UMediaPlayer::StaticClass();
bCreateNew = true;
bEditAfterNew = true;
}
/* UFactory interface
*****************************************************************************/
bool UMediaPlayerFactoryNew::ConfigureProperties()
{
Options.CreateVideoTexture = false;
Options.OkClicked = false;
TSharedRef<SWindow> Window = SNew(SWindow)
.Title(LOCTEXT("CreateMediaPlayerDialogTitle", "Create Media Player"))
.ClientSize(FVector2D(400, 160))
.SupportsMinimize(false)
.SupportsMaximize(false);
Window->SetContent(SNew(SMediaPlayerFactoryDialog, Options, Window));
GEditor->EditorAddModalWindow(Window);
return Options.OkClicked;
}
UObject* UMediaPlayerFactoryNew::FactoryCreateNew(UClass* InClass, UObject* InParent, FName InName, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn)
{
auto NewMediaPlayer = NewObject<UMediaPlayer>(InParent, InClass, InName, Flags);
if ((NewMediaPlayer != nullptr) && Options.CreateVideoTexture)
{
IAssetTools& AssetTools = FModuleManager::Get().LoadModuleChecked<FAssetToolsModule>("AssetTools").Get();
const FString ParentName = InParent->GetOutermost()->GetName();
FString OutAssetName;
FString OutPackageName;
AssetTools.CreateUniqueAssetName(ParentName, TEXT("_Video"), OutPackageName, OutAssetName);
const FString PackagePath = FPackageName::GetLongPackagePath(OutPackageName);
auto Factory = NewObject<UMediaTextureFactoryNew>();
auto VideoTexture = Cast<UMediaTexture>(AssetTools.CreateAsset(OutAssetName, PackagePath, UMediaTexture::StaticClass(), Factory));
if (VideoTexture != nullptr)
{
VideoTexture->MediaPlayer = NewMediaPlayer;
}
}
return NewMediaPlayer;
}
uint32 UMediaPlayerFactoryNew::GetMenuCategories() const
{
return EAssetTypeCategories::Media;
}
bool UMediaPlayerFactoryNew::ShouldShowInNewMenu() const
{
return true;
}
#undef LOCTEXT_NAMESPACE
| 27.902778 | 161 | 0.671478 | windystrife |
69c41e7ae8b1193da033a4dc394559871373fd16 | 1,903 | cc | C++ | depends/dbcommon/src/dbcommon/utils/cutils.cc | YangHao666666/hawq | 10cff8350f1ba806c6fec64eb67e0e6f6f24786c | [
"Artistic-1.0-Perl",
"ISC",
"bzip2-1.0.5",
"TCL",
"Apache-2.0",
"BSD-3-Clause-No-Nuclear-License-2014",
"MIT",
"PostgreSQL",
"BSD-3-Clause"
] | 1 | 2020-05-11T01:39:13.000Z | 2020-05-11T01:39:13.000Z | depends/dbcommon/src/dbcommon/utils/cutils.cc | YangHao666666/hawq | 10cff8350f1ba806c6fec64eb67e0e6f6f24786c | [
"Artistic-1.0-Perl",
"ISC",
"bzip2-1.0.5",
"TCL",
"Apache-2.0",
"BSD-3-Clause-No-Nuclear-License-2014",
"MIT",
"PostgreSQL",
"BSD-3-Clause"
] | 1 | 2021-03-01T02:57:26.000Z | 2021-03-01T02:57:26.000Z | depends/dbcommon/src/dbcommon/utils/cutils.cc | YangHao666666/hawq | 10cff8350f1ba806c6fec64eb67e0e6f6f24786c | [
"Artistic-1.0-Perl",
"ISC",
"bzip2-1.0.5",
"TCL",
"Apache-2.0",
"BSD-3-Clause-No-Nuclear-License-2014",
"MIT",
"PostgreSQL",
"BSD-3-Clause"
] | 1 | 2020-05-03T07:29:21.000Z | 2020-05-03T07:29:21.000Z | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#include "dbcommon/utils/cutils.h"
namespace dbcommon {
static void outputCallStack() {
int nptrs = 0;
void* buffer[64];
char** strings;
nptrs = backtrace(buffer, 64);
LOG_INFO("backtrace() returned %d addresses\n", nptrs);
strings = backtrace_symbols(buffer, nptrs);
if (strings == nullptr) {
return;
}
for (int j = 0; j < nptrs; j++) {
LOG_INFO("callstack(%d) %s\n", j, strings[j]);
}
free(strings);
}
char* cnmalloc(size_t size) {
if (size > 1024LU * 1024 * 1024) {
outputCallStack();
}
char* ret = static_cast<char*>(::malloc(size));
if (ret == nullptr) {
LOG_ERROR(ERRCODE_OUT_OF_MEMORY,
"cnmalloc() failed to allocate memory, size %zu", size);
}
return ret;
}
char* cnrealloc(void* ptr, size_t size) {
if (size > 1024LU * 1024 * 1024) {
outputCallStack();
}
char* ret = static_cast<char*>(::realloc(ptr, size));
if (ret == nullptr && size > 0) {
LOG_ERROR(ERRCODE_OUT_OF_MEMORY,
"cnrealloc() failed to allocate memory, size %zu", size);
}
return ret;
}
} // namespace dbcommon
| 26.430556 | 71 | 0.671571 | YangHao666666 |
69c588a34ad6018a8ba04f265c76749673132a96 | 1,679 | cpp | C++ | c++/program.cpp | foxtrotzulu94/LanguageBenchmarkGame | 29c92c47c860d426409047a8408eaa52284a0cff | [
"MIT"
] | null | null | null | c++/program.cpp | foxtrotzulu94/LanguageBenchmarkGame | 29c92c47c860d426409047a8408eaa52284a0cff | [
"MIT"
] | null | null | null | c++/program.cpp | foxtrotzulu94/LanguageBenchmarkGame | 29c92c47c860d426409047a8408eaa52284a0cff | [
"MIT"
] | null | null | null | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include "argument_holder.hpp"
#include "file_result.hpp"
#include "worker.hpp"
#include "utils.hpp"
void PrintUsage(){
using namespace std;
cout << endl;
cout << " Usage: program.out <dir_a> <dir_b> [options]" << endl << endl;
cout << " C++ implementation of the language benchmarking trial" << endl << endl;
cout << " Options:" << endl << endl;
cout << " -u, --ignore-unchanged\t Ignore unchanged files in the final output" << endl;
cout << " --md5\t\t\t MD5 Hash [Default]" << endl;
cout << " --sha1\t\t\t SHA1 Hash" << endl;
cout << " --sha256\t\t\t SHA256 Hash" << endl;
}
int main(int argc, char** argv){
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
ArgumentHolder args;
if(!args.Parse(argc, argv)){
std::cout << "Error parsing arguments!" << std::endl;
PrintUsage();
return 1;
}
Worker work(args.ChecksumName);
std::cout << "Starting diff of "<< args.DirectoryA << " and " << args.DirectoryB << " ("
<< args.ChecksumName << ")" << std::endl;
std::cout << "Start time " << GetFormattedDateTime() << std::endl;
auto promiseA = work.scanDirectory(args.DirectoryA.string());
auto promiseB = work.scanDirectory(args.DirectoryB.string());
auto resultA = promiseA.get(), resultB = promiseB.get();
work.Reconcile(resultA, resultB, true);
work.WriteResult(args.DirectoryA.string(), args.DirectoryB.string(), "reference.patch", args.ShouldIgnoreUnchanged);
std::cout << std::endl << "End time " << GetFormattedDateTime() << std::endl;
}
| 34.979167 | 120 | 0.622394 | foxtrotzulu94 |
69c63bdf96afc38e8fe7fba0b9e752be7677271e | 1,145 | cpp | C++ | math/EXCRT.cpp | jasonfan0328/algorithm | 3769a03c5c530381e3ee08c416c3593c96ee966c | [
"CC0-1.0"
] | 3 | 2021-05-03T01:14:04.000Z | 2021-05-05T05:47:56.000Z | math/EXCRT.cpp | jason-fxz/algorithm | 3769a03c5c530381e3ee08c416c3593c96ee966c | [
"CC0-1.0"
] | null | null | null | math/EXCRT.cpp | jason-fxz/algorithm | 3769a03c5c530381e3ee08c416c3593c96ee966c | [
"CC0-1.0"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100010;
ll a[N], b[N]; int n;
ll mul(ll a, ll b, ll mod) {
ll r = 0;
a = (a % mod + mod) % mod;
b = (b % mod + mod) % mod;
while (b) {
if (b & 1) r = (r + a) % mod;
a = (a << 1) % mod; b >>= 1;
} return r;
}
ll gcd(ll a, ll b) {
return !b ? a : gcd(b, a % b);
}
ll exgcd(ll a, ll b, ll &x, ll &y) {
if (!b) {x = 1, y = 0; return a;}
ll d = exgcd(b, a % b, x, y);
swap(x, y); y -= a / b * x;
return d;
}
// x=ai (mod mi)
ll EXCRT(int n, ll a[], ll m[]) {
for (int i = 2; i <= n; i++) {
ll d = gcd(m[i - 1], m[i]), x, y;
if ((a[i] - a[i - 1]) % d != 0) return -1; // 无解
exgcd(m[i - 1] / d, m[i] / d, x, y);
m[i] = m[i] / gcd(m[i], m[i - 1]) * m[i - 1];
a[i] = (a[i - 1] + mul(mul((a[i] - a[i - 1]) / d, x, m[i]), m[i - 1], m[i])) % m[i];
a[i] = (a[i] + m[i]) % m[i];
}
return a[n];
}
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++)
scanf("%lld%lld", &a[i], &b[i]);
ll ans = EXCRT(n, b, a);
printf("%lld\n", ans);
} | 27.261905 | 92 | 0.385153 | jasonfan0328 |
69cc7e9235f2a4b25bab741ce89177266b178c60 | 3,338 | cpp | C++ | src/emu/dinetwork.cpp | Robbbert/messui | 49b756e2140d8831bc81335298ee8c5471045e79 | [
"BSD-3-Clause"
] | 26 | 2015-03-31T06:25:51.000Z | 2021-12-14T09:29:04.000Z | src/emu/dinetwork.cpp | Robbbert/messui | 49b756e2140d8831bc81335298ee8c5471045e79 | [
"BSD-3-Clause"
] | null | null | null | src/emu/dinetwork.cpp | Robbbert/messui | 49b756e2140d8831bc81335298ee8c5471045e79 | [
"BSD-3-Clause"
] | 10 | 2015-03-27T05:45:51.000Z | 2022-02-04T06:57:36.000Z | // license:BSD-3-Clause
// copyright-holders:Carl, Miodrag Milanovic
#include "emu.h"
#include "osdnet.h"
device_network_interface::device_network_interface(const machine_config &mconfig, device_t &device, float bandwidth)
: device_interface(device, "network")
{
m_promisc = false;
m_bandwidth = bandwidth;
set_mac("\0\0\0\0\0\0");
m_intf = -1;
m_loopback_control = false;
}
device_network_interface::~device_network_interface()
{
}
void device_network_interface::interface_pre_start()
{
m_send_timer = device().machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(device_network_interface::send_complete), this));
m_recv_timer = device().machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(device_network_interface::recv_complete), this));
}
void device_network_interface::interface_post_start()
{
device().save_item(NAME(m_loopback_control));
}
int device_network_interface::send(u8 *buf, int len, int fcs)
{
// TODO: enable this check when other devices implement delayed transmit
//if (m_send_timer->enabled())
//throw emu_fatalerror("%s(%s): attempted to transmit while transmit already in progress", device().shortname(), device().tag());
int result = 0;
if (m_loopback_control)
{
// loop data back to receiver
result = recv_start_cb(buf, len);
if (result)
{
// schedule receive complete callback
m_recv_timer->adjust(attotime::from_ticks(len, m_bandwidth * 1'000'000 / 8), result);
}
}
else if (m_dev)
{
// send the data (excluding fcs)
result = m_dev->send(buf, len - fcs);
if (result)
result += fcs;
}
// schedule transmit complete callback
m_send_timer->adjust(attotime::from_ticks(len, m_bandwidth * 1'000'000 / 8), result);
return result;
}
TIMER_CALLBACK_MEMBER(device_network_interface::send_complete)
{
send_complete_cb(param);
}
void device_network_interface::recv_cb(u8 *buf, int len)
{
if (m_recv_timer->enabled())
throw emu_fatalerror("%s(%s): attempted to receive while receive already in progress", device().shortname(), device().tag());
int result = 0;
// process the received data
if (!m_loopback_control)
result = recv_start_cb(buf, len);
if (result)
{
// stop receiving more data from the network
if (m_dev)
m_dev->stop();
// schedule receive complete callback
m_recv_timer->adjust(attotime::from_ticks(len, m_bandwidth * 1'000'000 / 8), result);
}
}
TIMER_CALLBACK_MEMBER(device_network_interface::recv_complete)
{
recv_complete_cb(param);
// start receiving data from the network again
if (m_dev && !m_loopback_control)
m_dev->start();
}
void device_network_interface::set_promisc(bool promisc)
{
m_promisc = promisc;
if(m_dev) m_dev->set_promisc(promisc);
}
void device_network_interface::set_mac(const char *mac)
{
memcpy(m_mac, mac, 6);
if(m_dev) m_dev->set_mac(m_mac);
}
void device_network_interface::set_interface(int id)
{
if(m_dev)
m_dev->stop();
m_dev.reset(open_netdev(id, this, (int)(m_bandwidth*1000000/8.0f/1500)));
if(!m_dev) {
device().logerror("Network interface %d not found\n", id);
id = -1;
}
m_intf = id;
}
void device_network_interface::set_loopback(bool loopback)
{
if (m_loopback_control == loopback)
return;
m_loopback_control = loopback;
if (m_dev)
{
if (loopback)
m_dev->stop();
else if (!m_recv_timer->enabled())
m_dev->start();
}
}
| 24.014388 | 136 | 0.727082 | Robbbert |
69ccc19cb17a6de0aeb0dc8a1c7c6b06b421becf | 33,356 | cpp | C++ | Source/GameJoltAPI/gjAPI.cpp | Sasurai/Dodge | bb7233b20bb1f8f0e6cae2d53c3993aea486109c | [
"MIT"
] | 1 | 2020-01-08T05:36:59.000Z | 2020-01-08T05:36:59.000Z | Source/GameJoltAPI/gjAPI.cpp | Sasurai/Dodge | bb7233b20bb1f8f0e6cae2d53c3993aea486109c | [
"MIT"
] | null | null | null | Source/GameJoltAPI/gjAPI.cpp | Sasurai/Dodge | bb7233b20bb1f8f0e6cae2d53c3993aea486109c | [
"MIT"
] | null | null | null | ///////////////////////////////////////////////////////////////////
//*-------------------------------------------------------------*//
//| Part of the Game Jolt API C++ Library (http://gamejolt.com) |//
//*-------------------------------------------------------------*//
//| Released under the zlib License |//
//| More information available in the README.md |//
//*-------------------------------------------------------------*//
///////////////////////////////////////////////////////////////////
#include "gjAPI.h"
#include <sstream>
#include <iostream>
#include <algorithm>
// ****************************************************************
/* constructor */
gjAPI::gjInterUser::gjInterUser(gjAPI* pAPI, gjNetwork* pNetwork)noexcept
: m_pAPI (pAPI)
, m_pNetwork (pNetwork)
{
// create NULL user for secure object handling
gjData pNullData;
pNullData["id"] = "0";
pNullData["username"] = "NOT FOUND";
pNullData["type"] = "Guest";
pNullData["avatar_url"] = GJ_API_AVATAR_DEFAULT;
m_apUser[0] = new gjUser(pNullData, m_pAPI);
// create guest user for secure object handling
gjData pGuestData;
pGuestData["id"] = "-1";
pGuestData["username"] = "Guest";
pGuestData["type"] = "Guest";
pGuestData["avatar_url"] = GJ_API_AVATAR_DEFAULT;
m_apUser[-1] = new gjUser(pGuestData, m_pAPI);
}
// ****************************************************************
/* destructor */
gjAPI::gjInterUser::~gjInterUser()
{
// delete all users
FOR_EACH(it, m_apUser)
SAFE_DELETE(it->second)
// clear container
m_apUser.clear();
}
// ****************************************************************
/* access user objects directly (may block) */
gjUser* gjAPI::gjInterUser::GetUser(const int& iID)
{
gjUserPtr pOutput;
if(this->__CheckCache(iID, &pOutput) == GJ_OK) return pOutput;
if(this->FetchUserNow(iID, &pOutput) == GJ_OK) return pOutput;
return m_apUser[0];
}
gjUser* gjAPI::gjInterUser::GetUser(const std::string& sName)
{
gjUserPtr pOutput;
if(this->__CheckCache(sName, &pOutput) == GJ_OK) return pOutput;
if(this->FetchUserNow(sName, &pOutput) == GJ_OK) return pOutput;
return m_apUser[0];
}
// ****************************************************************
/* access main user object directly (may block) */
gjUser* gjAPI::gjInterUser::GetMainUser()
{
if(!m_pAPI->IsConnected()) return m_apUser[0];
return this->GetUser(m_pAPI->GetUserName());
}
// ****************************************************************
/* delete all cached user objects */
void gjAPI::gjInterUser::ClearCache()
{
// save NULL user and guest user
gjUser* pNull = m_apUser[0]; m_apUser.erase(0);
gjUser* pGuest = m_apUser[-1]; m_apUser.erase(-1);
// delete users
FOR_EACH(it, m_apUser)
SAFE_DELETE(it->second)
// clear container
m_apUser.clear();
m_apUser[0] = pNull;
m_apUser[-1] = pGuest;
}
// ****************************************************************
/* check for cached user objects */
int gjAPI::gjInterUser::__CheckCache(const int& iID, gjUserPtr* ppOutput)
{
// retrieve cached user
if(m_apUser.count(iID))
{
if(ppOutput) (*ppOutput) = m_apUser[iID];
return GJ_OK;
}
return GJ_NO_DATA_FOUND;
}
int gjAPI::gjInterUser::__CheckCache(const std::string& sName, gjUserPtr* ppOutput)
{
// retrieve cached user
FOR_EACH(it, m_apUser)
{
if(it->second->GetName() == sName)
{
if(ppOutput) (*ppOutput) = it->second;
return GJ_OK;
}
}
return GJ_NO_DATA_FOUND;
}
// ****************************************************************
/* process user data and cache user objects */
int gjAPI::gjInterUser::__Process(const std::string& sData, void* pAdd, gjUserPtr* ppOutput)
{
// parse output
gjDataList aaReturn;
if(m_pAPI->ParseRequestKeypair(sData, &aaReturn) != GJ_OK)
{
m_pAPI->ErrorLogAdd("API Error: could not parse user");
if(ppOutput) (*ppOutput) = m_apUser[0];
return GJ_REQUEST_FAILED;
}
// create and cache user object
gjUser* pNewUser = new gjUser(aaReturn[0], m_pAPI);
const int iID = pNewUser->GetID();
if(m_apUser.count(iID))
{
SAFE_DELETE(pNewUser)
pNewUser = m_apUser[iID];
}
else m_apUser[iID] = pNewUser;
if(ppOutput) (*ppOutput) = pNewUser;
return pNewUser ? GJ_OK : GJ_NO_DATA_FOUND;
}
// ****************************************************************
/* constructor */
gjAPI::gjInterTrophy::gjInterTrophy(gjAPI* pAPI, gjNetwork* pNetwork)noexcept
: m_iCache (0)
, m_pAPI (pAPI)
, m_pNetwork (pNetwork)
{
// create NULL trophy for secure object handling
gjData pNullData;
pNullData["id"] = "0";
pNullData["title"] = "NOT FOUND";
pNullData["difficulty"] = "Bronze";
pNullData["image_url"] = GJ_API_TROPHY_DEFAULT_1;
m_apTrophy[0] = new gjTrophy(pNullData, m_pAPI);
// reserve some memory
m_aiSort.reserve(GJ_API_RESERVE_TROPHY);
m_aiSecret.reserve(GJ_API_RESERVE_TROPHY);
m_aiHidden.reserve(GJ_API_RESERVE_TROPHY);
// retrieve offline-cached trophy data
this->__LoadOffCache();
}
// ****************************************************************
/* destructor */
gjAPI::gjInterTrophy::~gjInterTrophy()
{
// delete all trophies
FOR_EACH(it, m_apTrophy)
SAFE_DELETE(it->second)
// clear containers
m_apTrophy.clear();
m_aiSort.clear();
m_aiSecret.clear();
m_aiHidden.clear();
}
// ****************************************************************
/* access trophy objects directly (may block) */
gjTrophy* gjAPI::gjInterTrophy::GetTrophy(const int& iID)
{
if(!m_pAPI->IsConnected() && m_iCache == 0) return m_apTrophy[0];
if(m_apTrophy.size() <= 1)
{
// wait for prefetching
if(GJ_API_PREFETCH) m_pNetwork->Wait(2);
if(m_apTrophy.size() <= 1)
{
gjTrophyList apOutput;
this->FetchTrophiesNow(0, &apOutput);
}
}
return m_apTrophy.count(iID) ? m_apTrophy[iID] : m_apTrophy[0];
}
// ****************************************************************
/* delete all cached trophy objects */
void gjAPI::gjInterTrophy::ClearCache(const bool& bFull)
{
const bool bRemoveAll = bFull || !GJ_API_OFFCACHE_TROPHY;
if(bRemoveAll)
{
// save NULL trophy
gjTrophy* pNull = m_apTrophy[0];
m_apTrophy.erase(0);
// delete trophies
FOR_EACH(it, m_apTrophy)
SAFE_DELETE(it->second)
// clear container
m_apTrophy.clear();
m_apTrophy[0] = pNull;
}
// set cache status
m_iCache = bRemoveAll ? 0 : 1;
}
// ****************************************************************
/* define layout of the returned trophy list */
void gjAPI::gjInterTrophy::SetSort(const int* piIDList, const size_t& iNum)
{
if(iNum)
{
// clear sort list
m_aiSort.clear();
// add IDs to sort list
for(size_t i = 0; i < iNum; ++i)
m_aiSort.push_back(piIDList[i]);
}
// apply sort attribute
FOR_EACH(it, m_apTrophy)
it->second->__SetSort(0);
for(size_t i = 0; i < m_aiSort.size(); ++i)
if(m_apTrophy.count(m_aiSort[i])) m_apTrophy[m_aiSort[i]]->__SetSort(int(i+1));
}
// ****************************************************************
/* define secret trophy objects */
void gjAPI::gjInterTrophy::SetSecret(const int* piIDList, const size_t& iNum)
{
if(iNum)
{
// clear secret list
m_aiSecret.clear();
// add IDs to secret list
for(size_t i = 0; i < iNum; ++i)
m_aiSecret.push_back(piIDList[i]);
}
// apply secret attribute
FOR_EACH(it, m_apTrophy)
it->second->__SetSecret(false);
FOR_EACH(it, m_aiSecret)
if(m_apTrophy.count(*it)) m_apTrophy[*it]->__SetSecret(true);
}
// ****************************************************************
/* define hidden trophy objects */
void gjAPI::gjInterTrophy::SetHidden(const int* piIDList, const size_t& iNum)
{
if(iNum)
{
// clear hidden list
m_aiHidden.clear();
// add IDs to hidden list
for(size_t i = 0; i < iNum; ++i)
m_aiHidden.push_back(piIDList[i]);
}
// apply hidden attribute and remove all hidden trophy objects
FOR_EACH(it, m_aiHidden)
if(m_apTrophy.count(*it)) m_apTrophy.erase(m_apTrophy.find(*it));
}
// ****************************************************************
/* check for cached trophy objects */
int gjAPI::gjInterTrophy::__CheckCache(const int& iAchieved, gjTrophyList* papOutput)
{
// retrieve cached trophies
if(m_apTrophy.size() > 1)
{
if(papOutput)
{
gjTrophyList apConvert;
apConvert.reserve(GJ_API_RESERVE_TROPHY);
// add sorted trophies
for(size_t i = 0; i < m_aiSort.size(); ++i)
if(m_apTrophy.count(m_aiSort[i])) apConvert.push_back(m_apTrophy[m_aiSort[i]]);
// add missing unsorted trophies
FOR_EACH(it, m_apTrophy)
{
if(it->first)
{
if(std::find(apConvert.begin(), apConvert.end(), it->second) == apConvert.end())
apConvert.push_back(it->second);
}
}
// check for achieved status
for(size_t i = 0; i < apConvert.size(); ++i)
{
if((iAchieved > 0 && apConvert[i]->IsAchieved()) ||
(iAchieved < 0 && !apConvert[i]->IsAchieved()) || !iAchieved)
(*papOutput).push_back(apConvert[i]);
}
}
return GJ_OK;
}
return GJ_NO_DATA_FOUND;
}
// ****************************************************************
/* process trophy data and cache trophy objects */
int gjAPI::gjInterTrophy::__Process(const std::string& sData, void* pAdd, gjTrophyList* papOutput)
{
// parse output
gjDataList aaReturn;
if(m_pAPI->ParseRequestKeypair(sData, &aaReturn) != GJ_OK)
{
m_pAPI->ErrorLogAdd("API Error: could not parse trophies");
return GJ_REQUEST_FAILED;
}
// offline-cache trophy data
if(!aaReturn.empty()) this->__SaveOffCache(sData);
if(m_iCache == 0) m_iCache = 2;
// create and cache trophy objects
FOR_EACH(it, aaReturn)
{
gjTrophy* pNewTrophy = new gjTrophy(*it, m_pAPI);
const int iID = pNewTrophy->GetID();
if(m_apTrophy.count(iID))
{
*m_apTrophy[iID] = *pNewTrophy;
SAFE_DELETE(pNewTrophy)
}
else m_apTrophy[iID] = pNewTrophy;
}
// apply attributes
this->SetSort(NULL, 0);
this->SetSecret(NULL, 0);
this->SetHidden(NULL, 0);
return (this->__CheckCache((long)pAdd, papOutput) == GJ_OK) ? GJ_OK : GJ_NO_DATA_FOUND;
}
// ****************************************************************
/* save trophy data to a cache file */
void gjAPI::gjInterTrophy::__SaveOffCache(const std::string& sData)
{
if(!GJ_API_OFFCACHE_TROPHY) return;
if(m_iCache != 0) return;
// open cache file
std::FILE* pFile = std::fopen(GJ_API_OFFCACHE_NAME, "w");
if(pFile)
{
// write data and close cache file
std::fprintf(pFile, "[TROPHY]\n");
std::fprintf(pFile, "%s", sData.c_str());
std::fclose(pFile);
}
}
// ****************************************************************
/* load trophy data from a cache file */
void gjAPI::gjInterTrophy::__LoadOffCache()
{
if(!GJ_API_OFFCACHE_TROPHY) return;
if(m_iCache != 0) return;
// open cache file
std::FILE* pFile = std::fopen(GJ_API_OFFCACHE_NAME, "r");
if(pFile)
{
// read trophy header
char acHeader[32];
std::fscanf(pFile, "%31[^\n]%*c", acHeader);
// read trophy data
std::string sData;
while(true)
{
char acLine[1024];
std::fscanf(pFile, "%1023[^\n]%*c", acLine);
if(std::feof(pFile)) break;
if(std::strlen(acLine) > 1)
{
sData += acLine;
sData += '\n';
}
}
// close cache file
std::fclose(pFile);
if(!sData.empty())
{
// flag offline caching and load offline-cached trophies
m_iCache = 1;
this->__Process(sData, NULL, NULL);
}
}
}
// ****************************************************************
/* constructor */
gjAPI::gjInterScore::gjInterScore(gjAPI* pAPI, gjNetwork* pNetwork)noexcept
: m_pAPI (pAPI)
, m_pNetwork (pNetwork)
{
// create NULL score table for secure object handling
gjData pNullData;
pNullData["id"] = "0";
pNullData["name"] = "NOT FOUND";
m_apScoreTable[0] = new gjScoreTable(pNullData, m_pAPI);
}
// ****************************************************************
/* destructor */
gjAPI::gjInterScore::~gjInterScore()
{
// delete all score tables and scores entries
FOR_EACH(it, m_apScoreTable)
SAFE_DELETE(it->second)
// clear container
m_apScoreTable.clear();
}
// ****************************************************************
/* access score table objects directly (may block) */
gjScoreTable* gjAPI::gjInterScore::GetScoreTable(const int &iID)
{
if(m_apScoreTable.size() <= 1)
{
// wait for prefetching
if(GJ_API_PREFETCH) m_pNetwork->Wait(2);
if(m_apScoreTable.size() <= 1)
{
gjScoreTableMap apOutput;
this->FetchScoreTablesNow(&apOutput);
}
}
gjScoreTable* pPrimary = gjScoreTable::GetPrimary();
return iID ? (m_apScoreTable.count(iID) ? m_apScoreTable[iID] : m_apScoreTable[0]) : (pPrimary ? pPrimary : m_apScoreTable[0]);
}
// ****************************************************************
/* delete all cached score table objects and score entries */
void gjAPI::gjInterScore::ClearCache()
{
// save NULL score table
gjScoreTable* pNull = m_apScoreTable[0]; m_apScoreTable.erase(0);
// delete score tables and scores entries
FOR_EACH(it, m_apScoreTable)
SAFE_DELETE(it->second)
// clear container
m_apScoreTable.clear();
m_apScoreTable[0] = pNull;
}
// ****************************************************************
/* check for cached score table objects */
int gjAPI::gjInterScore::__CheckCache(gjScoreTableMap* papOutput)
{
// retrieve cached score tables
if(m_apScoreTable.size() > 1)
{
if(papOutput)
{
FOR_EACH(it, m_apScoreTable)
if(it->first) (*papOutput)[it->first] = it->second;
}
return GJ_OK;
}
return GJ_NO_DATA_FOUND;
}
// ****************************************************************
/* process score table data and cache score table objects */
int gjAPI::gjInterScore::__Process(const std::string& sData, void* pAdd, gjScoreTableMap* papOutput)
{
// parse output
gjDataList aaReturn;
if(m_pAPI->ParseRequestKeypair(sData, &aaReturn) != GJ_OK)
{
m_pAPI->ErrorLogAdd("API Error: could not parse score tables");
return GJ_REQUEST_FAILED;
}
// create and cache score tables
FOR_EACH(it, aaReturn)
{
gjScoreTable* pNewScoreTable = new gjScoreTable(*it, m_pAPI);
const int iID = pNewScoreTable->GetID();
if(m_apScoreTable.count(iID)) SAFE_DELETE(pNewScoreTable)
else m_apScoreTable[iID] = pNewScoreTable;
}
return (this->__CheckCache(papOutput) == GJ_OK) ? GJ_OK : GJ_NO_DATA_FOUND;
}
// ****************************************************************
/* constructor */
gjAPI::gjInterDataStore::gjInterDataStore(const int& iType, gjAPI* pAPI, gjNetwork* pNetwork)noexcept
: m_iType (iType)
, m_pAPI (pAPI)
, m_pNetwork (pNetwork)
{
}
// ****************************************************************
/* destructor */
gjAPI::gjInterDataStore::~gjInterDataStore()
{
this->ClearCache();
}
// ****************************************************************
/* create and access data store items directly */
gjDataItem* gjAPI::gjInterDataStore::GetDataItem(const std::string& sKey)
{
// create new data store item
if(!m_apDataItem.count(sKey))
{
gjData asDataItemData;
asDataItemData["key"] = sKey;
m_apDataItem[sKey] = new gjDataItem(asDataItemData,m_iType, m_pAPI);
}
return m_apDataItem.count(sKey) ? m_apDataItem[sKey] : NULL;
}
// ****************************************************************
/* delete all cached data store items */
void gjAPI::gjInterDataStore::ClearCache()
{
// delete data store items
FOR_EACH(it, m_apDataItem)
SAFE_DELETE(it->second)
// clear container
m_apDataItem.clear();
}
// ****************************************************************
/* check for cached data store items */
int gjAPI::gjInterDataStore::__CheckCache(gjDataItemMap* papOutput)
{
// retrieve cached data store items
if(!m_apDataItem.empty())
{
if(papOutput)
{
FOR_EACH(it, m_apDataItem)
(*papOutput)[it->first] = it->second;
}
return GJ_OK;
}
return GJ_NO_DATA_FOUND;
}
// ****************************************************************
/* process data store data and cache data store items */
int gjAPI::gjInterDataStore::__Process(const std::string& sData, void* pAdd, gjDataItemMap* papOutput)
{
// parse output
gjDataList aaReturn;
if(m_pAPI->ParseRequestKeypair(sData, &aaReturn) != GJ_OK)
{
m_pAPI->ErrorLogAdd("API Error: could not parse data store items");
return GJ_REQUEST_FAILED;
}
// create and cache data store items
FOR_EACH(it, aaReturn)
{
gjDataItem* pNewDataItem = new gjDataItem(*it, m_iType, m_pAPI);
const std::string sKey = pNewDataItem->GetKey();
if(m_apDataItem.count(sKey))
{
SAFE_DELETE(pNewDataItem)
pNewDataItem = m_apDataItem[sKey];
}
else m_apDataItem[sKey] = pNewDataItem;
if(papOutput) (*papOutput)[sKey] = pNewDataItem;
}
return aaReturn.size() ? GJ_OK : GJ_NO_DATA_FOUND;
}
// ****************************************************************
/* constructor */
gjAPI::gjInterFile::gjInterFile(gjAPI* pAPI, gjNetwork* pNetwork)noexcept
: m_pAPI (pAPI)
, m_pNetwork (pNetwork)
{
// reserve some memory
m_asFile.reserve(GJ_API_RESERVE_FILE);
}
// ****************************************************************
/* destructor */
gjAPI::gjInterFile::~gjInterFile()
{
this->ClearCache();
}
// ****************************************************************
/* delete all cached file paths */
void gjAPI::gjInterFile::ClearCache()
{
// clear container
m_asFile.clear();
}
// ****************************************************************
/* check for cached files */
int gjAPI::gjInterFile::__CheckCache(const std::string& sPath)
{
// compare cached file paths
for(size_t i = 0; i < m_asFile.size(); ++i)
{
if(sPath == m_asFile[i])
return GJ_OK;
}
return GJ_NO_DATA_FOUND;
}
// ****************************************************************
/* process downloaded file */
int gjAPI::gjInterFile::__Process(const std::string& sData, void* pAdd, std::string* psOutput)
{
// save path of the file
if(this->__CheckCache(sData) != GJ_OK) m_asFile.push_back(sData);
if(psOutput) (*psOutput) = sData;
return GJ_OK;
}
// ****************************************************************
/* constructor */
gjAPI::gjAPI(const int& iGameID, const std::string& sGamePrivateKey)noexcept
: m_iGameID (iGameID)
, m_sGamePrivateKey (sGamePrivateKey)
, m_sUserName ("")
, m_sUserToken ("")
, m_iNextPing (0)
, m_bActive (false)
, m_bConnected (false)
, m_sProcUserName ("")
, m_sProcUserToken ("")
{
// pre-process the game ID
m_sProcGameID = this->UtilIntToString(m_iGameID);
// create network object
m_pNetwork = new gjNetwork(this);
// create sub-interface objects
m_pInterUser = new gjInterUser(this, m_pNetwork);
m_pInterTrophy = new gjInterTrophy(this, m_pNetwork);
m_pInterScore = new gjInterScore(this, m_pNetwork);
m_pInterDataStoreGlobal = new gjInterDataStore(0, this, m_pNetwork);
m_pInterDataStoreUser = new gjInterDataStore(1, this, m_pNetwork);
m_pInterFile = new gjInterFile(this, m_pNetwork);
// prefetch score tables
if(GJ_API_PREFETCH) m_pInterScore->FetchScoreTablesCall(GJ_NETWORK_NULL_THIS(gjScoreTableMap));
// init error log
this->ErrorLogReset();
}
// ****************************************************************
/* destructor */
gjAPI::~gjAPI()
{
// logout last user
this->Logout();
// delete network object
SAFE_DELETE(m_pNetwork)
// delete sub-interface objects
SAFE_DELETE(m_pInterUser)
SAFE_DELETE(m_pInterTrophy)
SAFE_DELETE(m_pInterScore)
SAFE_DELETE(m_pInterDataStoreGlobal)
SAFE_DELETE(m_pInterDataStoreUser)
SAFE_DELETE(m_pInterFile)
// exit error log
this->ErrorLogReset();
}
// ****************************************************************
/* main update function of the library */
void gjAPI::Update()
{
// update network object
m_pNetwork->Update();
if(!this->IsConnected()) return;
if(m_iNextPing)
{
// update ping for the user session
const time_t iCurTime = time(NULL);
if(iCurTime >= m_iNextPing)
{
m_iNextPing = iCurTime + GJ_API_PING_TIME;
this->__PingSession(m_bActive);
}
}
}
// ****************************************************************
/* login with specific user */
int gjAPI::Login(const bool bSession, const std::string& sUserName, const std::string& sUserToken)
{
if(this->IsConnected()) return GJ_INVALID_CALL;
if(sUserName == "" || sUserToken == "") return GJ_INVALID_INPUT;
// authenticate user
std::string sCheck;
if(m_pNetwork->SendRequest("/users/auth/"
"?game_id=" + m_sProcGameID +
"&username=" + this->UtilEscapeString(sUserName) +
"&user_token=" + this->UtilEscapeString(sUserToken),
&sCheck, this, &gjAPI::Null, NULL, GJ_NETWORK_NULL_THIS(std::string))) return GJ_REQUEST_FAILED;
// check for success
gjDataList aaReturn;
if(this->ParseRequestKeypair(sCheck, &aaReturn) != GJ_OK)
{
this->ErrorLogAdd("API Error: could not authenticate user <" + sUserName + ">");
return GJ_REQUEST_FAILED;
}
// set main user data
m_sUserName = sUserName;
m_sUserToken = sUserToken;
m_sProcUserName = this->UtilEscapeString(m_sUserName);
m_sProcUserToken = this->UtilEscapeString(m_sUserToken);
// set connection
m_bConnected = true;
// open the user session
if(bSession) this->__OpenSession();
// prefetch user data
if(GJ_API_PREFETCH)
{
m_pInterUser->FetchUserCall(0, GJ_NETWORK_NULL_THIS(gjUserPtr));
m_pInterTrophy->FetchTrophiesCall(0, GJ_NETWORK_NULL_THIS(gjTrophyList));
m_pInterDataStoreUser->FetchDataItemsCall(GJ_NETWORK_NULL_THIS(gjDataItemMap));
}
return GJ_OK;
}
int gjAPI::Login(const bool bSession, std::string sCredPath)
{
// open credentials file
std::FILE* pFile = std::fopen(sCredPath.c_str(), "rb");
if(!pFile) return GJ_FILE_ERROR;
char acName[128], acToken[128];
char* pcEnd;
// get user name
std::fscanf(pFile, "%127[^\n]%*c", acName);
pcEnd = std::strchr(acName, 13);
if(pcEnd) *pcEnd = '\0';
// get user token
std::fscanf(pFile, "%127[^\n]%*c", acToken);
pcEnd = std::strchr(acToken, 13);
if(pcEnd) *pcEnd = '\0';
// close file and login
std::fclose(pFile);
return this->Login(bSession, acName, acToken);
}
// ****************************************************************
/* logout with specific user */
int gjAPI::Logout()
{
if(!this->IsConnected()) return GJ_NOT_CONNECTED;
// clear user specific data
m_pInterTrophy->ClearCache(false);
m_pInterDataStoreUser->ClearCache();
// close the user session
if(m_iNextPing) this->__CloseSession();
// clear main user data
m_sUserName = "";
m_sUserToken = "";
m_sProcUserName = "";
m_sProcUserToken = "";
// clear connection
m_bConnected = false;
return GJ_OK;
}
// ****************************************************************
/* parse a valid response string in keypair format */
int gjAPI::ParseRequestKeypair(const std::string& sInput, gjDataList* paaOutput)
{
if(!paaOutput) return GJ_INVALID_INPUT;
gjData aData;
std::istringstream sStream(sInput);
std::string sToken;
// traverse input string
while(std::getline(sStream, sToken))
{
// remove redundant newline characters safely and without C++11
if(sToken.empty()) continue;
while(*(sToken.end()-1) == 10 || *(sToken.end()-1) == 13) // .back()
{
sToken.erase(sToken.end()-1); // .pop_back()
if(sToken.empty()) break;
}
if(sToken.empty()) continue;
// separate key and value
const int iPos = sToken.find(':');
const std::string sKey = sToken.substr(0, iPos);
const std::string sValue = sToken.substr(iPos + 2, sToken.length() - iPos - 3);
// next data block on same key
if(aData.count(sKey.c_str()))
{
paaOutput->push_back(aData);
aData.clear();
}
// create key and save value
aData[sKey.c_str()] = sValue;
}
// insert last data block and check size
if(!aData.empty()) paaOutput->push_back(aData);
if(paaOutput->empty())
{
this->ErrorLogAdd("API Error: string parsing failed");
return GJ_INVALID_INPUT;
}
// check for failed request
if(paaOutput->front()["success"] != "true")
{
this->ErrorLogAdd("API Error: request was unsuccessful");
this->ErrorLogAdd("API Error: " + paaOutput->front()["message"]);
return GJ_REQUEST_FAILED;
}
return GJ_OK;
}
// ****************************************************************
/* parse a valid response string in Dump format */
int gjAPI::ParseRequestDump(const std::string& sInput, std::string* psOutput)
{
if(!psOutput) return GJ_INVALID_INPUT;
// read status
const std::string sStatus = sInput.substr(0, sInput.find_first_of(13));
// read data
*psOutput = sInput.substr(sStatus.length()+2);
// check for failed request
if(sStatus != "SUCCESS")
{
this->ErrorLogAdd("API Error: request was unsuccessful");
this->ErrorLogAdd("API Error: " + *psOutput);
return GJ_REQUEST_FAILED;
}
return GJ_OK;
}
// ****************************************************************
/* delete all cached objects */
void gjAPI::ClearCache()
{
// clear cache of all sub-interface
m_pInterUser->ClearCache();
m_pInterTrophy->ClearCache(true);
m_pInterScore->ClearCache();
m_pInterDataStoreGlobal->ClearCache();
m_pInterDataStoreUser->ClearCache();
m_pInterFile->ClearCache();
}
// ****************************************************************
/* escape a string for proper url calling */
std::string gjAPI::UtilEscapeString(const std::string& sString)
{
std::string sOutput = "";
// traverse input string
for(size_t i = 0; i < sString.length(); ++i)
{
// check the character type
if
(
(48 <= sString[i] && sString[i] <= 57) || // 0-9
(65 <= sString[i] && sString[i] <= 90) || // abc...xyz
(97 <= sString[i] && sString[i] <= 122) || // ABC...XYZ
(
sString[i] == '~' || sString[i] == '.' ||
sString[i] == '-' || sString[i] == '_'
)
)
{
// add valid character
sOutput += sString[i];
}
else
{
// convert character to hexadecimal value
sOutput += "%" + this->UtilCharToHex(sString[i]);
}
}
return sOutput;
}
// ****************************************************************
/* convert a character into his hexadecimal value */
std::string gjAPI::UtilCharToHex(const char& cChar)
{
int iValue = (int)cChar;
if(iValue < 0) iValue += 256;
char acBuffer[8];
std::sprintf(acBuffer, "%02X", iValue);
return acBuffer;
}
// ****************************************************************
/* simply convert an integer into a string */
std::string gjAPI::UtilIntToString(const int& iInt)
{
char acBuffer[32];
std::sprintf(acBuffer, "%d", iInt);
return acBuffer;
}
// ****************************************************************
/* create a folder hierarchy */
void gjAPI::UtilCreateFolder(const std::string& sFolder)
{
int iPos = 0;
do
{
// get next subfolder
iPos = sFolder.find_first_of("/\\", iPos+2);
const std::string sSubFolder = sFolder.substr(0, iPos);
// create subfolder
#if defined(_GJ_WINDOWS_)
CreateDirectoryA(sSubFolder.c_str(), NULL);
#else
mkdir(sSubFolder.c_str(), S_IRWXU);
#endif
}
while(iPos >= 0);
}
// ****************************************************************
/* get timestamp as string */
std::string gjAPI::UtilTimestamp(const time_t iTime)
{
// format the time value
tm* pFormat = std::localtime(&iTime);
// create output
char acBuffer[16];
std::sprintf(acBuffer, "%02d:%02d:%02d", pFormat->tm_hour, pFormat->tm_min, pFormat->tm_sec);
return acBuffer;
}
// ****************************************************************
/* reset error log */
void gjAPI::ErrorLogReset()
{
if(GJ_API_LOGFILE)
{
// remove error log file if empty
if(m_asLog.empty())
std::remove(GJ_API_LOGFILE_NAME);
}
// clear all log entries
m_asLog.clear();
}
// ****************************************************************
/* add error log entry */
void gjAPI::ErrorLogAdd(const std::string& sMsg)
{
const std::string sTimeMsg = "[" + this->UtilTimestamp() + "] " + sMsg;
// add message
m_asLog.push_back(sTimeMsg);
if(GJ_API_LOGFILE)
{
// add message to error log file
std::FILE* pFile = std::fopen(GJ_API_LOGFILE_NAME, "a");
if(pFile)
{
std::fprintf(pFile, "%s\n", sTimeMsg.c_str());
std::fclose(pFile);
}
}
#if defined(_GJ_DEBUG_)
// print message to terminal
std::cerr << "(!GJ) " << sTimeMsg << std::endl;
#endif
}
// ****************************************************************
/* open the user session */
int gjAPI::__OpenSession()
{
if(!this->IsConnected()) return GJ_NOT_CONNECTED;
// send non-blocking open request
if(m_pNetwork->SendRequest("/sessions/open/"
"?game_id=" + m_sProcGameID +
"&username=" + m_sProcUserName +
"&user_token=" + m_sProcUserToken,
NULL, this, &gjAPI::Null, NULL, GJ_NETWORK_NULL_THIS(std::string))) return GJ_REQUEST_FAILED;
// init session attributes
m_iNextPing = std::time(NULL) + GJ_API_PING_TIME;
m_bActive = true;
return GJ_OK;
}
// ****************************************************************
/* ping the user session */
int gjAPI::__PingSession(const bool& bActive)
{
if(!this->IsConnected()) return GJ_NOT_CONNECTED;
// use active status
const std::string sActive = bActive ? "active" : "idle";
// send non-blocking ping request
if(m_pNetwork->SendRequest("/sessions/ping/"
"?game_id=" + m_sProcGameID +
"&username=" + m_sProcUserName +
"&user_token=" + m_sProcUserToken +
"&status=" + sActive,
NULL, this, &gjAPI::Null, NULL, GJ_NETWORK_NULL_THIS(std::string))) return GJ_REQUEST_FAILED;
return GJ_OK;
}
// ****************************************************************
/* close the user session */
int gjAPI::__CloseSession()
{
if(!this->IsConnected()) return GJ_NOT_CONNECTED;
// send non-blocking close request
if(m_pNetwork->SendRequest("/sessions/close/"
"?game_id=" + m_sProcGameID +
"&username=" + m_sProcUserName +
"&user_token=" + m_sProcUserToken,
NULL, this, &gjAPI::Null, NULL, GJ_NETWORK_NULL_THIS(std::string))) return GJ_REQUEST_FAILED;
// clear session attributes
m_iNextPing = 0;
return GJ_OK;
}
| 28.172297 | 131 | 0.536575 | Sasurai |
69cdb8f40a274b41ceea595d55c8979ef8edd28f | 1,272 | cpp | C++ | src/Logger.cpp | cbaron3/chip8-emulator | b218fa40c03d950713d41f32ca08b709a69bcc84 | [
"MIT"
] | null | null | null | src/Logger.cpp | cbaron3/chip8-emulator | b218fa40c03d950713d41f32ca08b709a69bcc84 | [
"MIT"
] | 10 | 2019-02-04T17:00:20.000Z | 2019-05-31T01:44:39.000Z | src/Logger.cpp | cbaron3/chip8-emulator | b218fa40c03d950713d41f32ca08b709a69bcc84 | [
"MIT"
] | null | null | null | // Project includes
#include "../include/Logger.h"
// C++ includes
#include <iostream>
namespace util{
// Initial value of static object
Logger* Logger::m_logger = NULL;
// Singleton instance function
Logger* Logger::get_instance( void )
{
if(m_logger == NULL)
{
m_logger = new Logger();
}
return m_logger;
}
// Destructor
Logger::~Logger( void )
{
delete m_logger;
}
// Log message based on severity level
void Logger::log( LOG_LEVEL level, std::string msg ) const
{
// Only execute log if input level is greater than or equal to max level
if( level >= static_cast<LOG_LEVEL>( max_debug ) )
{
switch (level)
{
case LOG_LEVEL::DEBUG:
{
std::cout << "Debug Message: " << msg << std::endl;
} break;
case LOG_LEVEL::ERROR:
{
std::cout << "***ERROR*** Message: " << msg << std::endl;
} break;
case LOG_LEVEL::NONE:
default:
{
// Do nothing
} break;
}
}
}
// Set max log level
void Logger::set_max_log_level(LOG_LEVEL level)
{
max_debug = static_cast<int>(level);
}
// Helper function outside class to wrap singleton call
void LOG(Logger::LOG_LEVEL level, std::string msg)
{
Logger::get_instance()->log(level, msg);
}
} // End of namespace util | 19.272727 | 74 | 0.624214 | cbaron3 |
69cf441a87c21a8902eeec98a6d218c9f5c37ad7 | 1,474 | cpp | C++ | src/Generic/common/ASCIIUtil.cpp | BBN-E/serif | 1e2662d82fb1c377ec3c79355a5a9b0644606cb4 | [
"Apache-2.0"
] | 1 | 2022-03-24T19:57:00.000Z | 2022-03-24T19:57:00.000Z | src/Generic/common/ASCIIUtil.cpp | BBN-E/serif | 1e2662d82fb1c377ec3c79355a5a9b0644606cb4 | [
"Apache-2.0"
] | null | null | null | src/Generic/common/ASCIIUtil.cpp | BBN-E/serif | 1e2662d82fb1c377ec3c79355a5a9b0644606cb4 | [
"Apache-2.0"
] | null | null | null | // Copyright (c) 2012 by Raytheon BBN Technologies Corp.
// All Rights Reserved.
#include "Generic/common/leak_detection.h"
#include "Generic/common/ASCIIUtil.h"
#include "Generic/linuxPort/serif_port.h"
#include <iostream> // for iswspace on linux
bool ASCIIUtil::containsAlpha(const std::wstring &str) {
for (size_t i = 0; i < str.length(); i++) {
wchar_t c = str.at(i);
int ci = (int) c;
// iswalpha() doesn't work here for some reason
if (ci >= L'a' && ci <= L'z') return true;
if (ci >= L'A' && ci <= L'Z') return true;
}
return false;
}
bool ASCIIUtil::containsNonWhitespace(const std::wstring &str) {
for (size_t i = 0; i < str.length(); i++) {
wchar_t c = str.at(i);
if (!iswspace(c))
return true;
}
return false;
}
bool ASCIIUtil::containsDigits(const std::wstring &str) {
for (size_t i = 0; i < str.length(); i++) {
wchar_t c = str.at(i);
int ci = (int) c;
// Using iswdigit() causes code points such as 3670 (Thai digit "six") to be treated as digits, which is not desired.
if (ci >= L'0' && ci <= L'9')
return true;
}
return false;
}
bool ASCIIUtil::containsNonDigits(const std::wstring &str) {
for (size_t i = 0; i < str.length(); i++) {
wchar_t c = str.at(i);
int ci = (int) c;
// Using iswdigit() causes code points such as 3670 (Thai digit "six") to be treated as digits, which is not desired.
if (ci < L'0' || ci > L'9')
return true;
}
return false;
}
| 29.48 | 120 | 0.614654 | BBN-E |
69d077a4ee3c776e43f12161838888d2b98d6c3c | 4,160 | tpp | C++ | signal-slot-benchmarks/benchmark/lib/iscool/include/iscool/signals/detail/relay.tpp | qubka/signals | 6bd39c662ab2b1e0caafc5a4c4510a74fb9f9e1c | [
"MIT"
] | 181 | 2020-01-17T13:49:59.000Z | 2022-03-17T03:23:12.000Z | signal-slot-benchmarks/benchmark/lib/iscool/include/iscool/signals/detail/relay.tpp | qubka/signals | 6bd39c662ab2b1e0caafc5a4c4510a74fb9f9e1c | [
"MIT"
] | 22 | 2020-01-16T23:37:02.000Z | 2021-09-08T23:51:12.000Z | signal-slot-benchmarks/benchmark/lib/iscool/include/iscool/signals/detail/relay.tpp | qubka/signals | 6bd39c662ab2b1e0caafc5a4c4510a74fb9f9e1c | [
"MIT"
] | 16 | 2020-01-28T15:40:18.000Z | 2022-02-25T08:32:15.000Z | /*
Copyright 2018-present IsCool Entertainment
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef ISCOOL_SIGNALS_RELAY_TPP
#define ISCOOL_SIGNALS_RELAY_TPP
#include <boost/bind.hpp>
#include <boost/preprocessor/iteration/local.hpp>
#include <cassert>
namespace iscool
{
namespace signals
{
namespace detail
{
template< typename Signature >
struct signal_binder;
template< typename R, typename... T >
struct signal_binder< R( T... ) >
{
typedef iscool::signals::signal< R( T... ) > signal_type;
typedef
typename signal_type::slot_function_type slot_function_type;
static slot_function_type bind( const signal_type& signal );
};
template< std::size_t N, typename R, typename... T >
struct signal_binder_n;
template< typename Signature >
struct signal_invoker;
template< typename R, typename... T >
struct signal_invoker< R ( T... ) >
{
typedef iscool::signals::signal< R( T... ) > signal_type;
static R invoke( const signal_type* signal, T... arguments );
};
template< typename ...T >
struct signal_invoker< void( T... ) >
{
typedef iscool::signals::signal<void( T... )> signal_type;
static void invoke( const signal_type* signal, T... arguments );
};
}
}
}
template< typename Signature >
typename iscool::signals::signal< Signature >::slot_function_type
iscool::signals::relay( const signal< Signature >& s )
{
return detail::signal_binder<Signature>::bind( s );
}
template< typename R, typename ...T >
typename
iscool::signals::detail::signal_binder< R( T... ) >::slot_function_type
iscool::signals::detail::signal_binder<R( T... )>::bind
( const signal_type& signal )
{
constexpr std::size_t size = sizeof...(T);
return signal_binder_n< size, R, T... >::bind( signal );
}
#define SIGNAL_BINDER_PLACEHOLDER( UNUSED1, N, DATA ) \
BOOST_PP_CAT( DATA, BOOST_PP_INC( N ) )
#define SIGNAL_BINDER_BINDN( N ) \
template< typename R, typename ...T > \
struct signal_binder_n< N, R, T... > \
{ \
typedef iscool::signals::signal<R( T... )> signal_type; \
typedef typename signal_type::slot_function_type slot_function_type; \
static slot_function_type bind( const signal_type& signal ) \
{ \
return boost::bind<R> \
( &detail::signal_invoker<R( T... )>::invoke, &signal \
BOOST_PP_COMMA_IF( N ) \
BOOST_PP_ENUM( N, SIGNAL_BINDER_PLACEHOLDER, _ ) \
); \
} \
};
#define BOOST_PP_LOCAL_MACRO( N ) SIGNAL_BINDER_BINDN( N )
#define BOOST_PP_LOCAL_LIMITS (0, 8)
namespace iscool
{
namespace signals
{
namespace detail
{
#include BOOST_PP_LOCAL_ITERATE()
}
}
}
#undef SIGNAL_BINDER_PLACEHOLDER
#undef SIGNAL_BINDER_BINDN
#undef BOOST_PP_LOCAL_MACRO
#undef BOOST_PP_LOCAL_LIMITS
template< typename R, typename...T >
R iscool::signals::detail::signal_invoker< R( T... ) >::invoke
( const signal_type* signal, T... arguments )
{
assert( signal );
return *( signal->operator() ( arguments... ) );
};
template< typename ...T >
void iscool::signals::detail::signal_invoker< void( T... ) >::invoke
( const signal_type* signal, T... arguments )
{
assert( signal );
signal->operator() ( arguments... );
};
#endif
| 30.144928 | 80 | 0.613702 | qubka |
69d6b6c5973d7684a866996ab5ab2c47545fc681 | 2,195 | hpp | C++ | src/VirtWebPage.hpp | taleroangel/ProxyServer | be1433be7b332a9d901964087591c5908450733a | [
"Apache-2.0"
] | 1 | 2022-03-07T02:43:05.000Z | 2022-03-07T02:43:05.000Z | src/VirtWebPage.hpp | taleroangel/ProxyServer | be1433be7b332a9d901964087591c5908450733a | [
"Apache-2.0"
] | null | null | null | src/VirtWebPage.hpp | taleroangel/ProxyServer | be1433be7b332a9d901964087591c5908450733a | [
"Apache-2.0"
] | null | null | null | /**
* @file Server.hpp
* @author Angel D. Talero (angelgotalero@outlook.com)
* @brief Clase encargada de manejar los sitios web virtuales
*
* @copyright Copyright (c) 2021. All rights reserved.
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#ifndef _VIRTWEBPAGE_HPP_
#define _VIRTWEBPAGE_HPP_
#include <string>
#include <vector>
class VirtWebPage
{
/* ---- Typedefs privados ---- */
private:
/**
* @struct entry
* @brief Estructura de entradas
*/
struct entry
{
std::string input; /*< URL enviada por el navegador*/
std::string output; /*< URL equivalente*/
};
/* ---- Variables privadas ---- */
private:
std::vector<entry> entries; /*< Todas las entradas*/
/* ---- Constructores ---- */
public:
/**
* @brief Crear entradas de página web virtuales
*
* @param filename Nombre de archivo a leer
*/
explicit VirtWebPage(std::string filename) noexcept(false);
/**
* @brief Destruir las entradas de páginas web virtuales
*
*/
~VirtWebPage();
/* ---- Métodos públicos ---- */
public:
/**
* @brief Obtener la pagina web virtual
*
* @param url URL que mandó el navegador
* @throw AddressException La dirección que se solicitó no existe
*
* @return std::string URL real
*/
std::string getVirtualPage(std::string url) noexcept(false);
};
#endif //_VIRTWEBPAGE_HPP_ | 28.506494 | 69 | 0.663781 | taleroangel |
69d795cc6a368819e3a9697657a3c8dccfaef222 | 14,833 | cpp | C++ | src/jitcat/ExpressionBase.cpp | mvhooren/JitCat | 8e05b51c5feda8fa9258ba443854b23c4ad8bf7c | [
"MIT"
] | 14 | 2019-03-16T07:00:44.000Z | 2021-10-20T23:36:51.000Z | src/jitcat/ExpressionBase.cpp | mvhooren/JitCat | 8e05b51c5feda8fa9258ba443854b23c4ad8bf7c | [
"MIT"
] | 13 | 2019-11-22T12:43:55.000Z | 2020-05-25T13:09:08.000Z | src/jitcat/ExpressionBase.cpp | mvhooren/JitCat | 8e05b51c5feda8fa9258ba443854b23c4ad8bf7c | [
"MIT"
] | 1 | 2019-11-23T17:59:58.000Z | 2019-11-23T17:59:58.000Z | /*
This file is part of the JitCat library.
Copyright (C) Machiel van Hooren 2018
Distributed under the MIT License (license terms are at http://opensource.org/licenses/MIT).
*/
#include "jitcat/ExpressionBase.h"
#include "jitcat/CatArgumentList.h"
#include "jitcat/CatAssignableExpression.h"
#include "jitcat/CatBuiltInFunctionCall.h"
#include "jitcat/CatIndirectionConversion.h"
#include "jitcat/CatPrefixOperator.h"
#include "jitcat/CatRuntimeContext.h"
#include "jitcat/CatTypedExpression.h"
#include "jitcat/Configuration.h"
#include "jitcat/ExpressionErrorManager.h"
#include "jitcat/ExpressionHelperFunctions.h"
#include "jitcat/Document.h"
#include "jitcat/JitCat.h"
#ifdef ENABLE_LLVM
#include "jitcat/LLVMCodeGenerator.h"
#include "jitcat/LLVMCompileTimeContext.h"
#include "jitcat/LLVMJit.h"
#endif
#include "jitcat/PrecompilationContext.h"
#include "jitcat/SLRParseResult.h"
#include "jitcat/Tools.h"
#include "jitcat/TypeRegistry.h"
#include <cassert>
using namespace jitcat;
using namespace jitcat::AST;
using namespace jitcat::LLVM;
using namespace jitcat::Parser;
using namespace jitcat::Reflection;
using namespace jitcat::Tokenizer;
ExpressionBase::ExpressionBase(bool expectAssignable):
expressionIsLiteral(false),
isConstant(false),
expectAssignable(expectAssignable)
{
}
ExpressionBase::ExpressionBase(const char* expression, bool expectAssignable):
expression(expression),
expressionIsLiteral(false),
isConstant(false),
expectAssignable(expectAssignable)
{
}
ExpressionBase::ExpressionBase(const std::string& expression, bool expectAssignable):
expression(expression),
expressionIsLiteral(false),
isConstant(false),
expectAssignable(expectAssignable)
{
}
ExpressionBase::ExpressionBase(CatRuntimeContext* compileContext, const std::string& expression, bool expectAssignable):
expression(expression),
expressionIsLiteral(false),
isConstant(false),
expectAssignable(expectAssignable)
{
}
ExpressionBase::~ExpressionBase()
{
if (errorManagerHandle.getIsValid())
{
reinterpret_cast<ExpressionErrorManager*>(errorManagerHandle.get())->errorSourceDeleted(this);
}
}
void ExpressionBase::setExpression(const std::string& expression_, CatRuntimeContext* compileContext)
{
if (expression != expression_)
{
expression = expression_;
if (compileContext != nullptr)
{
compile(compileContext);
}
else
{
valueType = CatGenericType::unknownType;
parseResult.clear();
isConstant = false;
expressionIsLiteral = false;
}
}
}
const std::string& ExpressionBase::getExpression() const
{
return expression;
}
bool ExpressionBase::isLiteral() const
{
return expressionIsLiteral;
}
bool ExpressionBase::isConst() const
{
return isConstant;
}
bool ExpressionBase::hasError() const
{
return !(parseResult.success);
}
const CatGenericType& ExpressionBase::getType() const
{
return valueType;
}
bool ExpressionBase::parse(CatRuntimeContext* context, ExpressionErrorManager* errorManager, void* errorContext, const CatGenericType& expectedType)
{
if (context == nullptr)
{
context = &CatRuntimeContext::getDefaultContext();
context->getErrorManager()->clear();
}
//If this expressions is compiled multiple times, we need to clear any errors that were previously generated.
if (errorManagerHandle.getIsValid())
{
reinterpret_cast<ExpressionErrorManager*>(errorManagerHandle.get())->errorSourceDeleted(this);
}
errorManagerHandle.setReflectable(reinterpret_cast<unsigned char*>(errorManager), TypeRegistry::get()->registerType<ExpressionErrorManager>());
isConstant = false;
expressionIsLiteral = false;
Document document(expression.c_str(), expression.length());
context->getErrorManager()->setCurrentDocument(&document);
parseResult = JitCat::get()->parseExpression(&document, context, errorManager, errorContext);
if (parseResult.success)
{
typeCheck(expectedType, context, errorManager, errorContext);
if (parseResult.success)
{
constCollapse(context, errorManager, errorContext);
}
}
handleParseErrors(context);
//typeCheck may have changed parseResult.success
if (parseResult.success && !isConstant)
{
compileToNativeCode(context, expectedType);
}
if (!parseResult.success)
{
parseResult.astRootNode.reset(nullptr);
}
context->getErrorManager()->setCurrentDocument(nullptr);
return parseResult.success;
}
void ExpressionBase::discardAST()
{
parseResult.astRootNode = nullptr;
}
void ExpressionBase::constCollapse(CatRuntimeContext* context, ExpressionErrorManager* errorManager, void* errorContext)
{
CatTypedExpression* newExpression = static_cast<CatTypedExpression*>(parseResult.getNode<CatTypedExpression>()->constCollapse(context, errorManager, errorContext));
if (newExpression != parseResult.astRootNode.get())
{
parseResult.astRootNode.reset(newExpression);
}
//Const collapse may have changed the expression from a non-constant to a constant.
//For example, in an expression like 0.0 * aVariable
if (parseResult.success)
{
isConstant = parseResult.getNode<CatTypedExpression>()->isConst();
}
}
void ExpressionBase::typeCheck(const CatGenericType& expectedType, CatRuntimeContext* context, ExpressionErrorManager* errorManager, void* errorContext)
{
if (!parseResult.getNode<CatTypedExpression>()->typeCheck(context, errorManager, errorContext))
{
parseResult.success = false;
}
else
{
calculateLiteralStatus();
valueType = parseResult.getNode<CatTypedExpression>()->getType();
Lexeme expressionLexeme = parseResult.getNode<CatTypedExpression>()->getLexeme();
if (!expectedType.isUnknown())
{
IndirectionConversionMode mode = expectedType.getIndirectionConversion(valueType);
if (isValidConversionMode(mode))
{
if (mode == IndirectionConversionMode::AddressOfPointer
|| mode == IndirectionConversionMode::AddressOfValue)
{
parseResult.success = false;
errorManager->compiledWithError(std::string(Tools::append("Expression results in a value with a level of indirection that cannot be automatically converted. Trying to convert from ", valueType.toString(), " to ", expectedType.toString(), ".")), errorContext, context->getContextName(), expressionLexeme);
return;
}
else if (mode != IndirectionConversionMode::None)
{
//Create an AST node that handles the indirection conversion
std::unique_ptr<CatTypedExpression> previousNode(parseResult.releaseNode<CatTypedExpression>());
parseResult.astRootNode = std::make_unique<CatIndirectionConversion>(expressionLexeme, expectedType, mode, std::move(previousNode));
parseResult.getNode<CatTypedExpression>()->typeCheck(context, errorManager, errorContext);
valueType = parseResult.getNode<CatTypedExpression>()->getType();
}
}
else if (mode != IndirectionConversionMode::ErrorTypeMismatch)
{
parseResult.success = false;
switch (mode)
{
case IndirectionConversionMode::ErrorNotCopyConstructible: errorManager->compiledWithError(std::string(Tools::append("Expression result is not copy constructible.")), errorContext, context->getContextName(), expressionLexeme); return;
case IndirectionConversionMode::ErrorTooMuchIndirection: errorManager->compiledWithError(std::string(Tools::append("Expression has too much indirection.")), errorContext, context->getContextName(), expressionLexeme); return;
default: assert(isValidConversionMode(mode)); break;
}
}
if (expectAssignable && !parseResult.getNode<CatAssignableExpression>()->getAssignableType().isAssignableType())
{
parseResult.success = false;
errorManager->compiledWithError(std::string(Tools::append("Expression result is read only. Expected a writable ", expectedType.toString(), ".")), errorContext, context->getContextName(), expressionLexeme);
}
if (expectedType.isPointerToReflectableObjectType() || expectedType.isReflectableHandleType())
{
const std::string typeName = expectedType.getPointeeType()->getObjectTypeName();
if (!valueType.isPointerToReflectableObjectType() && !valueType.isReflectableHandleType())
{
parseResult.success = false;
errorManager->compiledWithError(Tools::append("Expected a ", expectedType.toString(), " got a ", valueType.toString()), errorContext, context->getContextName(), expressionLexeme);
}
else if (valueType.getPointeeType()->getObjectTypeName() != typeName)
{
parseResult.success = false;
errorManager->compiledWithError(Tools::append("Expected a ", typeName, ", got a ", valueType.getPointeeType()->getObjectTypeName()), errorContext, context->getContextName(), expressionLexeme);
}
}
else if (expectedType.isVoidType() && valueType.isVoidType())
{
parseResult.success = true;
}
else if (!expectAssignable && !valueType.compare(expectedType, true, true))
{
if (expectedType.isVoidType())
{
//Insert an automatic type conversion to void.
CatArgumentList* arguments = new CatArgumentList(expressionLexeme, std::vector<CatTypedExpression*>({parseResult.releaseNode<CatTypedExpression>()}));
parseResult.astRootNode = std::make_unique<CatBuiltInFunctionCall>("toVoid", expressionLexeme, arguments, expressionLexeme);
parseResult.getNode<CatTypedExpression>()->typeCheck(context, errorManager, errorContext);
valueType = parseResult.getNode<CatTypedExpression>()->getType();
}
else if (expectedType.isScalarType() && valueType.isScalarType())
{
//Insert an automatic type conversion if the scalar types do not match.
CatArgumentList* arguments = new CatArgumentList(expressionLexeme, std::vector<CatTypedExpression*>({ parseResult.releaseNode<CatTypedExpression>() }));
if (expectedType.isFloatType())
{
parseResult.astRootNode = std::make_unique<CatBuiltInFunctionCall>("toFloat", expressionLexeme, arguments, expressionLexeme);
parseResult.getNode<CatTypedExpression>()->typeCheck(context, errorManager, errorContext);
}
else if (expectedType.isDoubleType())
{
parseResult.astRootNode = std::make_unique<CatBuiltInFunctionCall>("toDouble", expressionLexeme, arguments, expressionLexeme);
parseResult.getNode<CatTypedExpression>()->typeCheck(context, errorManager, errorContext);
}
else if (expectedType.isIntType())
{
parseResult.astRootNode = std::make_unique<CatBuiltInFunctionCall>("toInt", expressionLexeme, arguments, expressionLexeme);
parseResult.getNode<CatTypedExpression>()->typeCheck(context, errorManager, errorContext);
}
else
{
assert(false); //Missing a conversion here?
}
valueType = parseResult.getNode<CatTypedExpression>()->getType();
}
else
{
parseResult.success = false;
errorManager->compiledWithError(std::string(Tools::append("Expected a ", expectedType.toString(), " got a ", valueType.toString(), ".")), errorContext, context->getContextName(), expressionLexeme);
}
}
}
else if (expectAssignable &&
!parseResult.getNode<CatTypedExpression>()->isAssignable())
{
parseResult.success = false;
errorManager->compiledWithError("Expression result is read only. Expected a writable value.", errorContext, context->getContextName(), expressionLexeme);
}
if (parseResult.success)
{
isConstant = parseResult.getNode<CatTypedExpression>()->isConst();
}
}
}
void ExpressionBase::handleParseErrors(CatRuntimeContext* context)
{
if (!parseResult.success)
{
expressionIsLiteral = false;
isConstant = false;
valueType = CatGenericType::unknownType;
}
else
{
context->getErrorManager()->compiledWithoutErrors(this);
}
}
void ExpressionBase::compileToNativeCode(CatRuntimeContext* context, const CatGenericType& expectedType)
{
if (!isConstant)
{
if (JitCat::get()->getHasPrecompiledExpression())
{
//Can't use precompiled expressions if there is a precompilation context
//because the expression would not be pre-compiled.
if (context->getPrecompilationContext() == nullptr)
{
//Lookup the symbol for the expression by its unique name.
uintptr_t symbolAddress = JitCat::get()->getPrecompiledSymbol(ExpressionHelperFunctions::getUniqueExpressionFunctionName(expression, context, expectAssignable, expectedType));
if (symbolAddress != 0 || !Configuration::enableLLVM)
{
//Expressions are expected to handle the case where symbolAddress == 0 and llvm is not available to JIT-compile the function.
handleCompiledFunction(symbolAddress);
if (symbolAddress != 0 && JitCat::get()->getDiscardASTAfterNativeCodeCompilation())
{
discardAST();
}
return;
}
}
}
#ifdef ENABLE_LLVM
LLVMCompileTimeContext llvmCompileContext(context, LLVM::LLVMJit::get().getJitTargetConfig(), false);
llvmCompileContext.options.enableDereferenceNullChecks = true;
intptr_t functionAddress = 0;
codeGenerator = context->getCodeGenerator();
if (!expectAssignable)
{
functionAddress = codeGenerator->generateAndGetFunctionAddress(parseResult.getNode<CatTypedExpression>(), expression, expectedType, &llvmCompileContext, expectedType.isValidType());
if (context->getPrecompilationContext() != nullptr)
{
context->getPrecompilationContext()->precompileExpression(parseResult.getNode<CatTypedExpression>(), expression, expectedType, context);
}
}
else if (parseResult.getNode<CatTypedExpression>()->isAssignable())
{
functionAddress = codeGenerator->generateAndGetAssignFunctionAddress(parseResult.getNode<CatAssignableExpression>(), expression, expectedType, &llvmCompileContext);
if (context->getPrecompilationContext() != nullptr)
{
context->getPrecompilationContext()->precompileAssignmentExpression(parseResult.getNode<CatAssignableExpression>(), expression, expectedType, context);
}
}
if (functionAddress != 0)
{
handleCompiledFunction(functionAddress);
if (JitCat::get()->getDiscardASTAfterNativeCodeCompilation())
{
discardAST();
}
}
else
{
assert(false);
}
#endif //ENABLE_LLVM
}
}
void jitcat::ExpressionBase::calculateLiteralStatus()
{
expressionIsLiteral = false;
if (parseResult.success)
{
if (parseResult.getNode<CatTypedExpression>()->getNodeType() == CatASTNodeType::Literal)
{
expressionIsLiteral = true;
}
else if (parseResult.getNode<CatTypedExpression>()->getNodeType() == CatASTNodeType::PrefixOperator)
{
//If the expression is a minus prefix operator combined with a literal, then we need to count the whole expression as a literal.
CatPrefixOperator* prefixOp = parseResult.getNode<CatPrefixOperator>();
if (prefixOp->getRHS() != nullptr
&& prefixOp->getOperator() == CatPrefixOperator::Operator::Minus
&& prefixOp->getRHS()->getNodeType() == CatASTNodeType::Literal)
{
expressionIsLiteral = true;
}
}
}
}
| 34.656542 | 309 | 0.750826 | mvhooren |
69d828b08dfec6c1091045c50e86816f023a620b | 1,255 | cpp | C++ | test/Stat_test.cpp | hhoppe/Mesh-processing-library | aa8c952fbbb00774008060767650b821bf72fa10 | [
"MIT"
] | 422 | 2017-01-12T04:44:39.000Z | 2022-03-21T14:38:49.000Z | test/Stat_test.cpp | wangxihao/Mesh-processing-library | 194ce16b8b28bbab1263ca6bc26dedfa7a0eeea2 | [
"MIT"
] | 1 | 2017-06-07T16:36:09.000Z | 2017-06-07T16:36:09.000Z | test/Stat_test.cpp | wangxihao/Mesh-processing-library | 194ce16b8b28bbab1263ca6bc26dedfa7a0eeea2 | [
"MIT"
] | 75 | 2017-01-12T04:44:41.000Z | 2021-11-09T02:57:34.000Z | // -*- C++ -*- Copyright (c) Microsoft Corporation; see license.txt
#include "libHh/Stat.h"
#include "libHh/Array.h"
#include "libHh/Vec.h"
using namespace hh;
// Optionally, run with: rm -f Stat.Stat_test; (setenv STAT_FILES; Stat_test); cat Stat.Stat_test
int main() {
{
Stat s1("", true);
for (int i : {2, 4, -1, 10, 8}) s1.enter(i);
SHOW(s1.short_string());
s1.enter(12);
s1.enter(11);
SHOW(s1.short_string());
s1.add(s1);
SHOW(s1);
Stat s2("Stat_test", true);
s2.enter(1);
s2.enter(5);
s2.enter(6);
SHOW(s2);
SHOW("end");
}
SHOW("before Stot");
HH_SSTAT(Stot, 0);
{
Stat Svar("Svar", true);
for_int(i, 100) Svar.enter(i);
}
{
HH_STAT(Ssquare);
for_int(i, 100) Ssquare.enter(i);
}
{
float values[] = {2.f, 4.f, 4.f, 5.f, 4.f}; // test C-array
SHOW(ArView(values));
for (float v : values) SHOW(v);
HH_RSTAT(Svalues, ArView(values));
}
{
const float values[] = {2.f, 4.f, 4.f, 5.f, 4.f}; // test C-array
for (float v : values) SHOW(v);
HH_RSTAT(Svalues, values);
}
{ HH_RSTAT(Svalues2, V(2.f, 4.f, 4.f, 5.f, 4.f)); }
{
SHOW(Stat(V(1., 4., 5., 6.)).short_string());
SHOW(Stat(V(1., 4., 5., 6.)).sdv());
}
}
| 23.240741 | 100 | 0.54741 | hhoppe |
69d9a899646b5f04222898da10680076b539826c | 2,972 | cpp | C++ | codeBase/Algorithms/Graph_Algorithms/Prim's_Minimum_Spanning_Tree/prims.cpp | suren3141/codeBase | 10ed9a56aca33631dc8c419cd83859c19dd6ff09 | [
"Apache-2.0"
] | 3 | 2020-03-16T14:59:08.000Z | 2021-07-28T20:51:53.000Z | codeBase/Algorithms/Graph_Algorithms/Prim's_Minimum_Spanning_Tree/prims.cpp | suren3141/codeBase | 10ed9a56aca33631dc8c419cd83859c19dd6ff09 | [
"Apache-2.0"
] | 2 | 2016-04-16T05:39:20.000Z | 2016-06-06T12:24:56.000Z | codeBase/Algorithms/Graph_Algorithms/Prim's_Minimum_Spanning_Tree/prims.cpp | killerilaksha/codeBase | 91cbd950fc90066903e58311000784aeba4ffc02 | [
"Apache-2.0"
] | 18 | 2020-02-17T23:17:37.000Z | 2021-07-28T20:52:13.000Z | /*
Copyright Hackers' Club, University Of Peradeniya
Author : E/13/181 (Samurdhi Karunarathne)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at *
http://www.apache.org/licenses/LICENSE-2.0 *
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Description:
The Prim's Algorithm finds the Minimum Spanning Tree of an undirected graph.
Time Complexity: O(E*logE) or O(E*logV) where E=Number of edges V=Number of vertices
Using this code:
This is a non-class based approach(Compare with the Kruskal's MST implementation). The graph must be created by updating the two-dimensional array 'graph'. If an edge
exists between two nodes the corresponding element of the matrix should be updated with the weight of that edge. Otherwise the respective element should read 0. Calling
primMST(graph,n) prints the edges of the MST and finally prints the total wright of the MST. Note that the NST itself is not unique but the total weight is.
Example Input:
5 6
1 2 3
1 3 4
4 2 6
5 2 2
2 3 5
3 5 7
Example Output:
0 - 1 3
0 - 2 4
1 - 3 6
1 - 4 2
15
Example Problems:
https://www.hackerrank.com/challenges/matrix
*/
#include <bits/stdc++.h>
using namespace std;
typedef long int li;
li minKey(vector<li> key, vector<bool> mstSet, li V) {
li min = LONG_MAX;
li min_index;
for (li v = 0; v < V; v++)
if (mstSet[v] == false && key[v] < min)
min = key[v], min_index = v;
return min_index;
}
void printMST(vector<li> parent, li V, vector<vector<li> > &graph) {
for (li i = 1; i < V; i++)
printf("%ld - %ld %ld \n", parent[i], i, graph[i][parent[i]]);
long long sm = 0;
for (li i = 1; i < V; i++)
sm += graph[i][parent[i]];
cout << sm << endl;
}
void primMST(vector<vector<li> > &graph, li V) {
vector<li> parent;
vector<li> key;
vector<bool> mstSet;
for (li i = 0; i < V; i++)
key.push_back(LONG_MAX), mstSet.push_back(false), parent.push_back(0);
key[0] = 0;
parent[0] = -1;
for (li count = 0; count < V - 1; count++) {
li u = minKey(key, mstSet, V);
mstSet[u] = true;
for (li v = 0; v < V; v++)
if (graph[u][v] && mstSet[v] == false && graph[u][v] < key[v])
parent[v] = u, key[v] = graph[u][v];
}
printMST(parent, V, graph);
}
int main() {
li n, m;
cin >> n >> m;
vector<vector<li> > graph;
for (li j = 0; j < n; j++) {
vector<li> tmp;
for (li k = 0; k < n; k++) tmp.push_back(0);
graph.push_back(tmp);
}
for (li j = 0; j < m; j++) {
li x, y;
li r;
cin >> x >> y >> r;
graph[x - 1][y - 1] = r;
graph[y - 1][x - 1] = r;
}
primMST(graph, n);
return 0;
} | 26.070175 | 168 | 0.641319 | suren3141 |
69daf60209975db1c677d25f81675d4d6ac34359 | 550 | hpp | C++ | willow/include/popart/transforms/overlapio.hpp | gglin001/popart | 3225214343f6d98550b6620e809a3544e8bcbfc6 | [
"MIT"
] | 61 | 2020-07-06T17:11:46.000Z | 2022-03-12T14:42:51.000Z | willow/include/popart/transforms/overlapio.hpp | gglin001/popart | 3225214343f6d98550b6620e809a3544e8bcbfc6 | [
"MIT"
] | 1 | 2021-02-25T01:30:29.000Z | 2021-11-09T11:13:14.000Z | willow/include/popart/transforms/overlapio.hpp | gglin001/popart | 3225214343f6d98550b6620e809a3544e8bcbfc6 | [
"MIT"
] | 6 | 2020-07-15T12:33:13.000Z | 2021-11-07T06:55:00.000Z | // Copyright (c) 2021 Graphcore Ltd. All rights reserved.
#ifndef GUARD_NEURALNET_OVERLAPIO_HPP
#define GUARD_NEURALNET_OVERLAPIO_HPP
#include <popart/transforms/transform.hpp>
namespace popart {
class OverlapIO : public Transform {
public:
static std::size_t id();
OverlapIO() : Transform() {}
virtual ~OverlapIO() override {}
virtual bool apply(Graph &graph) const final;
virtual std::size_t getId() const final { return id(); }
virtual std::string getName() const final { return "OverlapIO"; }
};
} // namespace popart
#endif
| 21.153846 | 67 | 0.727273 | gglin001 |
69db9c865eb7b7e9c52029c6cb4c9aa4a3b030d8 | 995 | cc | C++ | src/code_writen_when_learning/ret_t_of_post_inc_int.cc | NobodyXu/snippet | 8f0308e48dab1d166dc9e5ff43b00db2d35b616b | [
"MIT"
] | 1 | 2019-04-02T04:38:15.000Z | 2019-04-02T04:38:15.000Z | src/code_writen_when_learning/ret_t_of_post_inc_int.cc | NobodyXu/snippet | 8f0308e48dab1d166dc9e5ff43b00db2d35b616b | [
"MIT"
] | null | null | null | src/code_writen_when_learning/ret_t_of_post_inc_int.cc | NobodyXu/snippet | 8f0308e48dab1d166dc9e5ff43b00db2d35b616b | [
"MIT"
] | null | null | null | #include <iostream>
#include <boost/cstdint.hpp>
#include <typeinfo>
template <class T>
T create_T();
template <class T>
void ret_t_of_pre_inc() {
T i;
std::cout << typeid(decltype(++i)).name() << std::endl
<< typeid(T).name() << std::endl
<< typeid(T&).name() << std::endl;
}
template <class T>
void ret_t_of_post_inc() {
T i;
std::cout << typeid(decltype(i++)).name() << std::endl
<< typeid(T).name() << std::endl
<< typeid(T&).name() << std::endl;
}
#define test(pos) \
ret_t_of_ ## pos ## _inc<int8_t>(); \
ret_t_of_ ## pos ## _inc<uint8_t>(); \
\
ret_t_of_ ## pos ##_inc<int16_t>(); \
ret_t_of_ ## pos ## _inc<uint16_t>();\
\
ret_t_of_ ## pos ## _inc<int32_t>(); \
ret_t_of_ ## pos ## _inc<uint32_t>();\
\
ret_t_of_ ## pos ## _inc<int64_t>(); \
ret_t_of_ ## pos ## _inc<uint64_t>();\
\
ret_t_of_ ## pos ## _inc<float>(); \
ret_t_of_ ## pos ## _inc<double>()
int main() {
test(pre);
test(post);
}
| 24.268293 | 58 | 0.552764 | NobodyXu |
69ded58302baca09c1949467324f1a037b65273c | 748 | hpp | C++ | hw/ip/kmac/dv/dpi/vendor/kerukuro_digestpp/algorithm/sm3.hpp | asb/opentitan | af68ff5041b10c81e97adc075a4d042f8ac7ab20 | [
"Apache-2.0"
] | 1,375 | 2019-11-05T15:11:00.000Z | 2022-03-28T17:50:43.000Z | hw/ip/kmac/dv/dpi/vendor/kerukuro_digestpp/algorithm/sm3.hpp | asb/opentitan | af68ff5041b10c81e97adc075a4d042f8ac7ab20 | [
"Apache-2.0"
] | 7,045 | 2019-11-05T16:05:45.000Z | 2022-03-31T23:08:08.000Z | hw/ip/kmac/dv/dpi/vendor/kerukuro_digestpp/algorithm/sm3.hpp | asb/opentitan | af68ff5041b10c81e97adc075a4d042f8ac7ab20 | [
"Apache-2.0"
] | 428 | 2019-11-05T15:00:20.000Z | 2022-03-28T15:34:57.000Z | /*
This code is written by kerukuro and released into public domain.
*/
#ifndef DIGESTPP_ALGORITHM_SM3_HPP
#define DIGESTPP_ALGORITHM_SM3_HPP
#include "../hasher.hpp"
#include "detail/sm3_provider.hpp"
namespace digestpp
{
/**
* @brief SM3 hash function
*
* @hash
*
* @outputsize 256 bits
*
* @defaultsize 256 bits
*
* @par Example:\n
* @code // Output a SM3 digest of a string
* digestpp::sm3 hasher;
* hasher.absorb("The quick brown fox jumps over the lazy dog");
* std::cout << hasher.hexdigest() << '\n';
* @endcode
*
* @par Example output:\n
* @code 5fdfe814b8573ca021983970fc79b2218c9570369b4859684e2e4c3fc76cb8ea
* @endcode
*
* @sa hasher
*/
typedef hasher<detail::sm3_provider> sm3;
} // namespace digestpp
#endif | 18.7 | 73 | 0.705882 | asb |
69df1ad7d8614d697c0432d2810ec8b3c2393d6b | 1,172 | cpp | C++ | official sample codes/GenIRanger/private/DatAndXmlFiles.cpp | novitec/ranger3 | 5ba831c2ddd500685f5e3940ab725c005c975c1c | [
"MIT"
] | null | null | null | official sample codes/GenIRanger/private/DatAndXmlFiles.cpp | novitec/ranger3 | 5ba831c2ddd500685f5e3940ab725c005c975c1c | [
"MIT"
] | null | null | null | official sample codes/GenIRanger/private/DatAndXmlFiles.cpp | novitec/ranger3 | 5ba831c2ddd500685f5e3940ab725c005c975c1c | [
"MIT"
] | 1 | 2020-03-25T04:49:40.000Z | 2020-03-25T04:49:40.000Z | // Copyright 2018 SICK AG. All rights reserved.
#include "DatAndXmlFiles.h"
namespace GenIRanger {
DatAndXmlFiles::DatAndXmlFiles(std::string filePathWithNoEnding)
: mDataStream(filePathWithNoEnding + ".dat", openMode)
, mXmlStream(filePathWithNoEnding + ".xml", openMode)
{
mDataStream.exceptions(std::ios::failbit | std::ios::badbit);
mXmlStream.exceptions(std::ios::failbit | std::ios::badbit);
}
DatAndXmlFiles::~DatAndXmlFiles()
{
mDataStream.close();
mXmlStream.close();
}
void DatAndXmlFiles::writeData(ComponentPtr& component)
{
writeData(component->data().data(), component->data().size());
}
void DatAndXmlFiles::writeMarkData(LineMetadataPtr encoderValues)
{
const Metadata notUsed = 0;
for (auto encoderValue : *encoderValues)
{
writeSingleMarkValue(encoderValue);
writeSingleMarkValue(notUsed);
writeSingleMarkValue(notUsed);
writeSingleMarkValue(notUsed);
writeSingleMarkValue(notUsed);
}
}
void DatAndXmlFiles::writeSingleMarkValue(const Metadata value)
{
writeData(reinterpret_cast<const uint8_t*>(&value), sizeof(Metadata));
}
void DatAndXmlFiles::writeXml(std::string& xml)
{
mXmlStream << xml;
}
}
| 23.44 | 72 | 0.744881 | novitec |
69dfaaecaff7c2aa2914a68e33bc8a59d61cc116 | 388 | cpp | C++ | chai.cpp | faede/Daily | 45d2cbdca9a63c956df066fb596317ae4a6137b3 | [
"MIT"
] | null | null | null | chai.cpp | faede/Daily | 45d2cbdca9a63c956df066fb596317ae4a6137b3 | [
"MIT"
] | null | null | null | chai.cpp | faede/Daily | 45d2cbdca9a63c956df066fb596317ae4a6137b3 | [
"MIT"
] | null | null | null | #include <iostream>
using namespace std;
int a[20];
void chai(int n,int pos,int temp_sum,int last){
if(temp_sum == n){
cout<<n<<"=";
cout<<a[1];
for(int i = 2; i < pos ; ++i){
cout<<"+"<<a[i];
}
cout<<endl;
return;
}
for(int i = last; i != n && i <= n - temp_sum ; ++i){
a[pos] = i;
chai(n,pos+1,temp_sum + i,i);
}
}
int main(){
int n;
cin>>n;
chai(n,1,0,1);
}
| 15.52 | 54 | 0.515464 | faede |
69e434b50feeab8f249da755c6ef7022179f84bd | 354 | cpp | C++ | knapsack/main.cpp | ryanmcdermott/katas | d23b8c131f03e4df0a3a5268de4b63c5b35058a1 | [
"MIT"
] | 46 | 2017-06-26T15:09:10.000Z | 2022-03-19T04:21:32.000Z | knapsack/main.cpp | ryanmcdermott/katas | d23b8c131f03e4df0a3a5268de4b63c5b35058a1 | [
"MIT"
] | null | null | null | knapsack/main.cpp | ryanmcdermott/katas | d23b8c131f03e4df0a3a5268de4b63c5b35058a1 | [
"MIT"
] | 13 | 2017-10-18T05:30:18.000Z | 2021-10-04T22:46:35.000Z | #include "./knapsack.hpp"
#include <assert.h>
#include <iostream>
using std::cout;
int main() {
int values[] = {60, 100, 120};
int weights[] = {10, 20, 30};
int max_weight = 50;
int item_count = sizeof(values) / sizeof(values[0]);
int result = knapsack(max_weight, weights, values, item_count);
assert(result == 220);
cout << result;
}
| 19.666667 | 65 | 0.641243 | ryanmcdermott |
69e4f5d578fc88afbea1e11cfa1cbbd196cd3345 | 4,943 | cpp | C++ | Library/Source/Nano/Time/NTimeUtils.cpp | refnum/Nano | dceb0907061f7845d8a3c662f309ca164e932e6f | [
"BSD-3-Clause"
] | 23 | 2019-11-12T09:31:11.000Z | 2021-09-13T08:59:37.000Z | Library/Source/Nano/Time/NTimeUtils.cpp | refnum/nano | dceb0907061f7845d8a3c662f309ca164e932e6f | [
"BSD-3-Clause"
] | 1 | 2020-10-30T09:54:12.000Z | 2020-10-30T09:54:12.000Z | Library/Source/Nano/Time/NTimeUtils.cpp | refnum/Nano | dceb0907061f7845d8a3c662f309ca164e932e6f | [
"BSD-3-Clause"
] | 3 | 2015-09-08T11:00:02.000Z | 2017-09-11T05:42:30.000Z | /* NAME:
NTimeUtils.cpp
DESCRIPTION:
Time utilities.
COPYRIGHT:
Copyright (c) 2006-2021, refNum Software
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
___________________________________________________________________________
*/
//=============================================================================
// Includes
//-----------------------------------------------------------------------------
#include "NTimeUtils.h"
// Nano
#include "NPOSIX.h"
#include "NanoConstants.h"
// System
#include <math.h>
//=============================================================================
// NTimeUtils::GetAbsolute : Get an absolute time.
//-----------------------------------------------------------------------------
NTime NTimeUtils::GetAbsolute(NInterval theInterval)
{
// Validate our parameters
NN_REQUIRE(theInterval == kNTimeForever || theInterval >= 0.0);
// Get the absolute time
if (theInterval == kNTimeForever)
{
theInterval = kNTimeDistantFuture;
}
return NTimeUtils::GetTime() + theInterval;
}
//=============================================================================
// NTimeUtils::IsAfter : Check the current time.
//-----------------------------------------------------------------------------
bool NTimeUtils::IsAfter(NTime theTime)
{
// Check the time
return NTimeUtils::GetTime() >= theTime;
}
//=============================================================================
// NTimeUtils::ToTimespec : Convert to a timespec.
//-----------------------------------------------------------------------------
struct timespec NTimeUtils::ToTimespec(NInterval theInterval)
{
// Convert the value
NInterval timeSecs = floor(theInterval);
NInterval timeFrac = theInterval - timeSecs;
return {time_t(timeSecs), long(timeFrac / kNTimeNanosecond)};
}
//=============================================================================
// NTimeUtils::ToTmUTC : Convert to a tm in UTC.
//-----------------------------------------------------------------------------
struct tm NTimeUtils::ToTmUTC(NTime theTime)
{
// Convert the value
time_t timeUnix = time_t(theTime + kNanoEpochTo1970);
return NPOSIX::gmtime(timeUnix);
}
//=============================================================================
// NTimeUtils::ToTmLocal : Convert to a tm in local time.
//-----------------------------------------------------------------------------
struct tm NTimeUtils::ToTmLocal(NTime theTime)
{
// Convert the value
time_t timeUnix = time_t(theTime + kNanoEpochTo1970);
return NPOSIX::localtime(timeUnix);
}
//=============================================================================
// NTimeUtils::ToInterval : Convert to an NInterval.
//-----------------------------------------------------------------------------
NInterval NTimeUtils::ToInterval(const struct timespec& timeSpec)
{
// Convert the value
NInterval timeSecs = NInterval(timeSpec.tv_sec);
NInterval timeFrac = NInterval(timeSpec.tv_nsec) * kNTimeNanosecond;
return timeSecs + timeFrac;
}
//=============================================================================
// NTimeUtils::ToTime : Convert a tm in UTC to an NTime.
//-----------------------------------------------------------------------------
NTime NTimeUtils::ToTime(const struct tm& timeUTC)
{
// Convert the value
struct tm localCopy(timeUTC);
time_t timeUnix = mktime(&localCopy);
return NTime(NInterval(timeUnix), kNanoEpochFrom1970);
}
| 28.738372 | 79 | 0.560388 | refnum |
69e5c583543bdf0c7e2be6f9de29fb1e20a78129 | 41,321 | cpp | C++ | src/core/callers/trio_caller.cpp | alimanfoo/octopus | f3cc3f567f02fafe33f5a06e5be693d6ea985ee3 | [
"MIT"
] | 1 | 2018-08-21T23:34:28.000Z | 2018-08-21T23:34:28.000Z | src/core/callers/trio_caller.cpp | alimanfoo/octopus | f3cc3f567f02fafe33f5a06e5be693d6ea985ee3 | [
"MIT"
] | null | null | null | src/core/callers/trio_caller.cpp | alimanfoo/octopus | f3cc3f567f02fafe33f5a06e5be693d6ea985ee3 | [
"MIT"
] | null | null | null | // Copyright (c) 2015-2018 Daniel Cooke
// Use of this source code is governed by the MIT license that can be found in the LICENSE file.
#include "trio_caller.hpp"
#include <typeinfo>
#include <functional>
#include <iterator>
#include <algorithm>
#include <numeric>
#include <map>
#include <utility>
#include "basics/genomic_region.hpp"
#include "concepts/mappable.hpp"
#include "containers/probability_matrix.hpp"
#include "core/types/allele.hpp"
#include "core/types/variant.hpp"
#include "core/types/calls/germline_variant_call.hpp"
#include "core/types/calls/denovo_call.hpp"
#include "core/types/calls/denovo_reference_reversion_call.hpp"
#include "core/types/calls/reference_call.hpp"
#include "core/models/genotype/uniform_population_prior_model.hpp"
#include "core/models/genotype/coalescent_population_prior_model.hpp"
#include "core/models/genotype/population_model.hpp"
#include "utils/map_utils.hpp"
#include "utils/mappable_algorithms.hpp"
#include "utils/maths.hpp"
#include "timers.hpp"
namespace octopus {
TrioCaller::TrioCaller(Caller::Components&& components,
Caller::Parameters general_parameters,
Parameters specific_parameters)
: Caller {std::move(components), std::move(general_parameters)}
, parameters_ {std::move(specific_parameters)}
{
if (parameters_.maternal_ploidy == 0) {
throw std::logic_error {"IndividualCaller: ploidy must be > 0"};
}
}
std::string TrioCaller::do_name() const
{
return "trio";
}
Caller::CallTypeSet TrioCaller::do_call_types() const
{
return {std::type_index(typeid(GermlineVariantCall)),
std::type_index(typeid(DenovoCall)),
std::type_index(typeid(DenovoReferenceReversionCall))};
}
// TrioCaller::Latents
TrioCaller::Latents::Latents(const std::vector<Haplotype>& haplotypes,
std::vector<Genotype<Haplotype>>&& genotypes,
model::TrioModel::InferredLatents&& latents,
const Trio& trio)
: trio {trio}
, maternal_genotypes {std::move(genotypes)}
, model_latents {std::move(latents)}
{
set_genotype_posteriors(trio);
set_haplotype_posteriors(haplotypes);
}
TrioCaller::Latents::Latents(const std::vector<Haplotype>& haplotypes,
std::vector<Genotype<Haplotype>>&& maternal_genotypes,
std::vector<Genotype<Haplotype>>&& paternal_genotypes,
const unsigned child_ploidy,
ModelInferences&& latents,
const Trio& trio)
: trio {trio}
, maternal_genotypes {std::move(maternal_genotypes)}
, paternal_genotypes {std::move(paternal_genotypes)}
, model_latents {std::move(latents)}
{
// TODO: in this case
}
std::shared_ptr<TrioCaller::Latents::HaplotypeProbabilityMap>
TrioCaller::Latents::haplotype_posteriors() const noexcept
{
return marginal_haplotype_posteriors;
}
std::shared_ptr<TrioCaller::Latents::GenotypeProbabilityMap>
TrioCaller::Latents::genotype_posteriors() const noexcept
{
return marginal_genotype_posteriors;
}
namespace {
using model::TrioModel;
using JointProbability = TrioModel::Latents::JointProbability;
using GenotypeReference = std::reference_wrapper<const Genotype<Haplotype>>;
template <typename Function>
auto marginalise(const std::vector<Genotype<Haplotype>>& genotypes,
const std::vector<JointProbability>& joint_posteriors,
Function who)
{
std::vector<double> result(genotypes.size(), 0.0);
if (genotypes.empty()) return result;
const auto first = std::addressof(genotypes.front());
for (const auto& jp : joint_posteriors) {
result[std::addressof(who(jp).get()) - first] += jp.probability;
}
return result;
}
auto marginalise_mother(const std::vector<Genotype<Haplotype>>& genotypes,
const std::vector<JointProbability>& joint_posteriors)
{
return marginalise(genotypes, joint_posteriors, [] (const JointProbability& p) -> GenotypeReference { return p.maternal; });
}
auto marginalise_father(const std::vector<Genotype<Haplotype>>& genotypes,
const std::vector<JointProbability>& joint_posteriors)
{
return marginalise(genotypes, joint_posteriors, [] (const JointProbability& p) -> GenotypeReference { return p.paternal; });
}
auto marginalise_child(const std::vector<Genotype<Haplotype>>& genotypes,
const std::vector<JointProbability>& joint_posteriors)
{
return marginalise(genotypes, joint_posteriors, [] (const JointProbability& p) -> GenotypeReference { return p.child; });
}
} // namespace
void TrioCaller::Latents::set_genotype_posteriors(const Trio& trio)
{
auto& trio_posteriors = model_latents.posteriors.joint_genotype_probabilities;
marginal_maternal_posteriors = marginalise_mother(maternal_genotypes, trio_posteriors);
marginal_paternal_posteriors = marginalise_father(maternal_genotypes, trio_posteriors);
marginal_child_posteriors = marginalise_child(maternal_genotypes, trio_posteriors);
GenotypeProbabilityMap genotype_posteriors {std::begin(maternal_genotypes), std::end(maternal_genotypes)};
insert_sample(trio.mother(), marginal_maternal_posteriors, genotype_posteriors);
insert_sample(trio.father(), marginal_paternal_posteriors, genotype_posteriors);
insert_sample(trio.child(), marginal_child_posteriors, genotype_posteriors);
marginal_genotype_posteriors = std::make_shared<GenotypeProbabilityMap>(std::move(genotype_posteriors));
}
namespace {
using JointProbability = TrioModel::Latents::JointProbability;
using TrioProbabilityVector = std::vector<JointProbability>;
using InverseGenotypeTable = std::vector<std::vector<std::size_t>>;
auto make_inverse_genotype_table(const std::vector<Haplotype>& haplotypes,
const std::vector<Genotype<Haplotype>>& genotypes)
{
assert(!haplotypes.empty() && !genotypes.empty());
using HaplotypeReference = std::reference_wrapper<const Haplotype>;
std::unordered_map<HaplotypeReference, std::vector<std::size_t>> result_map {haplotypes.size()};
const auto cardinality = element_cardinality_in_genotypes(static_cast<unsigned>(haplotypes.size()),
genotypes.front().ploidy());
for (const auto& haplotype : haplotypes) {
auto itr = result_map.emplace(std::piecewise_construct,
std::forward_as_tuple(std::cref(haplotype)),
std::forward_as_tuple());
itr.first->second.reserve(cardinality);
}
for (std::size_t i {0}; i < genotypes.size(); ++i) {
for (const auto& haplotype : genotypes[i]) {
result_map.at(haplotype).emplace_back(i);
}
}
InverseGenotypeTable result {};
result.reserve(haplotypes.size());
for (const auto& haplotype : haplotypes) {
auto& indices = result_map.at(haplotype);
std::sort(std::begin(indices), std::end(indices));
indices.erase(std::unique(std::begin(indices), std::end(indices)), std::end(indices));
result.emplace_back(std::move(indices));
}
return result;
}
using GenotypeMarginalPosteriorMatrix = std::vector<std::vector<double>>;
auto calculate_haplotype_posteriors(const std::vector<Haplotype>& haplotypes,
const std::vector<Genotype<Haplotype>>& genotypes,
const GenotypeMarginalPosteriorMatrix& genotype_posteriors,
const InverseGenotypeTable& inverse_genotypes)
{
std::unordered_map<std::reference_wrapper<const Haplotype>, double> result {haplotypes.size()};
auto itr = std::cbegin(inverse_genotypes);
std::vector<std::size_t> genotype_indices(genotypes.size());
std::iota(std::begin(genotype_indices), std::end(genotype_indices), 0);
// noncontaining genotypes are genotypes that do not contain a particular haplotype.
const auto num_noncontaining_genotypes = genotypes.size() - itr->size();
std::vector<std::size_t> noncontaining_genotype_indices(num_noncontaining_genotypes);
for (const auto& haplotype : haplotypes) {
std::set_difference(std::cbegin(genotype_indices), std::cend(genotype_indices),
std::cbegin(*itr), std::cend(*itr),
std::begin(noncontaining_genotype_indices));
double prob_not_observed {1};
for (const auto& sample_genotype_posteriors : genotype_posteriors) {
prob_not_observed *= std::accumulate(std::cbegin(noncontaining_genotype_indices),
std::cend(noncontaining_genotype_indices),
0.0, [&sample_genotype_posteriors]
(const auto curr, const auto i) {
return curr + sample_genotype_posteriors[i];
});
}
result.emplace(haplotype, 1.0 - prob_not_observed);
++itr;
}
return result;
}
} // namespace
void TrioCaller::Latents::set_haplotype_posteriors(const std::vector<Haplotype>& haplotypes)
{
auto inverse_genotypes = make_inverse_genotype_table(haplotypes, maternal_genotypes);
const GenotypeMarginalPosteriorMatrix genotype_posteriors {
marginal_maternal_posteriors, marginal_paternal_posteriors, marginal_child_posteriors
};
auto haplotype_posteriors = calculate_haplotype_posteriors(haplotypes, maternal_genotypes, genotype_posteriors, inverse_genotypes);
marginal_haplotype_posteriors = std::make_shared<HaplotypeProbabilityMap>(haplotype_posteriors);
}
// TrioCaller
std::unique_ptr<Caller::Latents>
TrioCaller::infer_latents(const std::vector<Haplotype>& haplotypes,
const HaplotypeLikelihoodCache& haplotype_likelihoods) const
{
auto germline_prior_model = make_prior_model(haplotypes);
DeNovoModel denovo_model {parameters_.denovo_model_params, haplotypes.size(), DeNovoModel::CachingStrategy::address};
const model::TrioModel model {
parameters_.trio, *germline_prior_model, denovo_model,
TrioModel::Options {parameters_.max_joint_genotypes},
debug_log_
};
std::vector<std::vector<unsigned>> genotype_indices {};
auto maternal_genotypes = generate_all_genotypes(haplotypes, parameters_.maternal_ploidy, genotype_indices);
if (parameters_.maternal_ploidy == parameters_.paternal_ploidy) {
germline_prior_model->prime(haplotypes);
denovo_model.prime(haplotypes);
auto latents = model.evaluate(maternal_genotypes, genotype_indices, haplotype_likelihoods);
return std::make_unique<Latents>(haplotypes, std::move(maternal_genotypes),
std::move(latents), parameters_.trio);
} else {
auto paternal_genotypes = generate_all_genotypes(haplotypes, parameters_.paternal_ploidy);
if (parameters_.maternal_ploidy == parameters_.child_ploidy) {
auto latents = model.evaluate(maternal_genotypes, paternal_genotypes,
maternal_genotypes, haplotype_likelihoods);
return std::make_unique<Latents>(haplotypes, std::move(maternal_genotypes),
std::move(latents), parameters_.trio);
} else {
auto latents = model.evaluate(maternal_genotypes, paternal_genotypes,
paternal_genotypes, haplotype_likelihoods);
return std::make_unique<Latents>(haplotypes, std::move(maternal_genotypes),
std::move(latents), parameters_.trio);
}
}
}
boost::optional<double>
TrioCaller::calculate_model_posterior(const std::vector<Haplotype>& haplotypes,
const HaplotypeLikelihoodCache& haplotype_likelihoods,
const Caller::Latents& latents) const
{
return calculate_model_posterior(haplotypes, haplotype_likelihoods, dynamic_cast<const Latents&>(latents));
}
namespace {
static auto calculate_model_posterior(const double normal_model_log_evidence,
const double dummy_model_log_evidence)
{
constexpr double normalModelPrior {0.9999999};
constexpr double dummyModelPrior {1.0 - normalModelPrior};
const auto normal_model_ljp = std::log(normalModelPrior) + normal_model_log_evidence;
const auto dummy_model_ljp = std::log(dummyModelPrior) + dummy_model_log_evidence;
const auto norm = maths::log_sum_exp(normal_model_ljp, dummy_model_ljp);
return std::exp(normal_model_ljp - norm);
}
} // namespace
boost::optional<double>
TrioCaller::calculate_model_posterior(const std::vector<Haplotype>& haplotypes,
const HaplotypeLikelihoodCache& haplotype_likelihoods,
const Latents& latents) const
{
const auto max_ploidy = std::max({parameters_.maternal_ploidy, parameters_.paternal_ploidy, parameters_.child_ploidy});
std::vector<std::vector<unsigned>> genotype_indices {};
const auto genotypes = generate_all_genotypes(haplotypes, max_ploidy + 1, genotype_indices);
const auto germline_prior_model = make_prior_model(haplotypes);
DeNovoModel denovo_model {parameters_.denovo_model_params};
germline_prior_model->prime(haplotypes);
denovo_model.prime(haplotypes);
const model::TrioModel model {parameters_.trio, *germline_prior_model, denovo_model,
TrioModel::Options {parameters_.max_joint_genotypes}};
const auto inferences = model.evaluate(genotypes, genotype_indices, haplotype_likelihoods);
return octopus::calculate_model_posterior(latents.model_latents.log_evidence, inferences.log_evidence);
}
std::vector<std::unique_ptr<VariantCall>>
TrioCaller::call_variants(const std::vector<Variant>& candidates, const Caller::Latents& latents) const
{
return call_variants(candidates, dynamic_cast<const Latents&>(latents));
}
namespace {
bool contains_helper(const Haplotype& haplotype, const Allele& allele)
{
if (!is_insertion(allele)) {
return haplotype.contains(allele);
} else {
return haplotype.includes(allele);
}
}
bool contains_helper(const Genotype<Haplotype>& genotype, const Allele& allele)
{
if (!is_insertion(allele)) {
return contains(genotype, allele);
} else {
return includes(genotype, allele);
}
}
bool contains(const JointProbability& trio, const Allele& allele)
{
return contains_helper(trio.maternal, allele)
|| contains_helper(trio.paternal, allele)
|| contains_helper(trio.child, allele);
}
using HaplotypePtrBoolMap = std::unordered_map<const Haplotype*, bool>;
using GenotypePtrBoolMap = std::unordered_map<const Genotype<Haplotype>*, bool>;
// allele posterior calculation
bool contains(const Haplotype& haplotype, const Allele& allele, HaplotypePtrBoolMap& cache)
{
const auto itr = cache.find(std::addressof(haplotype));
if (itr == std::cend(cache)) {
const auto result = contains_helper(haplotype, allele);
cache.emplace(std::piecewise_construct,
std::forward_as_tuple(std::addressof(haplotype)),
std::forward_as_tuple(result));
return result;
} else {
return itr->second;
}
}
bool contains(const Genotype<Haplotype>& genotype, const Allele& allele, HaplotypePtrBoolMap& cache)
{
return std::any_of(std::cbegin(genotype), std::cend(genotype),
[&] (const auto& haplotype) {
return contains(haplotype, allele, cache);
});
}
bool contains(const Genotype<Haplotype>& genotype, const Allele& allele,
HaplotypePtrBoolMap& haplotype_cache,
GenotypePtrBoolMap& genotype_cache)
{
const auto itr = genotype_cache.find(std::addressof(genotype));
if (itr == std::cend(genotype_cache)) {
const auto result = contains(genotype, allele, haplotype_cache);
genotype_cache.emplace(std::piecewise_construct,
std::forward_as_tuple(std::addressof(genotype)),
std::forward_as_tuple(result));
return result;
} else {
return itr->second;
}
}
bool contains(const JointProbability& trio, const Allele& allele,
HaplotypePtrBoolMap& haplotype_cache,
GenotypePtrBoolMap& genotype_cache)
{
return contains(trio.maternal, allele, haplotype_cache, genotype_cache)
|| contains(trio.paternal, allele, haplotype_cache, genotype_cache)
|| contains(trio.child, allele, haplotype_cache, genotype_cache);
}
auto compute_posterior_uncached(const Allele& allele, const TrioProbabilityVector& trio_posteriors)
{
auto p = std::accumulate(std::cbegin(trio_posteriors), std::cend(trio_posteriors),
0.0, [&] (const auto curr, const auto& trio) {
return curr + (contains(trio, allele) ? 0.0 : trio.probability);
});
return probability_to_phred(p);
}
auto compute_posterior_cached(const Allele& allele, const TrioProbabilityVector& trio_posteriors)
{
HaplotypePtrBoolMap haplotype_cache {};
haplotype_cache.reserve(trio_posteriors.size());
GenotypePtrBoolMap genotype_cache {};
genotype_cache.reserve(trio_posteriors.size());
auto p = std::accumulate(std::cbegin(trio_posteriors), std::cend(trio_posteriors),
0.0, [&] (const auto curr, const auto& p) {
return curr + (contains(p, allele, haplotype_cache, genotype_cache) ? 0.0 : p.probability);
});
return probability_to_phred(p);
}
auto compute_posterior(const Allele& allele, const TrioProbabilityVector& trio_posteriors)
{
if (trio_posteriors.size() >= 500) {
return compute_posterior_cached(allele, trio_posteriors);
} else {
return compute_posterior_uncached(allele, trio_posteriors);
}
}
using AllelePosteriorMap = std::map<Allele, Phred<double>>;
auto compute_posteriors(const std::vector<Allele>& alleles, const TrioProbabilityVector& trio_posteriors)
{
AllelePosteriorMap result {};
for (const auto& allele : alleles) {
result.emplace(allele, compute_posterior(allele, trio_posteriors));
}
return result;
}
auto call_alleles(const AllelePosteriorMap& allele_posteriors, const Phred<double> min_posterior)
{
AllelePosteriorMap result {};
std::copy_if(std::cbegin(allele_posteriors), std::cend(allele_posteriors),
std::inserter(result, std::begin(result)),
[=] (const auto& p) { return p.second >= min_posterior; });
return result;
}
// de novo posterior calculation
bool is_denovo(const Allele& allele, const JointProbability& trio)
{
return contains_helper(trio.child, allele)
&& !(contains_helper(trio.maternal, allele) || contains_helper(trio.paternal, allele));
}
bool is_denovo(const Allele& allele, const JointProbability& trio,
HaplotypePtrBoolMap& haplotype_cache,
GenotypePtrBoolMap& genotype_cache)
{
return contains(trio.child, allele, haplotype_cache, genotype_cache)
&& !(contains(trio.maternal, allele, haplotype_cache, genotype_cache)
|| contains(trio.paternal, allele, haplotype_cache, genotype_cache));
}
auto compute_denovo_posterior_uncached(const Allele& allele, const TrioProbabilityVector& trio_posteriors)
{
auto p = std::accumulate(std::cbegin(trio_posteriors), std::cend(trio_posteriors),
0.0, [&allele] (const auto curr, const auto& p) {
return curr + (is_denovo(allele, p) ? 0.0 : p.probability);
});
return probability_to_phred(p);
}
auto compute_denovo_posterior_cached(const Allele& allele, const TrioProbabilityVector& trio_posteriors)
{
HaplotypePtrBoolMap haplotype_cache {};
haplotype_cache.reserve(trio_posteriors.size());
GenotypePtrBoolMap genotype_cache {};
genotype_cache.reserve(trio_posteriors.size());
auto p = std::accumulate(std::cbegin(trio_posteriors), std::cend(trio_posteriors),
0.0, [&] (const auto curr, const auto& p) {
return curr + (is_denovo(allele, p, haplotype_cache, genotype_cache) ? 0.0 : p.probability);
});
return probability_to_phred(p);
}
auto compute_denovo_posterior(const Allele& allele, const TrioProbabilityVector& trio_posteriors)
{
if (trio_posteriors.size() >= 500) {
return compute_denovo_posterior_cached(allele, trio_posteriors);
} else {
return compute_denovo_posterior_uncached(allele, trio_posteriors);
}
}
auto compute_denovo_posteriors(const AllelePosteriorMap& called_alleles,
const TrioProbabilityVector& trio_posteriors)
{
AllelePosteriorMap result {};
for (const auto& p : called_alleles) {
result.emplace(p.first, compute_denovo_posterior(p.first, trio_posteriors));
}
return result;
}
struct CalledDenovo : public Mappable<CalledDenovo>
{
Allele allele;
Phred<double> posterior;
CalledDenovo(Allele allele, Phred<double> posterior)
: allele {std::move(allele)}
, posterior {posterior}
{}
const GenomicRegion& mapped_region() const noexcept { return allele.mapped_region(); }
};
auto call_denovos(const AllelePosteriorMap& denovo_posteriors, const Phred<double> min_posterior)
{
std::vector<CalledDenovo> result {};
result.reserve(denovo_posteriors.size());
for (const auto& p : denovo_posteriors) {
if (p.second >= min_posterior) {
result.emplace_back(p.first, p.second);
}
}
return result;
}
struct CallCompare
{
bool operator()(const AllelePosteriorMap::value_type& lhs, const CalledDenovo& rhs) const
{
return lhs.first < rhs.allele;
}
bool operator()(const CalledDenovo& lhs, const AllelePosteriorMap::value_type& rhs) const
{
return lhs.allele < rhs.first;
}
};
auto get_germline_alleles(const AllelePosteriorMap& called_alleles,
const std::vector<CalledDenovo>& denovos)
{
std::vector<AllelePosteriorMap::value_type> result {};
result.reserve(called_alleles.size() - denovos.size());
std::set_difference(std::cbegin(called_alleles), std::cend(called_alleles),
std::cbegin(denovos), std::cend(denovos),
std::back_inserter(result), CallCompare {});
return result;
}
struct CalledGermlineVariant : public Mappable<CalledGermlineVariant>
{
Variant variant;
Phred<double> posterior;
CalledGermlineVariant(Variant variant, Phred<double> posterior)
: variant {std::move(variant)}
, posterior {posterior}
{}
const GenomicRegion& mapped_region() const noexcept { return variant.mapped_region(); }
};
boost::optional<Variant> find_variant(const Allele& allele, const std::vector<Variant>& variants)
{
const auto er = std::equal_range(std::cbegin(variants), std::cend(variants), allele,
[] (const auto& lhs, const auto& rhs) {
return mapped_region(lhs) < mapped_region(rhs);
});
const auto iter = std::find_if(er.first, er.second,
[&allele] (const Variant& v) {
return v.alt_allele() == allele;
});
if (iter != er.second) {
return *iter;
} else {
return boost::none;
}
}
auto call_germline_variants(const std::vector<AllelePosteriorMap::value_type>& germline_allele_posteriors,
const std::vector<Variant>& variants, const Phred<double> min_posterior)
{
std::vector<CalledGermlineVariant> result {};
result.reserve(germline_allele_posteriors.size());
for (const auto& p : germline_allele_posteriors) {
if (p.second >= min_posterior) {
const auto variant = find_variant(p.first, variants);
if (variant) result.emplace_back(*variant, p.second);
}
}
return result;
}
struct TrioCall
{
Genotype<Haplotype> mother, father, child;
};
bool includes(const TrioCall& trio, const Allele& allele)
{
return includes(trio.mother, allele) || includes(trio.father, allele) || includes(trio.child, allele);
}
bool none_mendilian_errors(const JointProbability& call, const std::vector<CalledGermlineVariant>& germline_calls)
{
return std::none_of(std::cbegin(germline_calls), std::cend(germline_calls),
[&call] (const auto& germline) { return is_denovo(germline.variant.alt_allele(), call); });
}
bool all_mendilian_errors(const JointProbability& call, const std::vector<CalledDenovo>& denovo_calls)
{
return std::all_of(std::cbegin(denovo_calls), std::cend(denovo_calls),
[&call] (const auto& denovo) { return is_denovo(denovo.allele, call); });
}
bool is_viable_genotype_call(const JointProbability& call,
const std::vector<CalledGermlineVariant>& germline_calls,
const std::vector<CalledDenovo>& denovo_calls)
{
return none_mendilian_errors(call, germline_calls) && all_mendilian_errors(call, denovo_calls);
}
TrioCall to_call(const JointProbability& p) noexcept
{
return TrioCall {p.maternal, p.paternal, p.child};
}
auto call_trio(const TrioProbabilityVector& trio_posteriors,
const std::vector<CalledGermlineVariant>& germline_calls,
const std::vector<CalledDenovo>& denovo_calls)
{
assert(!trio_posteriors.empty());
const auto map_itr = std::max_element(std::cbegin(trio_posteriors), std::cend(trio_posteriors),
[] (const auto& lhs, const auto& rhs) {
return lhs.probability < rhs.probability;
});
if (trio_posteriors.size() == 1 || is_viable_genotype_call(*map_itr, germline_calls, denovo_calls)) {
return to_call(*map_itr);
} else {
std::vector<std::reference_wrapper<const JointProbability>> trio_posterior_refs {};
trio_posterior_refs.reserve(trio_posteriors.size());
std::copy(std::cbegin(trio_posteriors), std::cend(trio_posteriors), std::back_inserter(trio_posterior_refs));
std::sort(std::begin(trio_posterior_refs), std::end(trio_posterior_refs),
[] (const auto& lhs, const auto& rhs) { return lhs.get().probability > rhs.get().probability; });
auto viable_map_itr = std::find_if(std::next(std::cbegin(trio_posterior_refs)), std::cend(trio_posterior_refs),
[&] (const auto& p) {
return is_viable_genotype_call(p, germline_calls, denovo_calls);
});
if (viable_map_itr != std::cend(trio_posterior_refs)) {
return to_call(*viable_map_itr);
} else {
return to_call(*map_itr);
}
}
}
bool includes(const TrioCall& trio, const CalledGermlineVariant& call)
{
return includes(trio, call.variant.alt_allele());
}
bool includes(const TrioCall& trio, const CalledDenovo& call)
{
return includes(trio, call.allele);
}
template <typename T>
void remove_ungenotyped_allele(std::vector<T>& calls, const TrioCall& trio)
{
auto itr = std::remove_if(std::begin(calls), std::end(calls),
[&] (const auto& call) { return !includes(trio, call); });
calls.erase(itr, std::end(calls));
}
void remove_ungenotyped_allele(std::vector<CalledGermlineVariant>& germline_calls,
std::vector<CalledDenovo>& denovo_calls,
const TrioCall& trio)
{
remove_ungenotyped_allele(germline_calls, trio);
remove_ungenotyped_allele(denovo_calls, trio);
}
using GenotypeProbabilityMap = ProbabilityMatrix<Genotype<Haplotype>>;
auto compute_posterior(const Genotype<Allele>& genotype,
const GenotypeProbabilityMap::InnerMap& posteriors)
{
auto p = std::accumulate(std::cbegin(posteriors), std::cend(posteriors), 0.0,
[&genotype] (const double curr, const auto& p) {
return curr + (contains(p.first, genotype) ? 0.0 : p.second);
});
return probability_to_phred(p);
}
struct GenotypePosterior
{
Genotype<Allele> genotype;
Phred<double> posterior;
};
struct GenotypedTrio
{
GenotypePosterior mother, father, child;
};
auto call_genotypes(const Trio& trio, const TrioCall& called_trio,
const GenotypeProbabilityMap& trio_posteriors,
const std::vector<GenomicRegion>& regions)
{
std::vector<GenotypedTrio> result {};
result.reserve(regions.size());
for (const auto& region : regions) {
auto mother_genotype = copy<Allele>(called_trio.mother, region);
auto mother_posterior = compute_posterior(mother_genotype, trio_posteriors[trio.mother()]);
auto father_genotype = copy<Allele>(called_trio.father, region);
auto father_posterior = compute_posterior(father_genotype, trio_posteriors[trio.father()]);
auto child_genotype = copy<Allele>(called_trio.child, region);
auto child_posterior = compute_posterior(child_genotype, trio_posteriors[trio.child()]);
result.push_back({{std::move(mother_genotype), mother_posterior},
{std::move(father_genotype), father_posterior},
{std::move(child_genotype), child_posterior}});
}
return result;
}
bool is_reference_reversion(const Allele& denovo, const std::map<Allele, Allele>& reference_alleles)
{
return reference_alleles.at(denovo) == denovo;
}
auto make_variant(Allele&& denovo, const std::map<Allele, Allele>& reference_alleles)
{
return Variant {reference_alleles.at(denovo), std::move(denovo)};
}
auto make_genotype_calls(GenotypedTrio&& call, const Trio& trio)
{
return std::vector<std::pair<SampleName, Call::GenotypeCall>> {
{trio.mother(), {std::move(call.mother.genotype), call.mother.posterior}},
{trio.father(), {std::move(call.father.genotype), call.father.posterior}},
{trio.child(), {std::move(call.child.genotype), call.child.posterior}}
};
}
auto make_calls(std::vector<CalledDenovo>&& alleles,
std::vector<GenotypedTrio>&& genotypes,
const Trio& trio,
const std::vector<Variant>& candidates)
{
std::map<Allele, Allele> reference_alleles {};
for (const auto& denovo : alleles) {
auto iter = std::find_if(std::cbegin(candidates), std::cend(candidates),
[denovo] (const auto& c) { return is_same_region(c, denovo); });
reference_alleles.emplace(denovo.allele, iter->ref_allele());
}
std::vector<std::unique_ptr<VariantCall>> result {};
result.reserve(alleles.size());
std::transform(std::make_move_iterator(std::begin(alleles)),
std::make_move_iterator(std::end(alleles)),
std::make_move_iterator(std::begin(genotypes)),
std::back_inserter(result),
[&trio, &reference_alleles] (auto&& allele, auto&& genotype) -> std::unique_ptr<DenovoCall> {
if (is_reference_reversion(allele.allele, reference_alleles)) {
return std::make_unique<DenovoReferenceReversionCall>(std::move(allele.allele),
make_genotype_calls(std::move(genotype), trio),
allele.posterior);
} else {
return std::make_unique<DenovoCall>(make_variant(std::move(allele.allele), reference_alleles),
make_genotype_calls(std::move(genotype), trio),
allele.posterior);
}
});
return result;
}
auto make_calls(std::vector<CalledGermlineVariant>&& variants,
std::vector<GenotypedTrio>&& genotypes,
const Trio& trio)
{
std::vector<std::unique_ptr<VariantCall>> result {};
result.reserve(variants.size());
std::transform(std::make_move_iterator(std::begin(variants)),
std::make_move_iterator(std::end(variants)),
std::make_move_iterator(std::begin(genotypes)),
std::back_inserter(result),
[&trio] (auto&& variant, auto&& genotype) {
return std::make_unique<GermlineVariantCall>(std::move(variant.variant),
make_genotype_calls(std::move(genotype), trio),
variant.posterior);
});
return result;
}
auto make_calls(std::vector<CalledGermlineVariant>&& variants,
std::vector<GenotypedTrio>&& germline_genotypes,
std::vector<CalledDenovo>&& alleles,
std::vector<GenotypedTrio>&& denovo_genotypes,
const Trio& trio, const std::vector<Variant>& candidates)
{
auto germline_calls = make_calls(std::move(variants), std::move(germline_genotypes), trio);
auto denovo_calls = make_calls(std::move(alleles), std::move(denovo_genotypes), trio, candidates);
std::vector<std::unique_ptr<VariantCall>> result {};
result.reserve(germline_calls.size() + denovo_calls.size());
std::merge(std::make_move_iterator(std::begin(germline_calls)),
std::make_move_iterator(std::end(germline_calls)),
std::make_move_iterator(std::begin(denovo_calls)),
std::make_move_iterator(std::end(denovo_calls)),
std::back_inserter(result),
[] (const auto& lhs, const auto& rhs) {
return lhs->mapped_region() < rhs->mapped_region();
});
return result;
}
} // namespace
namespace debug {
void log(const TrioProbabilityVector& posteriors,
boost::optional<logging::DebugLogger>& debug_log,
boost::optional<logging::TraceLogger>& trace_log);
void log(const AllelePosteriorMap& posteriors,
boost::optional<logging::DebugLogger>& debug_log,
boost::optional<logging::TraceLogger>& trace_log,
Phred<double> min_posterior, bool denovo = false);
} // namespace debug
std::vector<std::unique_ptr<VariantCall>>
TrioCaller::call_variants(const std::vector<Variant>& candidates, const Latents& latents) const
{
const auto alleles = decompose(candidates);
const auto& trio_posteriors = latents.model_latents.posteriors.joint_genotype_probabilities;
debug::log(trio_posteriors, debug_log_, trace_log_);
const auto allele_posteriors = compute_posteriors(alleles, trio_posteriors);
debug::log(allele_posteriors, debug_log_, trace_log_, parameters_.min_variant_posterior);
const auto called_alleles = call_alleles(allele_posteriors, parameters_.min_variant_posterior);
const auto denovo_posteriors = compute_denovo_posteriors(called_alleles, trio_posteriors);
debug::log(denovo_posteriors, debug_log_, trace_log_, parameters_.min_denovo_posterior, true);
auto denovos = call_denovos(denovo_posteriors, parameters_.min_denovo_posterior);
const auto germline_alleles = get_germline_alleles(called_alleles, denovos);
auto germline_variants = call_germline_variants(germline_alleles, candidates, parameters_.min_variant_posterior);
const auto called_trio = call_trio(trio_posteriors, germline_variants, denovos);
remove_ungenotyped_allele(germline_variants, denovos, called_trio);
auto denovo_genotypes = call_genotypes(parameters_.trio, called_trio, *latents.genotype_posteriors(),
extract_regions(denovos));
auto germline_genotypes = call_genotypes(parameters_.trio, called_trio, *latents.genotype_posteriors(),
extract_regions(germline_variants));
return make_calls(std::move(germline_variants), std::move(germline_genotypes),
std::move(denovos), std::move(denovo_genotypes),
parameters_.trio, candidates);
}
std::vector<std::unique_ptr<ReferenceCall>>
TrioCaller::call_reference(const std::vector<Allele>& alleles, const Caller::Latents& latents,
const ReadMap& reads) const
{
return call_reference(alleles, dynamic_cast<const Latents&>(latents), reads);
}
std::vector<std::unique_ptr<ReferenceCall>>
TrioCaller::call_reference(const std::vector<Allele>& alleles, const Latents& latents,
const ReadMap& reads) const
{
return {};
}
std::unique_ptr<PopulationPriorModel> TrioCaller::make_prior_model(const std::vector<Haplotype>& haplotypes) const
{
if (parameters_.germline_prior_model_params) {
return std::make_unique<CoalescentPopulationPriorModel>(CoalescentModel {
Haplotype {mapped_region(haplotypes.front()), reference_},
*parameters_.germline_prior_model_params,
haplotypes.size(), CoalescentModel::CachingStrategy::address
});
} else {
return std::make_unique<UniformPopulationPriorModel>();
}
}
namespace debug {
template <typename S>
void print(S&& stream, const TrioProbabilityVector& posteriors, const std::size_t n)
{
const auto m = std::min(n, posteriors.size());
if (m == posteriors.size()) {
stream << "Printing all trio joint genotype posteriors (maternal | paternal | child)" << '\n';
} else {
stream << "Printing top " << m << " trio joint genotype posteriors (maternal | paternal | child)" << '\n';
}
std::vector<JointProbability> v {};
v.reserve(posteriors.size());
std::copy(std::cbegin(posteriors), std::cend(posteriors), std::back_inserter(v));
const auto mth = std::next(std::begin(v), m);
std::partial_sort(std::begin(v), mth, std::end(v),
[] (const auto& lhs, const auto& rhs) { return lhs.probability > rhs.probability; });
std::for_each(std::begin(v), mth,
[&] (const auto& p) {
using octopus::debug::print_variant_alleles;
print_variant_alleles(stream, p.maternal);
stream << " | ";
print_variant_alleles(stream, p.paternal);
stream << " | ";
print_variant_alleles(stream, p.child);
stream << " " << p.probability << "\n";
});
}
void log(const TrioProbabilityVector& posteriors,
boost::optional<logging::DebugLogger>& debug_log,
boost::optional<logging::TraceLogger>& trace_log)
{
if (trace_log) {
print(stream(*trace_log), posteriors, -1);
}
if (debug_log) {
print(stream(*debug_log), posteriors, 10);
}
}
template <typename S>
void print(S&& stream, const AllelePosteriorMap& posteriors, const std::size_t n,
const std::string& type = "allele")
{
const auto m = std::min(n, posteriors.size());
if (m == posteriors.size()) {
stream << "Printing all " << type << " posteriors" << '\n';
} else {
stream << "Printing top " << m << " " << type << " posteriors" << '\n';
}
std::vector<std::pair<Allele, Phred<double>>> v {};
v.reserve(posteriors.size());
std::copy(std::cbegin(posteriors), std::cend(posteriors), std::back_inserter(v));
const auto mth = std::next(std::begin(v), m);
std::partial_sort(std::begin(v), mth, std::end(v),
[] (const auto& lhs, const auto& rhs) { return lhs.second > rhs.second; });
std::for_each(std::begin(v), mth,
[&] (const auto& p) {
stream << p.first << " " << p.second.probability_true() << '\n';
});
}
void log(const AllelePosteriorMap& posteriors,
boost::optional<logging::DebugLogger>& debug_log,
boost::optional<logging::TraceLogger>& trace_log,
Phred<double> min_posterior, const bool denovo)
{
if (!denovo || !posteriors.empty()) {
const std::string type {denovo ? "denovo allele" : "allele"};
if (trace_log) {
print(stream(*trace_log), posteriors, -1, type);
}
if (debug_log) {
const auto n = std::count_if(std::cbegin(posteriors), std::cend(posteriors),
[=] (const auto& p) { return p.second >= min_posterior; });
print(stream(*debug_log), posteriors, std::max(n, decltype(n) {10}), type);
}
}
}
} // namespace debug
} // namespace octopus
| 42.775362 | 135 | 0.654703 | alimanfoo |
69e7c7f74bc79ccac4886ec37eaff73dbf6343cb | 4,538 | cpp | C++ | RompLib/src/QueryFuncs.cpp | World-Worst-Detector/romp | d45cf33bd233eef4cd475a8dd328d19a3ae27c24 | [
"MIT"
] | 5 | 2018-11-15T16:44:06.000Z | 2022-03-01T05:39:54.000Z | RompLib/src/QueryFuncs.cpp | World-Worst-Detector/romp | d45cf33bd233eef4cd475a8dd328d19a3ae27c24 | [
"MIT"
] | 5 | 2019-03-12T16:03:13.000Z | 2022-01-15T01:23:59.000Z | RompLib/src/QueryFuncs.cpp | World-Worst-Detector/romp | d45cf33bd233eef4cd475a8dd328d19a3ae27c24 | [
"MIT"
] | 6 | 2019-01-03T22:19:14.000Z | 2021-06-23T18:10:49.000Z | #include "QueryFuncs.h"
#include <glog/logging.h>
#include <glog/raw_logging.h>
#include <pthread.h>
namespace romp {
/*
* Helper function to determine if the query function get available result.
*/
bool infoIsAvailable(const int retVal) {
if (retVal == 0) {
// task does not exist
return false;
} else if (retVal == 1) {
// task exists at the specified ancestor level but the information
// is not available
RAW_LOG(WARNING, "task exists but info is not available");
return false;
} else if (retVal == 2) {
// task exists at the specified ancestor level and the information
// is available
return true;
} else {
RAW_LOG(FATAL, "unknown return value");
return false;
}
}
/*
* Query all openmp task information given the task level in one time.
* This function could be called when multiple aspects of information about
* openmp task is needed.
*/
bool queryAllTaskInfo(const int ancestorLevel,
int& taskType,
int& threadNum,
AllTaskInfo& allTaskInfo) {
auto retVal = omptGetTaskInfo(ancestorLevel, &taskType,
&allTaskInfo.taskData, &allTaskInfo.taskFrame,
&allTaskInfo.parallelData, &threadNum);
return infoIsAvailable(retVal);
}
/*
* Query openmp task information given the task level. If the information is
* available, set dataPtr to the pointer to actual data, then return true.
* If the information is not available, set dataPtr to nullptr and return false.
*/
bool queryTaskInfo(const int ancestorLevel,
int& taskType,
int& threadNum,
void*& dataPtr) {
int retVal = -1;
dataPtr = nullptr;
ompt_data_t omptTaskData;
auto taskDataPtr = &omptTaskData;
auto taskDataPtrPtr = &taskDataPtr;
retVal = omptGetTaskInfo(ancestorLevel, &taskType, taskDataPtrPtr, NULL,
NULL, &threadNum);
dataPtr = taskDataPtr->ptr;
if (!dataPtr || !infoIsAvailable(retVal)) {
RAW_LOG(WARNING, "task data info is not available");
return false;
}
return true;
}
/*
* Query openmp task's frame information given the task level. If the
* information is available, set
*/
bool queryFrameInfo(const int ancestorLevel,
int& taskType,
ompt_frame_t* omptFramePtr) {
int retVal = -1;
auto omptFramePtrPtr = &omptFramePtr;
retVal = omptGetTaskInfo(ancestorLevel, &taskType, NULL, omptFramePtrPtr,
NULL, NULL);
if (!infoIsAvailable(retVal)) {
RAW_LOG(WARNING, "ompt frame info is not available");
return false;
}
return true;
}
/*
* Query openmp runtime information about the parallel region.
* On success, set dataPtr to pointer to parallel region data, and return true.
* Otherwise, set dataPtr to nullptr and return false.
*/
bool queryParallelInfo(
const int ancestorLevel,
int& teamSize,
void*& dataPtr) {
dataPtr = nullptr;
ompt_data_t omptParData;
auto parDataPtr = &omptParData;
auto parDataPtrPtr = &parDataPtr;
auto retVal = omptGetParallelInfo(ancestorLevel, parDataPtrPtr, &teamSize);
if (!infoIsAvailable(retVal)) {
return false;
}
dataPtr = parDataPtr->ptr;
return true;
}
/*
* Query openmp runtime information about the thread.
* If thread data pointer is not nullptr, return true and pass the pointer
* to dataPtr. Otherwise, return false.
*/
bool queryOmpThreadInfo(void*& dataPtr) {
dataPtr = nullptr;
auto curThreadData = omptGetThreadData();
if (!curThreadData || !(curThreadData->ptr)) {
return false;
}
dataPtr = curThreadData->ptr;
return true;
}
/*
* Query the stack base address and the stack size of the current thread.
* On success, return true. Otherwise, return false and set stackAddr to
* nullptr and staskSize to 0.
*/
bool queryThreadStackInfo(void*& stackAddr, size_t& stackSize) {
pthread_attr_t attr;
if (pthread_getattr_np(pthread_self(), &attr) != 0) {
RAW_LOG(WARNING, "cannot get pthread attribute");
return false;
}
if (pthread_attr_getstack(&attr, &stackAddr, &stackSize) != 0) {
RAW_LOG(WARNING, "cannot get thread stack info");
return false;
}
return true;
}
/*
* Query the task private data memory associated with the explicit task.
* The base address of the data memory is stored in `addr`. The size of the
* memory is stored in `size`.
*/
bool queryTaskMemoryInfo(void** addr, size_t* size) {
return omptGetTaskMemory(addr, size, 0) == 1;
}
}
| 29.660131 | 81 | 0.675408 | World-Worst-Detector |
69eb60b45c90ad1be47b31cfd9b394083c9c1fa1 | 10,745 | cpp | C++ | src/Generic/relations/VectorModel.cpp | BBN-E/serif | 1e2662d82fb1c377ec3c79355a5a9b0644606cb4 | [
"Apache-2.0"
] | 1 | 2022-03-24T19:57:00.000Z | 2022-03-24T19:57:00.000Z | src/Generic/relations/VectorModel.cpp | BBN-E/serif | 1e2662d82fb1c377ec3c79355a5a9b0644606cb4 | [
"Apache-2.0"
] | null | null | null | src/Generic/relations/VectorModel.cpp | BBN-E/serif | 1e2662d82fb1c377ec3c79355a5a9b0644606cb4 | [
"Apache-2.0"
] | null | null | null | // Copyright 2008 by BBN Technologies Corp.
// All Rights Reserved.
#include "Generic/common/leak_detection.h"
#include "Generic/relations/VectorModel.h"
#include "Generic/common/Symbol.h"
#include "Generic/common/NgramScoreTable.h"
#include "Generic/common/UTF8InputStream.h"
#include "Generic/common/UTF8Token.h"
#include "Generic/common/ParamReader.h"
#include "Generic/relations/PotentialRelationInstance.h"
#include "Generic/relations/xx_RelationUtilities.h"
#include "Generic/relations/RelationTypeSet.h"
#include "Generic/relations/discmodel/DTRelationSet.h"
#include "Generic/relations/discmodel/RelationObservation.h"
#include "Generic/relations/discmodel/RelationPropLink.h"
#include "Generic/theories/Parse.h"
#include "Generic/state/StateLoader.h"
#include "Generic/state/TrainingLoader.h"
#include "Generic/theories/Parse.h"
#include "Generic/theories/MentionSet.h"
#include "Generic/theories/PropositionSet.h"
#include "Generic/common/StringTransliterator.h"
#include "math.h"
#include <boost/scoped_ptr.hpp>
VectorModel::VectorModel(const char *file_prefix, bool splitlevel)
{
boost::scoped_ptr<UTF8InputStream> stream_scoped_ptr(UTF8InputStream::build());
UTF8InputStream& stream(*stream_scoped_ptr);
stream.open(file_prefix);
_model = type_feature_vector_model_t::build(stream);
stream.close();
char b2pStr[500];
sprintf(b2pStr, "%s.b2p", file_prefix);
boost::scoped_ptr<UTF8InputStream> b2pStream_scoped_ptr(UTF8InputStream::build());
UTF8InputStream& b2pStream(*b2pStream_scoped_ptr);
b2pStream.open(b2pStr);
_b2pModel = type_b2p_feature_vector_model_t::build(b2pStream);
b2pStream.close();
SPLIT_LEVEL_DECISION = splitlevel;
}
VectorModel::VectorModel() : SPLIT_LEVEL_DECISION(false)
{
}
VectorModel::~VectorModel() {
delete _model;
delete _b2pModel;
}
void VectorModel::train(char *training_file, char* output_file_prefix)
{
boost::scoped_ptr<UTF8InputStream> in_scoped_ptr(UTF8InputStream::build());
UTF8InputStream& in(*in_scoped_ptr);
in.open(training_file);
_originalData = _new NgramScoreTable(13, in);
in.close();
_model = type_feature_vector_model_t::build();
_b2pModel = type_b2p_feature_vector_model_t::build();
PotentialRelationInstance *inst = _new PotentialRelationInstance();
NgramScoreTable::Table::iterator iter;
for (iter = _originalData->get_start(); iter != _originalData->get_end(); ++iter) {
float count = (*iter).second;
inst->setFromTrainingNgram((*iter).first);
int t = RelationTypeSet::getTypeFromSymbol(inst->getRelationType());
if (!RelationTypeSet::isSymmetric(t) && inst->isReversed())
{
t = RelationTypeSet::reverse(t);
inst->setRelationType(RelationTypeSet::getRelationSymbol(t));
}
inst->setReverse(false);
_model->addEvent(inst, Symbol());
_b2pModel->addEvent(inst, Symbol());
}
_model->deriveModel();
_b2pModel->deriveModel();
UTF8OutputStream stream;
stream.open(output_file_prefix);
_model->print(stream);
stream.close();
char b2pStr[500];
sprintf(b2pStr, "%s.b2p", output_file_prefix);
UTF8OutputStream b2pStream;
b2pStream.open(b2pStr);
_b2pModel->print(b2pStream);
b2pStream.close();
}
void VectorModel::trainFromStateFileList(char *training_file, char* output_file_prefix)
{
_model = type_feature_vector_model_t::build();
_b2pModel = type_b2p_feature_vector_model_t::build();
_observation = _new RelationObservation();
_inst = _new PotentialRelationInstance();
int beam_width = ParamReader::getOptionalIntParamWithDefaultValue("beam_width",1);
TrainingLoader *trainingLoader = _new TrainingLoader(training_file, L"doc-relations-events");
trainFromLoader(trainingLoader);
delete trainingLoader;
_model->deriveModel();
_b2pModel->deriveModel();
UTF8OutputStream stream;
stream.open(output_file_prefix);
_model->print(stream);
stream.close();
char b2pStr[500];
sprintf(b2pStr, "%s.b2p", output_file_prefix);
UTF8OutputStream b2pStream;
b2pStream.open(b2pStr);
_b2pModel->print(b2pStream);
b2pStream.close();
}
void VectorModel::trainFromLoader(TrainingLoader *trainingLoader)
{
for (int i = 0; i < trainingLoader->getMaxSentences(); i++) {
SentenceTheory *theory = trainingLoader->getNextSentenceTheory();
if (theory == 0)
break;
const Parse* parse = theory->getPrimaryParse();
MentionSet* mentionSet = theory->getMentionSet();
PropositionSet *propSet = theory->getPropositionSet();
ValueMentionSet *valueSet = theory->getValueMentionSet();
propSet->fillDefinitionsArray();
DTRelationSet *relSet = _new DTRelationSet(mentionSet->getNMentions(),
theory->getRelMentionSet(), Symbol(L"NONE"));
trainFromSentence(parse, mentionSet, valueSet, propSet, relSet);
}
}
void VectorModel::trainFromSentence(const Parse* parse, const MentionSet* mset,
const ValueMentionSet *vset,
PropositionSet *propSet, DTRelationSet *relSet)
{
_observation->resetForNewSentence(parse, mset, vset, propSet);
int nmentions = mset->getNMentions();
for (int i = 0; i < nmentions; i++) {
if (!mset->getMention(i)->isOfRecognizedType() ||
mset->getMention(i)->getMentionType() == Mention::NONE ||
mset->getMention(i)->getMentionType() == Mention::APPO ||
mset->getMention(i)->getMentionType() == Mention::LIST)
continue;
for (int j = i + 1; j < nmentions; j++) {
if (!mset->getMention(j)->isOfRecognizedType() ||
mset->getMention(j)->getMentionType() == Mention::NONE ||
mset->getMention(j)->getMentionType() == Mention::APPO ||
mset->getMention(j)->getMentionType() == Mention::LIST)
continue;
if (!RelationUtilities::get()->validRelationArgs(mset->getMention(i), mset->getMention(j)))
continue;
_observation->populate(i, j);
// ordering is changed by _observation --> it might not be i, j
int left = _observation->getMention1()->getIndex();
int right = _observation->getMention2()->getIndex();
RelationPropLink *link = _observation->getPropLink();
_inst->setStandardInstance(_observation);
_inst->setRelationType(relSet->getRelation(left, right));
if (!link->isEmpty() && !link->isNegative()) {
_model->addEvent(_inst, Symbol());
}
if (relSet->hasReversedRelation(left, right)) {
int t = RelationTypeSet::getTypeFromSymbol(_inst->getRelationType());
if (!RelationTypeSet::isSymmetric(t))
{
t = RelationTypeSet::reverse(t);
_inst->setRelationType(RelationTypeSet::getRelationSymbol(t));
}
}
_b2pModel->addEvent(_inst, Symbol());
}
}
}
bool VectorModel::hasZeroProbability(PotentialRelationInstance *instance, int type) {
instance->setRelationType(RelationTypeSet::getRelationSymbol(type));
return (lookup(instance) <= -10000);
}
int VectorModel::findBestRelationType(PotentialRelationInstance *instance) {
if (SPLIT_LEVEL_DECISION) {
float all_other_score = 0;
// get & report none score
instance->setRelationType(RelationTypeSet::getRelationSymbol(0));
float none_score = lookup(instance);
/*if (RelationUtilities::get()->debugStreamIsOn()) {
RelationUtilities::get()->getDebugStream() << L"VECTOR NONE SCORE: ";
RelationUtilities::get()->getDebugStream() << none_score << L"\n";
}*/
// get & sum all other scores
for (int i = 1; i < RelationTypeSet::N_RELATION_TYPES; i++) {
instance->setRelationType(RelationTypeSet::getRelationSymbol(i));
float probability = lookup(instance);
if (probability != -10000)
all_other_score += exp(probability);
if (!RelationTypeSet::isSymmetric(i)) {
int revtype = RelationTypeSet::reverse(i);
instance->setRelationType(RelationTypeSet::getRelationSymbol(revtype));
float probability = lookup(instance);
if (probability != -10000)
all_other_score += exp(probability);
}
}
// if no options other than NONE, return NONE
if (all_other_score == 0)
return 0;
// if there are options other than NONE, report them
/*if (RelationUtilities::get()->debugStreamIsOn()) {
RelationUtilities::get()->getDebugStream() << L"ALL OTHER SCORE: ";
RelationUtilities::get()->getDebugStream() << log(all_other_score) << L"\n\n";
}*/
// return NONE only if...
if (none_score > log(all_other_score)) {
return 0;
}
}
int best_answer = 0;
float best_score = -10000;
int second_best_answer = 0;
float second_best_score = -10000;
for (int i = 0; i < RelationTypeSet::N_RELATION_TYPES; i++) {
if (SPLIT_LEVEL_DECISION && i==0)
continue;
instance->setRelationType(RelationTypeSet::getRelationSymbol(i));
float probability = lookup(instance);
if (probability > best_score) {
second_best_score = best_score;
second_best_answer = best_answer;
best_score = probability;
best_answer = i;
} else if (probability > second_best_score) {
second_best_score = probability;
second_best_answer = i;
}
if (!RelationTypeSet::isSymmetric(i)) {
int revtype = RelationTypeSet::reverse(i);
instance->setRelationType(RelationTypeSet::getRelationSymbol(revtype));
float probability = lookup(instance);
if (probability > best_score) {
second_best_score = best_score;
second_best_answer = best_answer;
best_score = probability;
best_answer = revtype;
} else if (probability > second_best_score) {
second_best_score = probability;
second_best_answer = revtype;
}
}
}
/*if (RelationUtilities::get()->debugStreamIsOn()) {
RelationUtilities::get()->getDebugStream() << L"VECTOR BEST: ";
RelationUtilities::get()->getDebugStream() << RelationTypeSet::getRelationSymbol(best_answer).to_string();
RelationUtilities::get()->getDebugStream() << L" " << best_score << L"\n";
RelationUtilities::get()->getDebugStream() << L"VECTOR SECOND BEST: ";
RelationUtilities::get()->getDebugStream() << RelationTypeSet::getRelationSymbol(second_best_answer).to_string();
RelationUtilities::get()->getDebugStream() << L" " << second_best_score << L"\n\n";
}*/
return best_answer;
}
int VectorModel::findConfidentRelationType(PotentialRelationInstance *instance,
double lambda_threshold)
{
double lambda = _model->getLambdaForFullHistory(instance, Symbol());
if (lambda < lambda_threshold)
return 0;
return findBestRelationType(instance);
}
float VectorModel::lookup(PotentialRelationInstance *instance) const
{
return (float)_model->getProbability(instance, Symbol());
}
float VectorModel::lookupB2P(PotentialRelationInstance *instance) const
{
return (float)_b2pModel->getProbability(instance, Symbol());
}
| 33.266254 | 116 | 0.710656 | BBN-E |
69ece13f49b984a83383566514ce4983f0932571 | 546 | hpp | C++ | src/texture_create_info.hpp | zfccxt/calcium | 9cc3a00904c05e675bdb5d35eef0f5356796e564 | [
"MIT"
] | null | null | null | src/texture_create_info.hpp | zfccxt/calcium | 9cc3a00904c05e675bdb5d35eef0f5356796e564 | [
"MIT"
] | null | null | null | src/texture_create_info.hpp | zfccxt/calcium | 9cc3a00904c05e675bdb5d35eef0f5356796e564 | [
"MIT"
] | null | null | null | #pragma once
#include <string>
#include "colour.hpp"
#include "texture_filter.hpp"
#include "texture_wrap.hpp"
namespace cl {
// TODO: Name these better
struct TextureCreateInfo {
std::string file_path;
TextureFilter filter = TextureFilter::kLinear;
TextureWrap wrap = TextureWrap::kRepeat;
bool flip_vertical_on_load = false;
};
struct BlankTextureCreateInfo {
Colour colour = 0xd7de73ff;
size_t width = 1;
size_t height = 1;
TextureFilter filter = TextureFilter::kNearest;
TextureWrap wrap = TextureWrap::kRepeat;
};
}
| 18.827586 | 49 | 0.74359 | zfccxt |
69f1f8c7be5e684596c57065c80b22c0db0e137d | 2,504 | cpp | C++ | Toolbox/Win32_utilities/win32_stdDialogBox.cpp | pk1954/Solutions | b224522283f82cb7d73b8005e35e0c045edc2fc0 | [
"MIT"
] | null | null | null | Toolbox/Win32_utilities/win32_stdDialogBox.cpp | pk1954/Solutions | b224522283f82cb7d73b8005e35e0c045edc2fc0 | [
"MIT"
] | null | null | null | Toolbox/Win32_utilities/win32_stdDialogBox.cpp | pk1954/Solutions | b224522283f82cb7d73b8005e35e0c045edc2fc0 | [
"MIT"
] | null | null | null | // win32_stdDialogBox.cpp
//
// Win32_utilities
#include "stdafx.h"
#include <sstream>
#include "win32_util.h"
#include "win32_util_resource.h"
#include "win32_stdDialogBox.h"
using std::wostringstream;
static float m_fValue; // the value to be edited in the dialog
static wstring m_wstrUnit; // the text to be displayed right of the edit box
static wstring m_wstrTitle; // the title bar text of the dialog
float StdDialogBox::Show
(
HWND const hwndParent,
float fValue,
wstring const wstrTitle,
wstring const wstrUnit
)
{
m_wstrTitle = wstrTitle;
m_wstrUnit = wstrUnit;
m_fValue = fValue;
if (IDOK == DialogBox(nullptr, MAKEINTRESOURCE(IDD_STD_EDIT_DIALOG), hwndParent, dialogProc))
fValue = m_fValue;
return fValue;
}
void StdDialogBox::SetParameterValue(HWND const hwndEditField, float const fValue)
{
wostringstream m_wstrBuffer;
m_wstrBuffer << fValue;
SetWindowText(hwndEditField, m_wstrBuffer.str().c_str());
}
bool StdDialogBox::Evaluate(HWND const hwndEditField, float & fValue)
{
static int const BUFLEN = 20;
static wchar_t wBuffer[BUFLEN];
float fNewValue { fValue };
bool bResult { false };
if (GetWindowText(hwndEditField, wBuffer, BUFLEN))
{
wstring wstrEdit(wBuffer);
for (auto & c : wstrEdit) // change german decimal comma to
if (c == L',') // decimal point
c = L'.';
try
{
fNewValue = stof(wstrEdit);
fValue = fNewValue;
bResult = true;
} catch(...)
{
MessageBeep(MB_ICONWARNING);
}
}
SetParameterValue(hwndEditField, fValue);
return bResult;
}
INT_PTR CALLBACK dialogProc
(
HWND const hDlg,
UINT const message,
WPARAM const wParam,
LPARAM const lParam
)
{
switch (message)
{
case WM_INITDIALOG:
{
SetWindowText(hDlg, m_wstrTitle.c_str());
StdDialogBox::SetParameterValue(GetDlgItem(hDlg, IDD_EDIT_CTL), m_fValue);
SetWindowText(GetDlgItem(hDlg, IDC_STATIC), m_wstrUnit.c_str());
SendMessage(hDlg, DM_SETDEFID, IDOK, 0);
SendMessage(GetDlgItem(hDlg, IDCANCEL), BM_SETSTYLE, BS_PUSHBUTTON, 0);
return INT_PTR(true);
}
case WM_COMMAND:
if (LOWORD(wParam) == IDOK)
{
HWND hwndEditCtl { GetDlgItem(hDlg, IDD_EDIT_CTL) };
if (StdDialogBox::Evaluate(hwndEditCtl, m_fValue))
EndDialog(hDlg, LOWORD(wParam));
else
SetFocus(hwndEditCtl);
return INT_PTR(true);
}
else if (LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return INT_PTR(true);
}
break;
default:
break;
}
return INT_PTR(false);
}
| 21.586207 | 94 | 0.70647 | pk1954 |
69f92ee3881644f941ac77841dcec48f1da8506d | 6,118 | cc | C++ | webkit/fileapi/media/picasa/pmp_test_helper.cc | codenote/chromium-test | 0637af0080f7e80bf7d20b29ce94c5edc817f390 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | webkit/fileapi/media/picasa/pmp_test_helper.cc | codenote/chromium-test | 0637af0080f7e80bf7d20b29ce94c5edc817f390 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | webkit/fileapi/media/picasa/pmp_test_helper.cc | codenote/chromium-test | 0637af0080f7e80bf7d20b29ce94c5edc817f390 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 1 | 2020-11-04T07:25:45.000Z | 2020-11-04T07:25:45.000Z | // Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/fileapi/media/picasa/pmp_test_helper.h"
#include <algorithm>
#include <iterator>
#include "base/file_util.h"
#include "base/logging.h"
#include "base/utf_string_conversions.h"
#include "webkit/fileapi/media/picasa/pmp_column_reader.h"
namespace picasaimport {
namespace {
bool WriteToFile(const base::FilePath& path, std::vector<uint8> data) {
// Cast for usage in WriteFile function
const char* data_char = reinterpret_cast<const char*>(&data[0]);
size_t bytes_written = file_util::WriteFile(path, data_char, data.size());
return (bytes_written == data.size());
}
// Flatten a vector of elements into an array of bytes.
template<class T>
std::vector<uint8> Flatten(const std::vector<T>& elems) {
const uint8* elems0 = reinterpret_cast<const uint8*>(&elems[0]);
std::vector<uint8> data_body(elems0, elems0 + sizeof(T)*elems.size());
return data_body;
}
// Custom specialization for std::string.
template<>
std::vector<uint8> Flatten(const std::vector<std::string>& strings) {
std::vector<uint8> totalchars;
for(std::vector<std::string>::const_iterator it = strings.begin();
it != strings.end(); ++it) {
std::copy(it->begin(), it->end(), std::back_inserter(totalchars));
totalchars.push_back('\0'); // Add the null termination too.
}
return totalchars;
}
// Returns a new vector with the concatenated contents of |a| and |b|.
std::vector<uint8> CombinedVectors(const std::vector<uint8>& a,
const std::vector<uint8>& b) {
std::vector<uint8> total;
std::copy(a.begin(), a.end(), std::back_inserter(total));
std::copy(b.begin(), b.end(), std::back_inserter(total));
return total;
}
} // namespace
PmpTestHelper::PmpTestHelper() { }
bool PmpTestHelper::Init() {
return temp_dir_.CreateUniqueTempDir();
}
base::FilePath PmpTestHelper::GetTempDirPath() {
DCHECK(temp_dir_.IsValid());
return temp_dir_.path();
}
template<class T>
bool PmpTestHelper::WriteColumnFileFromVector(
const std::string& table_name, const std::string& column_name,
const PmpFieldType field_type, const std::vector<T>& elements_vector) {
DCHECK(temp_dir_.IsValid());
std::string file_name = table_name + "_" + column_name + "." + kPmpExtension;
base::FilePath path = temp_dir_.path().Append(
base::FilePath::FromUTF8Unsafe(file_name));
std::vector<uint8> data = PmpTestHelper::MakeHeaderAndBody(
field_type, elements_vector.size(), elements_vector);
return WriteToFile(path, data);
}
// Explicit Instantiation for all the valid types.
template bool PmpTestHelper::WriteColumnFileFromVector<std::string>(
const std::string&, const std::string&, const PmpFieldType,
const std::vector<std::string>&);
template bool PmpTestHelper::WriteColumnFileFromVector<uint32>(
const std::string&, const std::string&, const PmpFieldType,
const std::vector<uint32>&);
template bool PmpTestHelper::WriteColumnFileFromVector<double>(
const std::string&, const std::string&, const PmpFieldType,
const std::vector<double>&);
template bool PmpTestHelper::WriteColumnFileFromVector<uint8>(
const std::string&, const std::string&, const PmpFieldType,
const std::vector<uint8>&);
template bool PmpTestHelper::WriteColumnFileFromVector<uint64>(
const std::string&, const std::string&, const PmpFieldType,
const std::vector<uint64>&);
bool PmpTestHelper::InitColumnReaderFromBytes(
PmpColumnReader* const reader, const std::vector<uint8>& data,
uint32* rows_read) {
DCHECK(temp_dir_.IsValid());
base::FilePath temp_path;
if (!file_util::CreateTemporaryFileInDir(temp_dir_.path(), &temp_path) ||
!WriteToFile(temp_path, data)) {
return false;
}
bool success = reader->Init(temp_path, rows_read);
file_util::Delete(temp_path, true);
return success;
}
// Return a vector so we don't have to worry about memory management.
std::vector<uint8> PmpTestHelper::MakeHeader(const PmpFieldType field_type,
const uint32 row_count) {
std::vector<uint8> header(picasaimport::kPmpHeaderSize);
// Copy in magic bytes.
memcpy(&header[picasaimport::kPmpMagic1Offset], &picasaimport::kPmpMagic1,
sizeof(picasaimport::kPmpMagic1));
memcpy(&header[picasaimport::kPmpMagic2Offset], &picasaimport::kPmpMagic2,
sizeof(picasaimport::kPmpMagic2));
memcpy(&header[picasaimport::kPmpMagic3Offset], &picasaimport::kPmpMagic3,
sizeof(picasaimport::kPmpMagic3));
memcpy(&header[picasaimport::kPmpMagic4Offset], &picasaimport::kPmpMagic4,
sizeof(picasaimport::kPmpMagic4));
// Copy in field type.
memcpy(&header[picasaimport::kPmpFieldType1Offset], &field_type, 2);
memcpy(&header[picasaimport::kPmpFieldType2Offset], &field_type, 2);
// Copy in row count.
memcpy(&header[picasaimport::kPmpRowCountOffset], &row_count, 4);
return header;
}
template<class T>
std::vector<uint8> PmpTestHelper::MakeHeaderAndBody(
const PmpFieldType field_type, const uint32 row_count,
const std::vector<T>& elems) {
return CombinedVectors(PmpTestHelper::MakeHeader(field_type, row_count),
Flatten(elems));
}
// Explicit Instantiation for all the valid types.
template std::vector<uint8> PmpTestHelper::MakeHeaderAndBody<std::string>(
const PmpFieldType, const uint32, const std::vector<std::string>&);
template std::vector<uint8> PmpTestHelper::MakeHeaderAndBody<uint32>(
const PmpFieldType, const uint32, const std::vector<uint32>&);
template std::vector<uint8> PmpTestHelper::MakeHeaderAndBody<double>(
const PmpFieldType, const uint32, const std::vector<double>&);
template std::vector<uint8> PmpTestHelper::MakeHeaderAndBody<uint8>(
const PmpFieldType, const uint32, const std::vector<uint8>&);
template std::vector<uint8> PmpTestHelper::MakeHeaderAndBody<uint64>(
const PmpFieldType, const uint32, const std::vector<uint64>&);
} // namespace picasaimport
| 35.364162 | 79 | 0.721641 | codenote |
69f986fb0137e3a90cdec1ccda4505ab528f959b | 585 | cpp | C++ | tests/adjacent_loop/tests/generator.cpp | not522/Competitive-Programming | be4a7d25caf5acbb70783b12899474a56c34dedb | [
"Unlicense"
] | 7 | 2018-04-14T14:55:51.000Z | 2022-01-31T10:49:49.000Z | tests/adjacent_loop/tests/generator.cpp | not522/Competitive-Programming | be4a7d25caf5acbb70783b12899474a56c34dedb | [
"Unlicense"
] | 5 | 2018-04-14T14:28:49.000Z | 2019-05-11T02:22:10.000Z | tests/adjacent_loop/tests/generator.cpp | not522/Competitive-Programming | be4a7d25caf5acbb70783b12899474a56c34dedb | [
"Unlicense"
] | null | null | null | #include "generator.hpp"
#include "constraints.hpp"
void gen_random(stringstream &ss, const map<string, boost::any> &args) {
int n = any_cast<int>(args.at("n"));
int y = any_cast<int>(args.at("y"));
int x = any_cast<int>(args.at("x"));
ss << n << " " << y << " " << x << " " << 10 << " " << 10 << endl;
}
int main(int argc, char *argv[]) {
registerGen(argc, argv, 1);
map<string, vector<any>> args;
args["n"] = vector<any>{2, 4, 5, 8, 9};
args["y"] = vector<any>{0, 5, 9};
args["x"] = vector<any>{0, 5, 9};
generate_combination("10_random_", gen_random, args);
}
| 30.789474 | 72 | 0.57094 | not522 |
69fa8d36192e4d157033ef85d7fa1a7b4b595684 | 1,154 | cpp | C++ | aws-cpp-sdk-chime/source/model/BatchCreateRoomMembershipRequest.cpp | Neusoft-Technology-Solutions/aws-sdk-cpp | 88c041828b0dbee18a297c3cfe98c5ecd0706d0b | [
"Apache-2.0"
] | 1 | 2022-02-10T08:06:54.000Z | 2022-02-10T08:06:54.000Z | aws-cpp-sdk-chime/source/model/BatchCreateRoomMembershipRequest.cpp | Neusoft-Technology-Solutions/aws-sdk-cpp | 88c041828b0dbee18a297c3cfe98c5ecd0706d0b | [
"Apache-2.0"
] | 1 | 2022-01-03T23:59:37.000Z | 2022-01-03T23:59:37.000Z | aws-cpp-sdk-chime/source/model/BatchCreateRoomMembershipRequest.cpp | ravindra-wagh/aws-sdk-cpp | 7d5ff01b3c3b872f31ca98fb4ce868cd01e97696 | [
"Apache-2.0"
] | 1 | 2022-03-23T15:17:18.000Z | 2022-03-23T15:17:18.000Z | /**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/chime/model/BatchCreateRoomMembershipRequest.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <utility>
using namespace Aws::Chime::Model;
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
BatchCreateRoomMembershipRequest::BatchCreateRoomMembershipRequest() :
m_accountIdHasBeenSet(false),
m_roomIdHasBeenSet(false),
m_membershipItemListHasBeenSet(false)
{
}
Aws::String BatchCreateRoomMembershipRequest::SerializePayload() const
{
JsonValue payload;
if(m_membershipItemListHasBeenSet)
{
Array<JsonValue> membershipItemListJsonList(m_membershipItemList.size());
for(unsigned membershipItemListIndex = 0; membershipItemListIndex < membershipItemListJsonList.GetLength(); ++membershipItemListIndex)
{
membershipItemListJsonList[membershipItemListIndex].AsObject(m_membershipItemList[membershipItemListIndex].Jsonize());
}
payload.WithArray("MembershipItemList", std::move(membershipItemListJsonList));
}
return payload.View().WriteReadable();
}
| 26.837209 | 137 | 0.783362 | Neusoft-Technology-Solutions |
69facbb96269bdbf16fdb4a385318085e2be31ee | 621 | cpp | C++ | cpp-main-big/src/main.cpp | dksmiffs/gnatmake-examples | 237c0cd9fe8d4788f8898509319a3a665d2233b1 | [
"MIT"
] | null | null | null | cpp-main-big/src/main.cpp | dksmiffs/gnatmake-examples | 237c0cd9fe8d4788f8898509319a3a665d2233b1 | [
"MIT"
] | null | null | null | cpp-main-big/src/main.cpp | dksmiffs/gnatmake-examples | 237c0cd9fe8d4788f8898509319a3a665d2233b1 | [
"MIT"
] | null | null | null | #include <iostream>
#include "i_am_c.h"
#include "i_am_cpp.hpp"
extern "C" void adainit();
extern "C" void adafinal();
extern "C" void ada_procedure();
extern "C" void ada_procedure_too();
int main()
{
std::cout << "Starting C++ main." << std::endl;
adainit();
std::cout << "Calling external C++ code from C++ main." << std::endl;
test::i_am_cpp();
std::cout << "Calling external C code from C++ main." << std::endl;
i_am_c();
std::cout << "Calling external Ada code from C++ main." << std::endl;
ada_procedure();
ada_procedure_too();
adafinal();
std::cout << "Exiting C++ main." << std::endl;
}
| 24.84 | 71 | 0.628019 | dksmiffs |
69fe0386c91b1531c34533d61f21a49c2766ce5c | 1,954 | cpp | C++ | luogu/codes/P1514.cpp | Tony031218/OI | 562f5f45d0448f4eab77643b99b825405a123d92 | [
"MIT"
] | 1 | 2021-02-22T03:39:24.000Z | 2021-02-22T03:39:24.000Z | luogu/codes/P1514.cpp | Tony031218/OI | 562f5f45d0448f4eab77643b99b825405a123d92 | [
"MIT"
] | null | null | null | luogu/codes/P1514.cpp | Tony031218/OI | 562f5f45d0448f4eab77643b99b825405a123d92 | [
"MIT"
] | null | null | null | /*************************************************************
* > File Name : P1514.cpp
* > Author : Tony
* > Created Time : 2019/06/21 15:10:31
* > Algorithm : [Dfs]Ex
**************************************************************/
#include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0; int f = 1; char ch = getchar();
while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
while (isdigit(ch)) {x = x * 10 + ch - 48; ch = getchar();}
return x * f;
}
const int maxn = 510;
int n, m;
int high[maxn][maxn];
int l[maxn][maxn], r[maxn][maxn];
bool vis[maxn][maxn];
int go[4][2] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
void dfs(int x, int y) {
vis[x][y] = true;
for (int i = 0; i < 4; ++i) {
int x2 = x + go[i][0];
int y2 = y + go[i][1];
if (x2 < 1 || x2 > n || y2 < 1 || y2 > m || high[x2][y2] >= high[x][y]) continue;
if (!vis[x2][y2]) dfs(x2, y2);
l[x][y] = min(l[x][y], l[x2][y2]);
r[x][y] = max(r[x][y], r[x2][y2]);
}
}
int main() {
n = read(); m = read();
memset(l, 0x3f, sizeof(l));
for (int i = 1; i <= m; ++i) {
l[n][i] = r[n][i] = i;
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
high[i][j] = read();
}
}
for (int i = 1; i <= m; ++i) {
if (!vis[1][i]) {
dfs(1, i);
}
}
bool flg = true; int cnt = 0;
for (int i = 1; i <= m; ++i) {
if (!vis[n][i]) {
flg = false;
cnt++;
}
}
if (!flg) {
printf("0\n%d\n", cnt);
return 0;
}
int le = 1, ans = 0;
while (le <= m) {
int tmp = 0;
for (int i = 1; i <= m; ++i) {
if (l[1][i] <= le) {
tmp = max(tmp, r[1][i]);
}
}
ans++;
le = tmp + 1;
}
printf("1\n%d\n", ans);
return 0;
} | 24.734177 | 89 | 0.351586 | Tony031218 |
69ff0364c09954f0a2975f8033527c51556d1c65 | 6,754 | cc | C++ | src/openclx/compiler.cc | igankevich/openclx | 5063635392619eef84e536f24f8252ea41a5ffe6 | [
"Unlicense"
] | null | null | null | src/openclx/compiler.cc | igankevich/openclx | 5063635392619eef84e536f24f8252ea41a5ffe6 | [
"Unlicense"
] | null | null | null | src/openclx/compiler.cc | igankevich/openclx | 5063635392619eef84e536f24f8252ea41a5ffe6 | [
"Unlicense"
] | null | null | null | #include <dirent.h>
#include <fstream>
#include <iomanip>
#include <sstream>
#include <openclx/binary>
#include <openclx/compiler>
#include <openclx/kernel>
#include <openclx/platform>
#define CLX_SYS_THROW() \
throw ::std::system_error(errno, ::std::system_category())
#define CLX_SYS_CHECK(ret) \
if (ret == -1) { \
CLX_SYS_THROW(); \
}
namespace {
typedef ::DIR directory;
typedef struct ::dirent directory_entry;
constexpr const char file_separator = '/';
constexpr const int max_includes = 1000;
}
std::string
clx::compiler::inline_sources(std::string src) const {
int nincludes = 0;
std::string include = "#include";
for (size_t offset=0;
offset!=std::string::npos && offset<src.size() && nincludes<max_includes;
offset=src.find(include, offset)) {
size_t i=offset+include.size();
// skip spaces
for (; i<src.size() && std::isspace(src[i]); ++i);
if (i < src.size()) {
char s = '"';
if (src[i] == '"') { s = '"'; }
else if (src[i] == '<') { s = '>'; }
else continue;
size_t j = i+1;
// find closing quote
for (; j<src.size() && src[j]!=s && (s=='>' || (s=='"' && src[j-1]!='\\')); ++j);
if (j < src.size()) { src += file_to_string(src.substr(i+1,j-i-1)); ++nincludes; }
}
offset = i;
}
return src;
}
std::string
clx::compiler::file_to_string(const std::string& filename) const {
const auto& src = this->source_directory();
const auto& suffix = this->suffix();
std::string path;
path.reserve(filename.size() + suffix.size() + src.size() + 1);
path += src;
path += file_separator;
path += filename;
path += suffix;
std::stringstream tmp;
std::ifstream in;
in.exceptions(std::ios::failbit | std::ios::badbit);
in.open(path, std::ios::in);
tmp << in.rdbuf();
return tmp.str();
}
std::string
clx::compiler::binary_path(const std::string& filename, size_t number) const {
std::stringstream name;
name << this->cache_directory();
name << file_separator;
name << filename << '-';
name << std::setfill('0') << std::setw(2*sizeof(number)) << std::hex << number;
return name.str();
}
clx::program
clx::compiler::compile(const std::string& filename) {
program prg;
this->compile(prg, filename, file_to_string(filename));
return prg;
}
clx::program
clx::compiler::compile(const std::string& filename, const std::string& src) {
program prg;
this->compile(prg, filename, src);
return prg;
}
void
clx::compiler::compile(
program& prg,
const std::string& filename,
const std::string& src
) {
if (cache()) {
hash_type hash;
const auto& devices = this->devices();
try {
std::vector<binary> binaries;
binaries.reserve(devices.size());
for (const auto& device : devices) {
auto key = hash(salt(device) + inline_sources(src));
const auto& path = binary_path(filename, key);
std::ifstream in;
in.exceptions(std::ios::failbit | std::ios::badbit);
in.open(path, std::ios::binary | std::ios::in);
binaries.emplace_back();
in >> binaries.back();
}
prg = this->_context.program(binaries);
prg.build(options(), devices);
} catch (const std::exception& err) {
this->compile_from_source(prg, src);
const auto& binaries = prg.binaries();
const auto ndevices = devices.size();
for (size_t i=0; i<ndevices; ++i) {
const auto& device = devices[i];
const auto& binary = binaries[i];
auto key = hash(salt(device) + inline_sources(src));
const auto& path = binary_path(filename, key);
std::ofstream out;
out.exceptions(std::ios::failbit | std::ios::badbit);
out.open(path, std::ios::binary | std::ios::out);
out << binary;
out.close();
}
}
} else {
this->compile_from_source(prg, src);
}
}
void
clx::compiler::compile_from_source(program& prg, const std::string& src) {
prg = this->_context.program(src);
try {
prg.build(options(), devices());
} catch (const std::system_error& err) {
if (errc(err.code().value()) == errc::build_program_failure) {
throw std::system_error(err.code(), this->errors(prg));
}
throw;
}
}
void
clx::compiler::compile() {
directory* dir = ::opendir(this->_source_directory.data());
if (!dir) { CLX_SYS_THROW(); }
directory_entry* entry;
const auto& suffix = this->suffix();
const auto n = suffix.size();
while ((entry = ::readdir(dir))) {
std::string filename = entry->d_name;
if (filename.size() < n ||
filename.compare(filename.size()-n, n, suffix) != 0) {
continue;
}
this->compile(entry->d_name);
}
CLX_SYS_CHECK(::closedir(dir));
}
void
clx::compiler::clear_cache() {
directory* dir = ::opendir(this->_cache_directory.data());
if (!dir) { CLX_SYS_THROW(); }
directory_entry* entry;
while ((entry = ::readdir(dir))) {
std::string path;
path += source_directory();
path += file_separator;
path += entry->d_name;
std::remove(path.data());
}
CLX_SYS_CHECK(::closedir(dir));
}
std::string
clx::compiler::errors(const program& prg) const {
std::string logs;
logs.reserve(4096);
for (const auto& device : devices()) {
const auto& log = prg.build_log(device);
if (!log.empty()) {
logs += log;
logs += '\n';
}
}
return logs;
}
void
clx::compiler::devices(const device_array& rhs) {
this->_devices = rhs;
}
void
clx::compiler::devices(device_array&& rhs) {
this->_devices = std::move(rhs);
}
std::string
clx::compiler::salt(const device& device) const {
std::string salt;
salt.reserve(4096);
const auto& platform = device.platform();
salt += platform.name();
salt += platform.vendor();
salt += platform.version();
salt += device.name();
salt += device.vendor();
salt += device.version();
salt += options();
return salt;
}
void
clx::compiler::unload() {
auto& devices = this->_devices;
for (const auto& device : devices) {
device.platform().unload_compiler();
}
}
::clx::kernel clx::compiler::kernel(
const std::string& filename,
const char* name
) {
return this->compile(filename).kernel(name);
}
| 28.378151 | 94 | 0.563222 | igankevich |
69ff14527edc3c3c9db50b30f4a3d0b1cb7228c9 | 3,334 | cpp | C++ | src/sensors/MS4525DO/MS4525DO.cpp | RiceCreekUAS/aura-sensors | ab56d1edf47871f094f03e05e9449f6c1ed88bcc | [
"MIT"
] | 1 | 2021-09-24T01:05:35.000Z | 2021-09-24T01:05:35.000Z | src/sensors/MS4525DO/MS4525DO.cpp | RiceCreekUAS/rc-fmu-arduino | ab56d1edf47871f094f03e05e9449f6c1ed88bcc | [
"MIT"
] | 1 | 2019-06-06T17:36:02.000Z | 2019-06-06T17:36:02.000Z | src/sensors/MS4525DO/MS4525DO.cpp | RiceCreekUAS/rc-fmu-arduino | ab56d1edf47871f094f03e05e9449f6c1ed88bcc | [
"MIT"
] | 2 | 2020-04-04T23:48:30.000Z | 2020-04-13T03:38:26.000Z | // MS4525DO.cpp
#include "Arduino.h"
#include "MS4525DO.h"
/* Default constructor */
MS4525DO::MS4525DO(){
_address = 0x28; // I2C address
_bus = NULL; // I2C bus
_ready = false;
}
/* MS4525DO object, input the I2C address and enumerated chip name (i.e. MS4525DO_1200_B) */
MS4525DO::MS4525DO(uint8_t address, TwoWire *bus){
_address = address; // I2C address
_bus = bus; // I2C bus
}
/* configure bus and i2c address */
void MS4525DO::configure(uint8_t address, TwoWire *bus){
_address = address; // I2C address
_bus = bus; // I2C bus
}
/* starts the I2C communication and sets the pressure and temperature ranges using getTransducer */
bool MS4525DO::begin(){
// starting the I2C bus
_bus->begin();
_bus->setClock(_i2cRate);
_bus->beginTransmission(_address);
int result = _bus->endTransmission();
delay(100);
if ( result > 0 ) {
Serial.print("MS4525DO init error: "); Serial.println(result);
return false;
} else {
_ready = true;
return true;
}
}
/* reads pressure and temperature and returns values in counts */
bool MS4525DO::getData(float* pressure, float* temperature) {
if ( ! _ready ) {
return false;
}
uint8_t b[4]; // buffer
const uint8_t numBytes = 4;
// 4 bytes from address
_bus->requestFrom(_address, numBytes);
// put the data in buffer
int counter = 0;
while ( _bus->available() && counter < numBytes ) {
b[counter] = _bus->read();
counter++;
}
// _bus->endTransmission();
if ( counter < numBytes ) {
// Serial.println("Error, fewer than expected bytes available on i2c read");
return false;
} else {
uint8_t status = (b[0] & 0xC0) >> 6;
b[0] = b[0] & 0x3f;
uint16_t dp_raw = (b[0] << 8) + b[1];
uint16_t T_dat = (b[2] << 8) + b[3];
T_dat = (0xFFE0 & T_dat) >> 5;
//b[3] = (b[3] >> 5);
//uint16_t T_dat = ((b[2]) << 8) | b[3];
// PR = (double)((P_dat-819.15)/(14744.7)) ;
// PR = (PR - 0.49060678) ;
// PR = abs(PR);
// V = ((PR*13789.5144)/1.225);
// VV = (sqrt((V)));
// Calculate differential pressure. As its centered around 8000
// and can go positive or negative
const float P_min = -1.0f;
const float P_max = 1.0f;
const float PSI_to_Pa = 6894.757f;
/*
this equation is an inversion of the equation in the
pressure transfer function figure on page 4 of the datasheet
We negate the result so that positive differential pressures
are generated when the bottom port is used as the static
port on the pitot and top port is used as the dynamic port
*/
float diff_press_PSI = -((dp_raw - 0.1f * 16383) * (P_max - P_min) / (0.8f * 16383) + P_min);
*pressure = diff_press_PSI * PSI_to_Pa; // pa
const float T_factor = 200.0 / 2047.0;
*temperature = (float)T_dat * T_factor - 50.0; // C
// #define DEBUG_ME
#if defined DEBUG_ME
Serial.print(status); Serial.print("\t");
Serial.print(dp_raw); Serial.print("\t");
Serial.print(*pressure,2); Serial.print("\t");
Serial.print(T_dat); Serial.print("\t");
Serial.print(*temperature,1); Serial.print("\t");
Serial.println();
#endif
}
return true;
}
| 29.767857 | 99 | 0.595981 | RiceCreekUAS |
0e02a28495bfdadba7ff2ee589b6d410b729d4af | 2,294 | hpp | C++ | src/include/XERenderer/GUI/RenderableLayer.hpp | devxkh/FrankE | 72faca02759b54aaec842831f3c7a051e7cf5335 | [
"MIT"
] | 11 | 2017-01-17T15:02:25.000Z | 2020-11-27T16:54:42.000Z | src/include/XERenderer/GUI/RenderableLayer.hpp | devxkh/FrankE | 72faca02759b54aaec842831f3c7a051e7cf5335 | [
"MIT"
] | 9 | 2016-10-23T20:15:38.000Z | 2018-02-06T11:23:17.000Z | src/include/XERenderer/GUI/RenderableLayer.hpp | devxkh/FrankE | 72faca02759b54aaec842831f3c7a051e7cf5335 | [
"MIT"
] | 2 | 2019-08-29T10:23:51.000Z | 2020-04-03T06:08:34.000Z | #ifndef _RENDERABLELAYER_HPP
#define _RENDERABLELAYER_HPP
#include <XESystem/SystemConfig.hpp>
#include <XERenderer/private/ScreenRenderable.hpp>
//#include <Ogre/OgreMain/include/OgreManualObject2.h>
#include <Ogre/OgreMain/include/OgreMovableObject.h>
#include <Ogre/OgreMain/include/OgreRenderable.h>
//Ogre::v1
#include <Ogre/OgreMain/include/OgreRenderOperation.h>
#include <vector>
#include <memory>
namespace Ogre {
class VertexBufferPacked;
class ObjectMemoryManager;
class SceneManager;
typedef std::string String;
}
namespace XE {
struct Vertex;
class CameraRenderable;
class GUIRenderer;
class RenderableShape;
class RenderableLayer : public Ogre::MovableObject, public ScreenRenderable//public Ogre::ManualObject
{
public:
RenderableLayer(Uint32 id, GUIRenderer& guiRenderer,
Ogre::ObjectMemoryManager* objManager, Ogre::SceneManager* sceneMgr, const Uint16 atlasId = 0);
~RenderableLayer();
// MovableObject overrides
/** @copydoc MovableObject::getMovableType. */
const Ogre::String& getMovableType(void) const;
void updateVertices(std::queue<Vertex>& vertices);
// Renderable overrides
/** @copydoc Renderable::getRenderOperation. */
virtual void getRenderOperation(Ogre::v1::RenderOperation& op, bool casterPass) OGRE_OVERRIDE;
/** @copydoc Renderable::getWorldTransforms. */
virtual void getWorldTransforms(Ogre::Matrix4* xform) const OGRE_OVERRIDE {}
/** @copydoc Renderable::getLights. */
virtual const Ogre::LightList &getLights(void) const OGRE_OVERRIDE { return queryLights(); }
/** @copydoc Renderable::getCastsShadows. */
virtual bool getCastsShadows(void) const { return false; }
protected:
//called from Ogre::Renderable
Ogre::OperationType mOperationType;
private:
void clear();
bool _initalizied;
Ogre::SceneManager* _t_OgreSceneMgrPtr;
Ogre::ObjectMemoryManager* _t_objectMemoryManager;
Ogre::VertexArrayObject * m_Vao;
Ogre::VaoManager * m_VaoManager;
Ogre::VertexElement2Vec m_VertexElements;
Ogre::VertexBufferPacked *m_vertexBuffer;
Ogre::IndexBufferPacked* m_indexBuffer;
GUIRenderer& m_guiRenderer;
Uint32 m_currentVertexBufferSize;
Uint32 m_currentIndexBufferSize;
Ogre::SceneManager* m_sceneMgr;
Ogre::SceneNode* m_sceneNodeLines;
};
}
#endif | 26.068182 | 103 | 0.767655 | devxkh |
0e058e34350ce6e5f8d9c6c68ffce88ec81eea64 | 1,895 | cc | C++ | tensorflow/core/grappler/optimizers/debug_stripper.cc | zhangyujing/tensorflow | c7a04561fb8972fb64907acc5f10f3c6d4cef9f2 | [
"Apache-2.0"
] | 3 | 2019-04-15T13:59:41.000Z | 2020-04-25T21:09:33.000Z | tensorflow/core/grappler/optimizers/debug_stripper.cc | zhangyujing/tensorflow | c7a04561fb8972fb64907acc5f10f3c6d4cef9f2 | [
"Apache-2.0"
] | 1 | 2018-02-23T03:17:44.000Z | 2018-02-23T03:17:44.000Z | tensorflow/core/grappler/optimizers/debug_stripper.cc | zhangyujing/tensorflow | c7a04561fb8972fb64907acc5f10f3c6d4cef9f2 | [
"Apache-2.0"
] | 1 | 2019-06-24T17:57:20.000Z | 2019-06-24T17:57:20.000Z | /* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include "tensorflow/core/grappler/optimizers/debug_stripper.h"
#include "tensorflow/core/framework/node_def.pb.h"
#include "tensorflow/core/grappler/clusters/cluster.h"
#include "tensorflow/core/grappler/grappler_item.h"
#include "tensorflow/core/grappler/op_types.h"
#include "tensorflow/core/grappler/utils.h"
namespace tensorflow {
namespace grappler {
Status DebugStripper::Optimize(Cluster* cluster, const GrapplerItem& item,
GraphDef* output) {
*output = item.graph;
for (NodeDef& node : *output->mutable_node()) {
if (IsAssert(node)) {
// Convert this node into a no-op.
node.set_op("NoOp");
node.clear_attr();
// Convert all its inputs into control dependency, which will then
// be optimized away by dependency optimizer.
for (string& inp : *node.mutable_input()) {
if (!IsControlInput(inp)) {
inp = AsControlDependency(inp);
}
}
}
}
return Status::OK();
}
void DebugStripper::Feedback(Cluster* cluster, const GrapplerItem& item,
const GraphDef& optimize_output, double result) {
// Takes no feedback.
}
} // end namespace grappler
} // end namespace tensorflow
| 35.092593 | 80 | 0.675462 | zhangyujing |
0e09defd5a7a97fbdf0c16a9885a917a8e983002 | 25,555 | cpp | C++ | code/gpucache_saver.cpp | Neill3d/MoPlugs_Framework | c6d212604256f9274737f877fb2c20b75143cf16 | [
"BSD-3-Clause"
] | 3 | 2018-03-11T22:44:14.000Z | 2021-12-09T11:38:48.000Z | code/gpucache_saver.cpp | Neill3d/MoPlugs_Framework | c6d212604256f9274737f877fb2c20b75143cf16 | [
"BSD-3-Clause"
] | null | null | null | code/gpucache_saver.cpp | Neill3d/MoPlugs_Framework | c6d212604256f9274737f877fb2c20b75143cf16 | [
"BSD-3-Clause"
] | null | null | null |
//////////////////////////////////////////////////////////////////////////////////////////////////
//
// file: gpucache_saver.cpp
//
// Author Sergey Solokhin (Neill3d)
//
//
// GitHub page - https://github.com/Neill3d/MoPlugs_Framework
// Licensed under BSD 3-Clause - https://github.com/Neill3d/MoPlugs_Framework/blob/master/LICENSE
//
///////////////////////////////////////////////////////////////////////////////////////////////////
#include "gpucache_saver.h"
#include <io.h>
#include <fcntl.h>
#include <sys\types.h>
#include <sys\stat.h>
#include "nv_dds\nv_dds.h"
///////////////////////////////////////////////////////////////////////////////////////////////////////
// CGPUCacheSaver
CGPUCacheSaver::CGPUCacheSaver()
{
mQuery = nullptr;
}
bool CGPUCacheSaver::Save(const char *filename, CGPUCacheSaverQuery *pQuery )
//bool WriteObjectsToXML(const char *fileName, const char *modelFileName, const char *texturesFileName, FBModelList &pList)
{
mQuery = pQuery;
if (mQuery == nullptr || mQuery->Init(filename) == false)
{
return false;
}
//
TiXmlDocument doc;
TiXmlElement head("Header");
head.SetAttribute( "models", mQuery->GetModelsCount() );
head.SetAttribute( "version", mQuery->GetVersion() );
head.SetAttribute( "filename", mQuery->GetSourceFilename() );
//
TiXmlElement models("Models");
int numberOfModels = mQuery->GetModelsCount();
models.SetAttribute( "count", numberOfModels );
for (int i=0; i<numberOfModels; ++i)
{
WriteModelToXML( i, &models );
}
models.SetAttribute( "submeshes", mQuery->GetSubMeshesCount() );
// store bb of the models
vec4 vmin, vmax;
mQuery->GetBoundingBox(vmin, vmax);
TiXmlElement bbItem( "BoundingBox" );
bbItem.SetDoubleAttribute( "minx", vmin[0] );
bbItem.SetDoubleAttribute( "miny", vmin[1] );
bbItem.SetDoubleAttribute( "minz", vmin[2] );
bbItem.SetDoubleAttribute( "maxx", vmax[0] );
bbItem.SetDoubleAttribute( "maxy", vmax[1] );
bbItem.SetDoubleAttribute( "maxz", vmax[2] );
models.InsertEndChild( bbItem );
unsigned int verticesCount, indicesCount;
mQuery->GetTotalCounts(verticesCount, indicesCount);
models.SetAttribute( "totalVertices", verticesCount );
models.SetAttribute( "totalIndices", indicesCount );
//
// MATERIALS
TiXmlElement materials("Materials");
WriteMaterialsToXML( &materials );
//
// TEXTURES
TiXmlElement textures("Textures");
WriteTexturesToXML( &textures );
//
// SHADERS
TiXmlElement shaders("Shaders");
WriteShadersToXML( &shaders );
//
// LIGHTS
TiXmlElement lights("Lights");
WriteLightsToXML( &lights );
head.SetAttribute( "materials", mQuery->GetMaterialsCount() );
head.SetAttribute( "textures", mQuery->GetSamplersCount() );
head.SetAttribute( "media", mQuery->GetVideoCount() );
head.SetAttribute( "shaders", mQuery->GetShadersCount() );
head.SetAttribute( "lights", mQuery->GetLightsCount() );
doc.InsertEndChild(head);
doc.InsertEndChild(models);
doc.InsertEndChild(materials);
doc.InsertEndChild(textures);
doc.InsertEndChild(shaders);
doc.InsertEndChild(lights);
doc.SaveFile( filename );
if (doc.Error() )
{
printf( doc.ErrorDesc() );
return false;
}
// store geometry and texture resources
std::string geometry_filename( filename );
auto iter = geometry_filename.find_last_of( "." );
geometry_filename.erase( iter );
geometry_filename.append( "_Geometry.pck" );
FILE *modelFile = nullptr;
int err = fopen_s( &modelFile, geometry_filename.c_str(), "wb" );
try
{
if (err != 0)
throw "Failed to open geometry file for writing";
FileGeometryHeader geomHeader;
FileGeometryHeader::Set( 1, numberOfModels, verticesCount, indicesCount, geomHeader );
fwrite( &geomHeader, sizeof(FileGeometryHeader), 1, modelFile );
for (int i=0; i<numberOfModels; ++i)
{
if (false == WriteModelGeometry( modelFile, i ) )
throw "Failed to save geometry model to cache";
}
}
catch (const char *error)
{
printf( "Cache Error - %s\n", error );
}
if (modelFile) fclose(modelFile);
//
//
std::string textures_filename( filename );
auto iter2 = textures_filename.find_last_of( "." );
textures_filename.erase( iter2 );
textures_filename.append( "_Textures.pck" );
return SaveTextures( textures_filename.c_str(), mQuery );
}
bool CGPUCacheSaver::SaveTextures(const char *filename, CGPUCacheSaverQuery *pQuery)
{
//
// store samplers/image data
BYTE *localImageBuffer = new BYTE[16384 * 16384 * 4];
int fh=0;
printf ("try to open a file\n" );
//
errno_t err = _sopen_s( &fh, filename, _O_BINARY | _O_CREAT | _O_WRONLY | _O_TRUNC, _SH_DENYRW, _S_IREAD | _S_IWRITE);
try
{
printf ("%d %d\n", err, fh );
if ( err != 0)
throw std::exception("Failed to open textures file for writing\n");
_lseeki64( fh, 0, 0 );
const int numberOfMedias = pQuery->GetVideoCount();
const int numberOfSamplers = pQuery->GetSamplersCount();
// !!!
// added version 2 format - support image sequences
FileTexturesHeader texHeader;
FileTexturesHeader::Set( 2, numberOfMedias, numberOfSamplers, texHeader );
texHeader.imagesOffset = 0;
texHeader.samplersOffset = 0;
int bytteswritten = _write( fh, &texHeader, sizeof(texHeader) );
if (bytteswritten != sizeof(texHeader))
throw std::exception("Failed to save texture file header");
// STORE image data first of all
//
texHeader.imagesOffset = _telli64(fh);
for (int i=0; i<numberOfMedias; ++i)
{
const char *szVideoName = pQuery->GetVideoName(i);
printf( "save video data %d - %s\n", i, szVideoName );
const char *szFilename = pQuery->GetVideoFilename(i);
if (szFilename && strstr( (char*)filename, ".dds" ) != nullptr )
{
if (false == SaveDDSData( fh, filename ) )
throw std::exception("Failed to save DDS data - ");
}
else if (nullptr != szFilename)
{
if (false == SaveImageSimple( fh, i ) )
throw std::exception("Failed to save simple image data - ");
}
else
{
// write empty texture
if (false == SaveImageEmpty( fh ) )
throw std::exception("Failed to save empty image data - ");
}
}
/*
if (canDoCompression == false)
{
FBMessageBox( "Caching export", "Textures were saved without compression, not enough memory!", "Ok" );
}
*/
// STORE Samplers
//
texHeader.samplersOffset = _telli64(fh);
for (int i=0; i<numberOfSamplers; ++i)
{
const int videoId = pQuery->GetSamplerVideoIndex(i);
if (false == SaveSampler( fh, i, videoId ) )
throw std::exception("Failed to save sampler for texture\n");
}
// rewrite header with offsets
_lseeki64(fh, 0, 0);
bytteswritten = _write( fh, &texHeader, sizeof(FileTexturesHeader) );
if (bytteswritten != sizeof(FileTexturesHeader) )
throw std::exception("Failed to write textures file header\n");
printf ( "images offset - %u, samplers offset - %u\n", texHeader.imagesOffset, texHeader.samplersOffset );
}
catch (std::exception &e)
{
printf( "Cache Error during save operation - %s", e.what() );
}
if (fh > 0) _close(fh);
if (localImageBuffer)
{
delete [] localImageBuffer;
localImageBuffer = nullptr;
}
return true;
}
bool CGPUCacheSaver::WriteLightsToXML( TiXmlElement *parentElem )
{
if (parentElem == nullptr)
return false;
int numberOfLights = mQuery->GetLightsCount();
parentElem->SetAttribute( "count", numberOfLights );
for (int i=0; i<numberOfLights; ++i)
{
TiXmlElement ligItem("Light");
ligItem.SetAttribute( "name", mQuery->GetLightName(i) );
parentElem->InsertEndChild( ligItem );
}
return true;
}
bool CGPUCacheSaver::SaveDDSData( int fh, const char *filename )
{
nv_dds::CDDSImage image;
if (false == image.load( filename ) )
return false;
const short width = (short) image.get_width();
const short height = (short) image.get_height();
const GLint internalFormat = image.get_format();
const GLint format = (image.get_components() == 4) ? GL_RGBA : GL_RGB;
const GLint imageSize = (GLint) image.get_size();
const unsigned char numberOfLods = (unsigned char) image.get_num_mipmaps();
// store header
ImageHeader2 header;
ImageHeader2::Set( width, height, internalFormat, format, imageSize, 0, numberOfLods, header);
long long pos = _telli64(fh);
printf( "current file position - %u\n", pos );
printf( "writing dds - %d, %d, size %d\n", width, height, imageSize );
int byttesWritten = 0;
try
{
byttesWritten = _write(fh, &header, sizeof(header) );
if (byttesWritten != sizeof(header))
throw std::exception( "error while writing a texture header!\n" );
const unsigned char *imageData = image;
// store texture
if (imageSize > 0 && imageData != nullptr)
{
byttesWritten = _write( fh, imageData, sizeof(BYTE) * imageSize );
if (byttesWritten != imageSize * sizeof(BYTE))
throw std::exception( "error while writing a texture data\n" );
}
// store lods
for (int i=0; i<numberOfLods; ++i)
{
nv_dds::CSurface mipmap = image.get_mipmap(i);
// get lod and save it
ImageLODHeader2 lodHeader;
ImageLODHeader2::Set( mipmap.get_width(), mipmap.get_height(), mipmap.get_size(), lodHeader );
byttesWritten = _write( fh, &lodHeader, sizeof(lodHeader) );
if (byttesWritten != sizeof(lodHeader) )
throw std::exception( "error while writing a mipmap header!\n" );
//
const unsigned char *mipmapData = mipmap;
byttesWritten = _write( fh, mipmapData, mipmap.get_size() );
if (byttesWritten != (int) mipmap.get_size() )
throw std::exception( "error while writing a mipmap data\n" );
}
}
catch (std::exception &e)
{
printf( "%s\n", e.what() );
return false;
}
return true;
}
bool CGPUCacheSaver::SaveSampler( int fh, const int index, const int videoIndex )
{
mat4 mf;
mQuery->GetSamplerMatrix(index, mf);
SamplerHeader header;
SamplerHeader::Set( mf.mat_array, videoIndex, GL_REPEAT, GL_REPEAT, GL_REPEAT, GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, header );
int byttesWritten = _write( fh, &header, sizeof(SamplerHeader) );
if (byttesWritten != sizeof(SamplerHeader) )
{
printf( "error while writing sampler header\n" );
return false;
}
return true;
}
bool CGPUCacheSaver::WriteTexturesToXML( TiXmlElement *parentItem )
{
int numberOfSamplers = mQuery->GetSamplersCount();
parentItem->SetAttribute( "count", numberOfSamplers );
//
GLint internalFormat, format;
double totalUncompressedSize = 0.0;
for (int i=0; i<numberOfSamplers; ++i)
{
TiXmlElement texItem("Texture");
texItem.SetAttribute( "name", mQuery->GetSamplerName(i) );
const int videoId = mQuery->GetSamplerVideoIndex(i);
if (videoId >= 0)
{
texItem.SetAttribute( "width", mQuery->GetVideoWidth(videoId) );
texItem.SetAttribute( "height", mQuery->GetVideoHeight(videoId) );
texItem.SetAttribute( "filename", mQuery->GetVideoFilename(videoId) );
texItem.SetAttribute( "format", mQuery->GetVideoFormat(videoId, internalFormat, format) );
texItem.SetAttribute( "startFrame", mQuery->GetVideoStartFrame(videoId) );
texItem.SetAttribute( "stopFrame", mQuery->GetVideoStopFrame(videoId) );
texItem.SetAttribute( "frameRate", mQuery->GetVideoFrameRate(videoId) );
texItem.SetAttribute( "imageSequence", (mQuery->IsVideoImageSequence(videoId)) ? 1 : 0 );
}
parentItem->InsertEndChild( texItem );
}
parentItem->SetAttribute( "UncompressedSize", mQuery->GetTotalUncompressedSize() );
return true;
}
bool CGPUCacheSaver::SaveImageEmpty( int fh )
{
//
auto fn_writeSafe = [] (const int fh, void *data, const int size) {
if (size != _write(fh, data, size ) )
throw std::exception( "error while writing data!\n" );
};
int numberOfFrames = 0;
int imageSize=0;
ImageHeader2 header;
ImageSequenceHeader2 seqHeader;
__int64 pos = _telli64(fh);
printf( "current file position - %u\n", pos );
printf( "writing image - size %d\n", imageSize );
BYTE imageType = IMAGE_TYPE_STILL;
try
{
imageType = IMAGE_TYPE_STILL;
GLubyte *imageData = nullptr;
fn_writeSafe( fh, &imageType, sizeof(BYTE) );
if (imageData == nullptr)
{
header.width = 0;
header.height = 0;
header.size = 0;
header.numberOfLODs = 0;
}
fn_writeSafe( fh, &header, sizeof(header) );
// OpenGL texture limitation
if (imageData != nullptr)
fn_writeSafe( fh, imageData, sizeof(BYTE) * header.size );
}
catch (std::exception &e)
{
printf( "%s\n", e.what() );
return false;
}
return true;
}
bool CGPUCacheSaver::SaveImageSimple( int fh, const int index )
{
//
auto fn_writeSafe = [] (const int fh, const void *data, const int size) {
if (size != _write(fh, data, size ) )
throw std::exception( "error while writing data!\n" );
};
int numberOfFrames = 0;
int imageSize=mQuery->GetVideoSize(index);
ImageHeader2 header;
ImageSequenceHeader2 seqHeader;
__int64 pos = _telli64(fh);
printf( "current file position - %u\n", pos );
printf( "writing image - size %d\n", imageSize );
BYTE imageType = IMAGE_TYPE_STILL;
try
{
imageType = IMAGE_TYPE_STILL;
const GLubyte *imageData = mQuery->GetVideoData(index);
fn_writeSafe( fh, &imageType, sizeof(BYTE) );
if (imageData == nullptr)
{
header.width = 0;
header.height = 0;
header.size = 0;
header.numberOfLODs = 0;
}
else
{
GLint internalFormat, format;
mQuery->GetVideoFormat( index, internalFormat, format );
ImageHeader2::Set(mQuery->GetVideoWidth(index), mQuery->GetVideoHeight(index),
internalFormat, format, mQuery->GetVideoSize(index), 0, 1, header );
}
fn_writeSafe( fh, &header, sizeof(header) );
// OpenGL texture limitation
if (imageData != nullptr)
fn_writeSafe( fh, imageData, sizeof(BYTE) * header.size );
}
catch (std::exception &e)
{
printf( "%s\n", e.what() );
return false;
}
return true;
}
bool CGPUCacheSaver::WriteModelToXML( const int modelIndex, TiXmlElement *models )
{
TiXmlElement modelItem("Model");
modelItem.SetAttribute( "name", mQuery->GetModelName(modelIndex) );
modelItem.SetAttribute( "visible", mQuery->GetModelVisible(modelIndex) );
modelItem.SetAttribute( "castShadow", mQuery->GetModelCastsShadows(modelIndex) );
modelItem.SetAttribute( "receiveShadow", mQuery->GetModelReceiveShadows(modelIndex) );
vec4 t, r, s, vmin, vmax;
mQuery->GetModelTranslation(modelIndex, t);
mQuery->GetModelRotation(modelIndex, r);
mQuery->GetModelScaling(modelIndex, s);
// ?! this is not for model, this one returns a global one
mQuery->GetModelBoundingBox(modelIndex, vmin, vmax);
TiXmlElement tItem( "Translation" );
tItem.SetDoubleAttribute( "x", t[0] );
tItem.SetDoubleAttribute( "y", t[1] );
tItem.SetDoubleAttribute( "z", t[2] );
TiXmlElement rItem( "Rotation" );
rItem.SetDoubleAttribute( "x", r[0] );
rItem.SetDoubleAttribute( "y", r[1] );
rItem.SetDoubleAttribute( "z", r[2] );
TiXmlElement sItem( "Scaling" );
sItem.SetDoubleAttribute( "x", s[0] );
sItem.SetDoubleAttribute( "y", s[1] );
sItem.SetDoubleAttribute( "z", s[2] );
modelItem.InsertEndChild( tItem );
modelItem.InsertEndChild( rItem );
modelItem.InsertEndChild( sItem );
TiXmlElement bbItem( "BoundingBox" );
bbItem.SetDoubleAttribute( "minx", vmin[0] );
bbItem.SetDoubleAttribute( "miny", vmin[1] );
bbItem.SetDoubleAttribute( "minz", vmin[2] );
bbItem.SetDoubleAttribute( "maxx", vmax[0] );
bbItem.SetDoubleAttribute( "maxy", vmax[1] );
bbItem.SetDoubleAttribute( "maxz", vmax[2] );
modelItem.InsertEndChild( bbItem );
// store sub-patches
TiXmlElement patches( "Patches" );
const int subpatchcount = mQuery->GetModelSubPatchCount(modelIndex);
for (int j=0; j<subpatchcount; ++j)
{
int offset, size, materialId;
mQuery->GetModelSubPatchInfo(modelIndex, j, offset, size, materialId);
TiXmlElement patchItem( "Patch" );
patchItem.SetAttribute( "offset", offset );
patchItem.SetAttribute( "size", size );
patchItem.SetAttribute( "material", (materialId >= 0) ? mQuery->GetMaterialName(materialId) : "None" );
patchItem.SetAttribute( "materialId", materialId );
patches.InsertEndChild( patchItem );
}
modelItem.SetAttribute( "vertices", mQuery->GetModelVertexCount(modelIndex) );
modelItem.InsertEndChild( patches );
// store shaders
TiXmlElement shaders( "Shaders" );
const int numberOfShaders = mQuery->GetModelShadersCount(modelIndex);
for (int j=0; j<numberOfShaders; ++j)
{
const int shaderId = mQuery->GetModelShaderId(modelIndex, j);
TiXmlElement shaderItem( "Shader" );
shaderItem.SetAttribute( "name", mQuery->GetShaderName(shaderId) );
shaderItem.SetAttribute( "shaderId", shaderId );
shaders.InsertEndChild(shaderItem);
}
modelItem.InsertEndChild( shaders );
models->InsertEndChild( modelItem );
return true;
}
bool CGPUCacheSaver::WriteModelGeometry( FILE *modelFile, const int index )
{
//bool CGPUVertexData::SaveModel( FILE *fp, FBModelVertexData *pVertexData, FBMatrix *tm )
const bool afterDeform = true;
const int numberOfVertices = mQuery->GetModelVertexCount(index); // pVertexData->GetVertexCount();
mQuery->ModelVertexArrayRequest(index);
const float *pVertices = mQuery->GetModelVertexArrayPoint( afterDeform );
const float *pNormals = mQuery->GetModelVertexArrayNormal( afterDeform );
const float *pTangents = mQuery->GetModelVertexArrayTangent( afterDeform );
const float *pUVs = mQuery->GetModelVertexArrayUV( 0, afterDeform );
const int *indices = mQuery->GetModelIndexArray();
mQuery->ModelVertexArrayRelease();
int pointStride = (pVertices) ? mQuery->GetModelVertexArrayPointStride(index) : 0;
int normalStride = (pNormals) ? mQuery->GetModelVertexArrayNormalStride(index) : 0;
int tangentStride = (pTangents) ? mQuery->GetModelVertexArrayTangentStride(index) : 0;
int uvStride = (pUVs) ? mQuery->GetModelVertexArrayUVStride(index) : 0;
//const int indexStride = (indices) ? sizeof(unsigned int) : 0;
int numberOfIndices = 0;
for (int i=0; i<mQuery->GetModelSubPatchCount(index); ++i)
{
int offset, size, matId;
mQuery->GetModelSubPatchInfo( index, i, offset, size, matId );
#ifndef max
#define max(a,b) (a>b)?a:b
#endif
numberOfIndices = max( numberOfIndices, offset+size );
}
// we have strong specified strides for arrays
if (pointStride != gPointStride) pointStride = 0;
if (normalStride != gNormalStride) normalStride = 0;
if (tangentStride != gTangentStride) tangentStride = 0;
if (uvStride != gUVStride) uvStride = 0;
// store header
VertexDataHeader header;
VertexDataHeader::Set( numberOfVertices, numberOfIndices, pointStride, normalStride, tangentStride, uvStride, header );
size_t elementsWritten = 0;
try
{
long long pos = _ftelli64(modelFile);
elementsWritten = fwrite( &header, sizeof(header), 1, modelFile );
if (elementsWritten != 1)
throw std::exception( "ERROR: failed to write model header!\n" );
float *pNewArray = (float*) pVertices;
/*
if (tm)
{
pNewArray = new FBVertex[numberOfVertices];
for (int i=0; i<numberOfVertices; ++i)
{
FBVertexMatrixMult( pNewArray[i], *tm, FBVertex(pVertices[i][0], pVertices[i][1], pVertices[i][2], 1.0) );
pNewArray[i][3] = 1.0;
}
}
*/
//
// store data into the file storage
header.positionOffset = _ftelli64(modelFile);
elementsWritten = fwrite( (pNewArray) ? pNewArray : pVertices, pointStride, numberOfVertices, modelFile );
//SAFE_ARRAY_DELETE(pNewArray);
if (elementsWritten != numberOfVertices)
throw std::exception( "ERROR: failed to write vertices!\n" );
header.normalOffset = _ftelli64(modelFile);
elementsWritten = fwrite( pNormals, normalStride, numberOfVertices, modelFile );
if (elementsWritten != numberOfVertices)
throw std::exception( "ERROR: failed to write vertices!\n" );
header.tangentOffset = _ftelli64(modelFile);
elementsWritten = fwrite( pTangents, tangentStride, numberOfVertices, modelFile );
if (elementsWritten != numberOfVertices)
throw std::exception( "ERROR: failed to write vertices!\n" );
header.uvOffset = _ftelli64(modelFile);
elementsWritten = fwrite( pUVs, uvStride, numberOfVertices, modelFile );
if (elementsWritten != numberOfVertices)
throw std::exception( "ERROR: failed to write vertices!\n" );
unsigned int *newIndices = new unsigned int[numberOfIndices];
if (newIndices == nullptr)
throw std::exception( "Failed to allocate memoryfor indices\n" );
for (int i=0; i<numberOfIndices; ++i)
newIndices[i] = (unsigned int) indices[i];
header.indicesOffset = _ftelli64(modelFile);
elementsWritten = fwrite( newIndices, sizeof(unsigned int), numberOfIndices, modelFile );
if(newIndices)
{
delete [] newIndices;
newIndices = nullptr;
}
if (elementsWritten != numberOfIndices)
throw std::exception( "ERROR: failed to write indices!\n" );
// now store header with offsets
header.endOffset = _ftelli64(modelFile);
_fseeki64(modelFile, pos, 0);
elementsWritten = fwrite( &header, sizeof(header), 1, modelFile );
if (elementsWritten != 1)
throw std::exception( "ERROR: failed to write model header!\n" );
_fseeki64(modelFile, header.endOffset, 0);
}
catch (const std::exception &e)
{
printf( "%s\n", e.what() );
return false;
}
return true;
}
bool CGPUCacheSaver::WriteShadersToXML( TiXmlElement *parentElem )
{
const int count = mQuery->GetShadersCount();
parentElem->SetAttribute( "count", count );
for (int i=0; i<count; ++i)
{
TiXmlElement shdItem("Shader");
WriteOneShaderToXML( &shdItem, i );
parentElem->InsertEndChild( shdItem );
}
return true;
}
bool CGPUCacheSaver::WriteOneShaderToXML( TiXmlElement *shdItem, const int index )
{
shdItem->SetAttribute( "name", mQuery->GetShaderName(index) );
ShaderGLSL data;
mQuery->ConvertShader(index, data);
// transparency mode
int alphaSource = mQuery->GetShaderAlphaSource(index);
shdItem->SetAttribute( "alpha", alphaSource );
shdItem->SetDoubleAttribute( "transparency", (double) data.transparency );
shdItem->SetAttribute( "type", data.shaderType );
// additional properties
switch(data.shaderType)
{
case eShaderTypeSuperLighting:
{
TiXmlElement colorCorrItem("ColorCorrection");
TiXmlElement customColorItem("CustomColor");
customColorItem.SetDoubleAttribute( "r", data.customColor.x );
customColorItem.SetDoubleAttribute( "g", data.customColor.y );
customColorItem.SetDoubleAttribute( "b", data.customColor.z );
colorCorrItem.InsertEndChild( customColorItem );
colorCorrItem.SetAttribute( "blendType", (int) data.customColor.w );
colorCorrItem.SetDoubleAttribute( "contrast", (double) data.contrast );
colorCorrItem.SetDoubleAttribute( "saturation", (double) data.saturation );
colorCorrItem.SetDoubleAttribute( "brightness", (double) data.brightness );
colorCorrItem.SetDoubleAttribute( "gamma", (double) data.gamma );
shdItem->InsertEndChild( colorCorrItem );
// Toon settings
TiXmlElement shadingItem( "Shading" );
shadingItem.SetAttribute( "type", (int) data.shadingType );
shadingItem.SetAttribute( "toonEnabled", 0 );
shadingItem.SetDoubleAttribute( "toonSteps", data.toonSteps );
shadingItem.SetDoubleAttribute( "toonDistribution", data.toonDistribution );
shadingItem.SetDoubleAttribute( "toonShadowPosition", data.toonShadowPosition );
shdItem->InsertEndChild( shadingItem );
} break;
case eShaderTypeColorCorrection:
{
TiXmlElement colorCorrItem("ColorCorrection");
TiXmlElement customColorItem("CustomColor");
customColorItem.SetDoubleAttribute( "r", data.customColor.x );
customColorItem.SetDoubleAttribute( "g", data.customColor.y );
customColorItem.SetDoubleAttribute( "b", data.customColor.z );
colorCorrItem.InsertEndChild( customColorItem );
colorCorrItem.SetAttribute( "blendType", (int) data.customColor.w );
colorCorrItem.SetDoubleAttribute( "contrast", (double) data.contrast );
colorCorrItem.SetDoubleAttribute( "saturation", (double) data.saturation );
colorCorrItem.SetDoubleAttribute( "brightness", (double) data.brightness );
colorCorrItem.SetDoubleAttribute( "gamma", (double) data.gamma );
shdItem->InsertEndChild( colorCorrItem );
} break;
case eShaderTypeShading:
{
// Toon settings
TiXmlElement shadingItem( "Shading" );
shadingItem.SetAttribute( "type", (int) data.shadingType );
shadingItem.SetAttribute( "toonEnabled", 0 );
shadingItem.SetDoubleAttribute( "toonSteps", data.toonSteps );
shadingItem.SetDoubleAttribute( "toonDistribution", data.toonDistribution );
shadingItem.SetDoubleAttribute( "toonShadowPosition", data.toonShadowPosition );
shdItem->InsertEndChild( shadingItem );
} break;
}
return true;
}
bool CGPUCacheSaver::WriteMaterialsToXML( TiXmlElement *parentElem )
{
const int numberOfMaterials = mQuery->GetMaterialsCount();
parentElem->SetAttribute( "count", numberOfMaterials );
for ( int i=0; i<numberOfMaterials; ++i )
{
MaterialGLSL data;
mQuery->ConvertMaterial(i, data);
TiXmlElement matItem("Material");
matItem.SetAttribute( "name", mQuery->GetMaterialName(i) );
TiXmlElement difItem("Diffuse");
difItem.SetDoubleAttribute( "r", (double) data.diffuseColor.x );
difItem.SetDoubleAttribute( "g", (double) data.diffuseColor.y );
difItem.SetDoubleAttribute( "b", (double) data.diffuseColor.z );
difItem.SetDoubleAttribute( "factor", (double) data.diffuseColor.w );
difItem.SetAttribute( "map", (data.diffuse>=0) ? mQuery->GetSamplerName(data.diffuse) : "None" );
difItem.SetAttribute( "mapId", data.diffuse );
matItem.InsertEndChild(difItem);
parentElem->InsertEndChild( matItem );
}
return true;
} | 28.237569 | 125 | 0.698689 | Neill3d |
0e0a55ae47d3eca06c6b80dcdddee6ebea0ffd63 | 21,073 | cc | C++ | ns-allinone-2.35/ns-2.35/mdart/mdart_ndp.cc | nitishk017/ns2project | f037b796ff10300ffe0422580be5855c37d0b140 | [
"MIT"
] | 1 | 2018-03-05T15:23:27.000Z | 2018-03-05T15:23:27.000Z | ns-allinone-2.35/ns-2.35/mdart/mdart_ndp.cc | nitishk017/ns2project | f037b796ff10300ffe0422580be5855c37d0b140 | [
"MIT"
] | 1 | 2019-01-20T17:35:23.000Z | 2019-01-22T21:41:38.000Z | ns-allinone-2.35/ns-2.35/mdart/mdart_ndp.cc | nitishk017/ns2project | f037b796ff10300ffe0422580be5855c37d0b140 | [
"MIT"
] | 1 | 2021-09-29T16:06:57.000Z | 2021-09-29T16:06:57.000Z | /*******************************************************************************
* *
* M-DART Routing Protocol *
* *
* Copyright (C) 2006 by Marcello Caleffi *
* marcello.caleffi@unina.it *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions are met: *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* 3. The name of the author may not be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* This software is provided by the author ``as is'' and any express or *
* implied warranties, including, but not limited to, the implied warranties *
* of merchantability and fitness for a particular purpose are disclaimed. *
* in no event shall the author be liable for any direct, indirect, *
* incidental, special, exemplary, or consequential damages (including, but *
* not limited to, procurement of substitute goods or services; loss of use, *
* data, or profits; or business interruption) however caused and on any *
* theory of liability, whether in contract, strict liability, or tort *
* (including negligence or otherwise) arising in any way out of the use of *
* this software, even if advised of the possibility of such damage. *
* *
* The M-DART code has been developed by Marcello Caleffi during his Ph.D. at *
* the Department of Biomedical, Electronic and Telecommunications Engineering *
* University of Naples Federico II, Italy. *
* *
* In order to give credit and recognition to the author, if you use M-DART *
* results or results obtained by modificating the M-DART source code, please *
* cite one of the following papers: *
* - M. Caleffi, L. Paura, "M-DART: Multi-Path Dynamic Address RouTing", *
* Wireless Communications and Mobile Computing, 2010 *
* - M. Caleffi, G. Ferraiuolo, L. Paura, "Augmented Tree-based Routing *
* Protocol for Scalable Ad Hoc Networks", Proc. of IEEE MASS '07: IEEE *
* Internatonal Conference on Mobile Adhoc and Sensor Systems, Pisa (Italy), *
* October 8-11 2007. *
* *
******************************************************************************/
#include <mdart/mdart_ndp.h>
#include <mdart/mdart.h>
//------------------------------------------------------------------------------
// Neigbor Discovery Protocol (NDP)
//------------------------------------------------------------------------------
NDP::NDP(MDART* mdart) {
mdart_ = mdart;
neighborSet_ = new neighborSet;
helloTimer_ = new NDPHelloTimer(this);
neighborTimer_ = new NDPNeighborTimer(this);
helloSeqNum_ = 0;
}
NDP::~NDP() {
delete helloTimer_;
delete neighborTimer_;
delete neighborSet_;
}
/*******************************************************************************
* NDP message functions
******************************************************************************/
void NDP::sendHello() {
#ifdef DEBUG_NDP
fprintf(stdout, "%.9f\tNDP::sendHello()\t\t\tin node %d\twith address %s\n", CURRENT_TIME, mdart_->id_, bitString(mdart_->address_));
#endif
Packet *sendPkt_ = Packet::alloc();
struct hdr_cmn *sendPktCh_ = HDR_CMN(sendPkt_);
struct hdr_ip *sendPktIh_ = HDR_IP(sendPkt_);
struct hdr_mdart_hello *sendPktRh_ = HDR_MDART_HELLO(sendPkt_);
sendPktCh_->ptype() = PT_MDART;
sendPktCh_->size() = IP_HDR_LEN + mdart_->size();
sendPktCh_->iface() = -2;
sendPktCh_->error() = 0;
sendPktCh_->addr_type() = NS_AF_NONE;
sendPktCh_->next_hop() = IP_BROADCAST;
sendPktIh_->saddr() = mdart_->id_;
sendPktIh_->daddr() = IP_BROADCAST;
sendPktIh_->sport() = RT_PORT;
sendPktIh_->dport() = RT_PORT;
sendPktIh_->ttl_ = IP_DEF_TTL;
sendPktRh_->type_ = MDART_TYPE_HELLO;
sendPktRh_->dstAdd_ = DATYPE_BROADCAST;
sendPktRh_->srcAdd_ = mdart_->address_;
sendPktRh_->srcId_ = mdart_->id_;
sendPktRh_->seqNum_ = helloSeqNum();
// PacketData* data_ = mdart_->routingTable_->getUpdate();
// assert(data_);
string string_ = mdart_->routingTable_->getUpdate();
string_ += "-";
if (mdart_->etxMetric_ == 1) {
string_ += getNeighborQuality();
}
PacketData* data_ = new PacketData(string_.length() + 2);
strcpy((char *)data_->data(), string_.data());
sendPkt_->setdata(data_);
sendPktCh_->size() = IP_HDR_LEN + string_.length() + 2 + mdart_->size();
#ifdef DEBUG_NDP
fprintf(stdout, "\tsendPktIh_->saddr = %d\n", sendPktIh_->saddr());
fprintf(stdout, "\tsendPktIh_->daddr = %d\n", sendPktIh_->daddr());
fprintf(stdout, "\tsendPktRh_->srcId_ = %d\n", sendPktRh_->srcId_);
fprintf(stdout, "\tsendPktRh_->srcAdd_ = %s\n", bitString(sendPktRh_->srcAdd_));
fprintf(stdout, "\tsendPktRh_->dstAdd_ = %s\n", bitString(sendPktRh_->dstAdd_));
fprintf(stdout, "\tsendPktRh_->seqNum_ = %d\n", sendPktRh_->seqNum_);
fprintf(stdout, "\tsendPktRh_->data() = %s\n", ((PacketData*)sendPkt_->userdata())->data());
// if (mdart_->logtarget_ != 0) {
// sprintf(mdart_->logtarget_->pt_->buffer(), "x -t %.9f mdart sendHello srcId %d srcAdd %s dstAdd %s seqNum %d", CURRENT_TIME, sendPktRh_->srcId_, bitString(sendPktRh_->srcAdd_), bitString(sendPktRh_->dstAdd_), sendPktRh_->seqNum_);
// mdart_->logtarget_->pt_->dump();
// }
#endif
Scheduler::instance().schedule(mdart_->getTarget(), sendPkt_, 0.0);
}
void NDP::recvHello(Packet* recvPkt_) {
struct hdr_mdart_hello *recvPktRh_ = HDR_MDART_HELLO(recvPkt_);
#ifdef DEBUG_NDP
fprintf(stdout, "%.9f\tNDP::recvHello()\t\t\tin node %d\twith address %s\n", CURRENT_TIME, mdart_->id_, bitString(mdart_->address_));
struct hdr_ip *recvPktIh_ = HDR_IP(recvPkt_);
fprintf(stdout, "\trecvPktIh_->saddr = %d\n", recvPktIh_->saddr());
fprintf(stdout, "\trecvPktIh_->daddr = %d\n", recvPktIh_->daddr());
fprintf(stdout, "\trecvPktRh_->dstAdd_ = %s\n", bitString(recvPktRh_->dstAdd_));
fprintf(stdout, "\trecvPktRh_->srcAdd_ = %s\n", bitString(recvPktRh_->srcAdd_));
fprintf(stdout, "\trecvPktRh_->srcId_ = %d\n", recvPktRh_->srcId_);
fprintf(stdout, "\trecvPktRh_->seqNum_ = %d\n", recvPktRh_->seqNum_);
fprintf(stdout, "\tsendPktRh_->data() = %s\n", ((PacketData*)recvPkt_->userdata())->data());
#endif
ostringstream strStream_;
strStream_ << ((PacketData*)recvPkt_->userdata())->data();
string string_ = strStream_.str();
string::size_type start_ = string_.find_first_not_of("-", 0);
string::size_type end_ = string_.find_first_of("-", start_);
// string table_ = "-";
// if ((int) end_ > -1)
// table_ = string_.substr(start_, end_);
// else
// end_ = (size_t) 0;
string table_ = string_.substr(start_, end_);
double forQuality_ = (double) 0.0;
#ifdef DEBUG_NDP
fprintf(stdout, "\ttable_ = %s\n", table_.c_str());
#endif
if (mdart_->etxMetric_ == 1) {
string quality_ = string_.substr(end_ + 1, string_.size() - end_ - 1);
#ifdef DEBUG_NDP
fprintf(stdout, "\tquality_ = %s\n", quality_.c_str());
#endif
string::size_type lastPos_ = quality_.find_first_not_of(";", 0);
string::size_type pos_ = quality_.find_first_of(";", lastPos_);
while (string::npos != pos_ || string::npos != lastPos_) {
string neighbor_ = quality_.substr(lastPos_, pos_ - lastPos_);
string::size_type idLastPos_ = neighbor_.find_first_not_of(",", 0);
string::size_type idPos_ = neighbor_.find_first_of(",", idLastPos_);
nsaddr_t id_ = atoi(neighbor_.substr(idLastPos_, idPos_ - idLastPos_).c_str());
string::size_type qualityLastPos_ = neighbor_.find_first_not_of(",", idPos_);
string::size_type qualityPos_ = neighbor_.find_first_of(",", qualityLastPos_);
#ifdef DEBUG_NDP
fprintf(stdout, "\tneigh id %d\tquality %f\n", id_, forQuality_);
#endif
if (id_ == mdart_->id_) {
#ifdef DEBUG_NDP
fprintf(stdout, "\t\tinsert\n");
#endif
forQuality_ = atof(neighbor_.substr(qualityLastPos_, qualityPos_ - qualityLastPos_).c_str());
}
lastPos_ = quality_.find_first_not_of(";", pos_);
pos_ = quality_.find_first_of(";", lastPos_);
}
}
neighborInsert(recvPktRh_->srcId_, recvPktRh_->srcAdd_, recvPktRh_->seqNum_, table_, forQuality_);
Packet::free(recvPkt_);
}
/*******************************************************************************
* NDP timers functions
******************************************************************************/
void NDP::startHelloTimer() {
helloTimer_->handle((Event*) 0);
}
void NDP::startNeighborTimer() {
neighborTimer_->handle((Event*) 0);
}
/*******************************************************************************
* NDP neighbor list functions
******************************************************************************/
Neighbor* NDP::neighborLookup(nsaddr_t id) {
// #ifdef DEBUG
// fprintf(stdout, "%.9f\tNDP::neighborLookup(%d)\t\t\tin node %d\twith address %s\n", CURRENT_TIME, id, mdart_->id_, bitString(mdart_->address_));
// #endif
neighborSet::iterator neighbor_;
for (neighbor_ = neighborSet_->begin(); neighbor_ != neighborSet_->end(); ++neighbor_) {
if((*neighbor_)->id() == id) {
// #ifdef DEBUG
// fprintf(stdout, "\tId found\n");
// #endif
return (*neighbor_);
}
}
return 0;
}
void NDP::neighborInsert(nsaddr_t id, nsaddr_t address, u_int32_t helloSeqNum, string table, double quality) {
#ifdef DEBUG_NDP
fprintf(stdout, "%.9f\tNDP::neighborInsert(%d, %s, %f)\t\tin node %d\twith address %s\n", CURRENT_TIME, id, bitString(address), quality, mdart_->id_, bitString(mdart_->address_));
#endif
Neighbor *neighbor_ = neighborLookup(id);
if (neighbor_ == 0) {
// fprintf(stdout, "\tNeighbor inserted\n");
neighbor_ = new Neighbor(id, address, helloSeqNum);
neighborSet_->insert(neighbor_);
}
else {
neighbor_->address(address, helloSeqNum);
// neighbor_->expire(expire);
}
//#ifdef LQE_ALGORITHM_MA
// if (quality != 0)
neighbor_->forLinkQuality(quality);
//#endif
neighbor_->updateTable(table);
}
/*
void NDP::neighborDelete(nsaddr_t id) {
#ifdef DEBUG_NDP
fprintf(stdout, "%.9f\tNDP::neighborDelete(%d)\t\t\tin node %d\twith address %s\n", CURRENT_TIME, id, mdart_->id_, bitString(mdart_->address_));
#endif
neighborSet::iterator neighbor_;
for (neighbor_ = neighborSet_->begin(); neighbor_ != neighborSet_->end(); ++neighbor_) {
if((*neighbor_)->id() == id) {
neighborSet_->erase(neighbor_);
#ifdef DEBUG_NDP
fprintf(stdout, "\tNeighbor removed\n");
#endif
break;
}
}
}
*/
void NDP::neighborPurge(void) {
#ifdef DEBUG_NDP
fprintf(stdout, "%.9f\tNDP::neighborPurge()\t\t\tin node %d\twith address %s\n", CURRENT_TIME, mdart_->id_, bitString(mdart_->address_));
#endif
double now = CURRENT_TIME;
neighborSet::iterator neighbor_ = neighborSet_->begin();
while (neighbor_ != neighborSet_->end()) {
neighborSet::iterator nextNeighbor_ = neighbor_;
++nextNeighbor_;
if((*neighbor_)->expire() <= now) {
// mdart_->routingTable_->purge((*neighbor_)->id_);
neighborSet_->erase(neighbor_);
delete (*neighbor_);
#ifdef DEBUG_NDP
fprintf(stdout, "\tNeighbor purged\n");
#endif
}
else {
(*neighbor_)->purgeHello();
}
neighbor_ = nextNeighbor_;
}
/* neighborSet::iterator neighbor_;
for (neighbor_ = neighborSet_->begin(); neighbor_ != neighborSet_->end(); ++neighbor_) {
#ifdef DEBUG
fprintf(stdout, "\tNeighbor id = %d\texpire = %.9f\n", (*neighbor_)->id_, (*neighbor_)->expire());
#endif
if((*neighbor_)->expire() <= now) {
// mdart_->routingTable_->purge((*neighbor_)->id_);
neighborSet_->erase(neighbor_);
delete (*neighbor_);
#ifdef DEBUG
fprintf(stdout, "\tNeighbor purged\n");
#endif
}
}
*/}
void NDP::neighborPrint() {
#ifdef DEBUG_ADDRESS_ALLOCATION
fprintf(stdout, "\tNDP::neighborPrint()\t\t\tin node %d\twith address %s\n", mdart_->id_, bitString(mdart_->address_));
#endif
neighborSet::iterator neighbor_;
//#ifdef DEBUG_ADDRESS_ALLOCATION
for (neighbor_ = neighborSet_->begin(); neighbor_ != neighborSet_->end(); ++neighbor_) {
fprintf(stdout, "\t\tNeighbor id=%d\taddress=%s\n", (*neighbor_)->id(), bitString((*neighbor_)->address()));
// (*neighbor_)->printTable();
// ora
}
//#endif
}
int NDP::neighborDegree() {
int degree = 0;
neighborSet::iterator neighbor_;
for (neighbor_ = neighborSet_->begin(); neighbor_ != neighborSet_->end(); ++neighbor_) {
degree += 1;
}
return degree;
}
int NDP::realNeighborDegree() {
int degree = 0;
neighborSet::iterator neighbor_;
for (neighbor_ = neighborSet_->begin(); neighbor_ != neighborSet_->end(); ++neighbor_) {
if(((*neighbor_)->expire() - (1.5 * NDP_ALLOWED_HELLO_LOSS * NDP_HELLO_INTERVAL) + NDP_HELLO_INTERVAL) >= CURRENT_TIME) {
degree += 1;
}
}
return degree;
}
/*
void NDP::setNeighborQuality(string str_) {
string::size_type lastPos_ = str_.find_first_not_of(";", 0);
string::size_type pos_ = str_.find_first_of(";", lastPos_);
while (string::npos != pos_ || string::npos != lastPos_) {
string neighbor_ = str_.substr(lastPos_, pos_ - lastPos_);
string::size_type idLastPos_ = neighbor_.find_first_not_of(",", 0);
string::size_type idPos_ = neighbor_.find_first_of(",", idLastPos_);
nsaddr_t id_ = atoi(neighbor_.substr(idLastPos_, idPos_ - idLastPos_).c_str());
string::size_type qualityLastPos_ = neighbor_.find_first_not_of(",", idPos_);
string::size_type qualityPos_ = neighbor_.find_first_of(",", qualityLastPos_);
double quality_ = atoi(neighbor_.substr(qualityLastPos_, qualityPos_ - qualityLastPos_).c_str());
#ifdef DEBUG_NDP
fprintf(stdout, "\tneigh id %d\tquality %f\n", id_, quality_);
#endif
// addEntry(id_, address_, expire_);
lastPos_ = str_.find_first_not_of(";", pos_);
pos_ = str_.find_first_of(";", lastPos_);
}
// dht_->setDHTUpdate((PacketData*)recvPkt->userdata());
}
*/
string NDP::getNeighborQuality() {
#ifdef DEBUG_NDP
fprintf(stdout, "%.9f\tNDP::getNeighborQuality()\n", CURRENT_TIME);
#endif
string str_;
neighborSet::iterator neighbor_;
for (neighbor_ = neighborSet_->begin(); neighbor_ != neighborSet_->end(); ++neighbor_) {
/* if((*neighbor_)->revLinkQuality() < LQE_RV_THRESHOLD) {
fprintf(stdout, "%.9f\tNDP::getNeighborQuality()\n", CURRENT_TIME);
fprintf(stdout, "\tid = %d\trevLinkQuality() = %f\n", (*neighbor_)->id(), (*neighbor_)->revLinkQuality());
// (*neighbor_)->printHello();
}*/
// if((*neighbor_)->revLinkQuality() >= LQE_RV_THRESHOLD) {
ostringstream stream_;
stream_ << (*neighbor_)->id();
stream_ << ',';
stream_ << (*neighbor_)->revLinkQuality();
stream_ << ';';
str_ += stream_.str();
// }
}
#ifdef DEBUG_NDP
fprintf(stdout, "\tdata = %s\n", str_.data());
#endif
return str_;
}
/*******************************************************************************
* NDP management functions
******************************************************************************/
void NDP::selectAddress() {
#ifdef DEBUG_NDP
fprintf(stdout, "\tNDP::selectAddress()\t\t\tin node %d\twith address %s\n", mdart_->id_, bitString(mdart_->address_));
#endif
neighborSet::iterator neighbor_;
for (neighbor_ = neighborSet_->begin(); neighbor_ != neighborSet_->end(); ++neighbor_) {
#ifdef DEBUG_NDP_LINK_QUALITY
if (mdart_->etxMetric_ == 1 && (*neighbor_)->linkQuality() < LQE_THRESHOLD) {
fprintf(stdout, "%.9f\tNDP::selectAddress()\t\t\tin node %d\twith address %s\n", CURRENT_TIME, mdart_->id_, bitString(mdart_->address_));
fprintf(stdout, "\tlinkQuality() = %f\trevLinkQuality() = %f\n", (*neighbor_)->linkQuality(), (*neighbor_)->revLinkQuality());
}
#endif
if ((mdart_->etxMetric_ == 1 && (*neighbor_)->linkQuality() > LQE_THRESHOLD) || mdart_->etxMetric_ == 0) {
#ifdef DEBUG_NDP
fprintf(stdout, "\t\tselected neighbor id=%d\taddress=%s\n", (*neighbor_)->id(), bitString((*neighbor_)->address()));
#endif
int i;
for(i=(*neighbor_)->insertionPoint(); i>-1; i--) {
std::bitset<ADDR_SIZE> bitNewAddress_((*neighbor_)->address());
bitNewAddress_.flip(i);
mdart_->address_ = bitNewAddress_.to_ulong();
#ifdef DEBUG_ADDRESS_ALLOCATION
fprintf(stdout, "\t\ttrying address=%s\n", bitString(mdart_->address_));
#endif
mdart_->routingTable_->setUpdate((*neighbor_));
if (validateAddress()) {
#ifdef DEBUG_ADDRESS_ALLOCATION
fprintf(stdout, "\t\taddress selected is %s\n", bitNewAddress_.to_string().c_str());
#endif
mdart_->adp_->updateAdd();
return;
}
else {
#ifdef DEBUG_NDP
fprintf(stdout, "\t\taddress selected %s is not valid\n", bitNewAddress_.to_string().c_str());
#endif
mdart_->address_ = mdart_->oldAddress_;
mdart_->routingTable_->clear();
}
}
}
}
#ifdef DEBUG_NDP
fprintf(stdout, "\t\tcouldn't select a valid address\n");
#endif
}
bool NDP::validateAddress() {
#ifdef DEBUG_ADDRESS_ALLOCATION
fprintf(stdout, "\tNDP::validateAddress()\t\t\tin node %d\twith address %s\n", mdart_->id_, bitString(mdart_->address_));
mdart_->routingTable_->print();
#endif
neighborSet::iterator neighbor_;
for (neighbor_ = neighborSet_->begin(); neighbor_ != neighborSet_->end(); ++neighbor_) {
#ifdef DEBUG_NDP_LINK_QUALITY
fprintf(stdout, "\tid = %d\tlinkQuality() = %f\trevLinkQuality() = %f\n", (*neighbor_)->id(), (*neighbor_)->linkQuality(), (*neighbor_)->revLinkQuality());
#endif
if ((mdart_->etxMetric_ == 1 && (*neighbor_)->linkQuality() >= LQE_THRESHOLD) || mdart_->etxMetric_ == 0) {
int levelSibling_ = DiffBit(mdart_->address_, (*neighbor_)->address());
#ifdef DEBUG_ADDRESS_ALLOCATION
fprintf(stdout, "\t\tNeighbor id=%d\taddress = %s\tLevel sibling = %d\n", (*neighbor_)->id(), bitString((*neighbor_)->address()), levelSibling_);
#endif
if (levelSibling_ == -1) {
#ifdef DEBUG_ADDRESS_ALLOCATION
if ((*neighbor_)->id() >= mdart_->id_) {
fprintf(stdout, "\t\t\tNeighbor id=%d >= node id=%d\n", (*neighbor_)->id(), mdart_->id_);
}
#endif
if ((*neighbor_)->id() < mdart_->id_) {
#ifdef DEBUG_ADDRESS_ALLOCATION
fprintf(stdout, "\t\t\tNeighbor id=%d < node id=%d\n", (*neighbor_)->id(), mdart_->id_);
fprintf(stdout, "\t\t\tinvalid address\n");
#endif
return false;
}
}
else {
#ifdef DEBUG_ADDRESS_ALLOCATION
if (!(*neighbor_)->entryPresent(levelSibling_)) {
fprintf(stdout, "\t\t\tNeighbor Entry not present\n");
}
#endif
if ((*neighbor_)->entryPresent(levelSibling_)) {
#ifdef DEBUG_ADDRESS_ALLOCATION
if ((*neighbor_)->networkId(levelSibling_) >= mdart_->routingTable_->levelId(levelSibling_-1)) {
fprintf(stdout, "\t\t\tNeighborTableEntry->networkId(%d)=%d >= node levelId(%d)=%d\n", levelSibling_, (*neighbor_)->networkId(levelSibling_), levelSibling_ -1 , mdart_->routingTable_->levelId(levelSibling_-1));
}
#endif
if ((*neighbor_)->networkId(levelSibling_) < mdart_->routingTable_->levelId(levelSibling_-1)) {
#ifdef DEBUG_ADDRESS_ALLOCATION
fprintf(stdout, "\t\t\tNeighborTableEntry->networkId(%d)=%d < node levelId(%d)=%d\n", levelSibling_, (*neighbor_)->networkId(levelSibling_), levelSibling_ -1 , mdart_->routingTable_->levelId(levelSibling_-1));
fprintf(stdout, "\t\t\tinvalid address\n");
#endif
return false;
}
}
}
#ifdef DEBUG_ADDRESS_ALLOCATION
fprintf(stdout, "\t\t\tvalid address\n");
#endif
}
}
return true;
}
void NDP::updateRoutingTable() {
#ifdef DEBUG_NDP_LINK_QUALITY
fprintf(stdout, "%.9f\tNDP::updateRoutingTable()\t\t\tin node %d\twith address %s\n", CURRENT_TIME, mdart_->id_, bitString(mdart_->address_));
#endif
neighborSet::iterator neighbor_;
for (neighbor_ = neighborSet_->begin(); neighbor_ != neighborSet_->end(); ++neighbor_) {
#ifdef DEBUG_NDP_LINK_QUALITY
if (mdart_->etxMetric_ == 1 && (*neighbor_)->linkQuality() < LQE_THRESHOLD) {
fprintf(stdout, "\tid = %d\tlinkQuality() = %f\trevLinkQuality() = %f\n", (*neighbor_)->id(), (*neighbor_)->linkQuality(), (*neighbor_)->revLinkQuality());
// neighborPrint();
}
#endif
if ((mdart_->etxMetric_ == 1 && (*neighbor_)->linkQuality() >= LQE_THRESHOLD) || mdart_->etxMetric_ == 0)
mdart_->routingTable_->setUpdate(*neighbor_);
}
}
| 40.839147 | 234 | 0.631472 | nitishk017 |
0e0c3b4b237b4e52dd678acf57557b22c1c8c8a6 | 1,164 | cpp | C++ | Tek2/Piscine-CPP/piscine_cpp_d14m/ex00/FruitBox.cpp | Estayparadox/Epitech-Bundle | e4395961bb86bf494e3c84ab44c27b5a9afc6c6c | [
"MIT"
] | 30 | 2018-10-26T12:54:11.000Z | 2022-02-04T18:18:57.000Z | Tek2/Piscine-CPP/piscine_cpp_d14m/ex00/FruitBox.cpp | Estayparadox/Epitech-Bundle | e4395961bb86bf494e3c84ab44c27b5a9afc6c6c | [
"MIT"
] | null | null | null | Tek2/Piscine-CPP/piscine_cpp_d14m/ex00/FruitBox.cpp | Estayparadox/Epitech-Bundle | e4395961bb86bf494e3c84ab44c27b5a9afc6c6c | [
"MIT"
] | 26 | 2018-11-20T18:11:39.000Z | 2022-01-28T21:05:30.000Z | //
// FruitBox.cpp for FruitBox.cpp in /home/pereni_j/Rendu/piscine_cpp_d14m/ex00
//
// Made by pereniguez joseph
// Login <pereni_j@epitech.net>
//
// Started on Tue Jan 19 19:09:48 2016 pereniguez joseph
// Last update Tue Jan 19 19:47:15 2016 pereniguez joseph
//
#include "FruitBox.h"
FruitBox::FruitBox(int size) : _size(size), _header(NULL)
{
}
FruitBox::~FruitBox()
{
}
int FruitBox::nbFruit() const
{
return _count;
}
bool FruitBox::putFruit(Fruit *fruit)
{
if (_count < _size)
{
FruitNode * current = _header;
FruitNode * node = new FruitNode();
node->box = fruit;
if (!_header)
_header = node;
else
{
while (current->next)
{
if (current->box == fruit)
return false;
current = current->next;
}
current->next = node;
}
_count++;
return true;
}
return false;
}
Fruit *FruitBox::pickFruit()
{
if (_count)
{
Fruit * fruit = _header->box;
FruitNode * del = _header;
_header = _header->next;
delete del;
_count--;
return fruit;
}
return NULL;
}
FruitNode *FruitBox::head() const
{
return _header;
}
| 16.869565 | 78 | 0.600515 | Estayparadox |
0e0ceb72e77c4782d9e004faeb4b11acc9674d8a | 40,072 | cpp | C++ | tx2-setup/robust_pose_graph_optimization/buzz_slam/src/slam/specialized/dataset/buzz_slam_dataset.cpp | SnowCarter/DOOR-SLAM | cf56d2b4b7a21ed7c6445f01600408c9dd5235c6 | [
"MIT"
] | 3 | 2021-07-05T17:59:01.000Z | 2022-03-31T12:46:25.000Z | tx2-setup/robust_pose_graph_optimization/buzz_slam/src/slam/specialized/dataset/buzz_slam_dataset.cpp | SnowCarter/DOOR-SLAM | cf56d2b4b7a21ed7c6445f01600408c9dd5235c6 | [
"MIT"
] | null | null | null | tx2-setup/robust_pose_graph_optimization/buzz_slam/src/slam/specialized/dataset/buzz_slam_dataset.cpp | SnowCarter/DOOR-SLAM | cf56d2b4b7a21ed7c6445f01600408c9dd5235c6 | [
"MIT"
] | 3 | 2020-03-25T16:21:25.000Z | 2021-07-05T16:37:34.000Z | #include "buzz_slam_dataset.h"
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <cmath>
#include "boost/filesystem.hpp"
namespace buzz_slam {
/****************************************/
/****************************************/
BuzzSLAMDataset::BuzzSLAMDataset() {
}
/****************************************/
/****************************************/
BuzzSLAMDataset::~BuzzSLAMDataset() {
}
/****************************************/
/****************************************/
void BuzzSLAMDataset::Init(buzzvm_t buzz_vm, const gtsam::Point3& t_gt, const gtsam::Rot3& R_gt){
BuzzSLAM::Init(buzz_vm);
// Initialize for tracing variables
number_of_outliers_added_ = 0;
number_of_inliers_added_ = 0;
// Initialize random numbers generators
srand(time(NULL));
gen_translation_ = std::mt19937{rd_()};
gen_rotation_ = std::mt19937{rd_()};
gen_outliers_ = std::mt19937{rd_()};
normal_distribution_translation_ = std::normal_distribution<>{0, translation_noise_std_};
normal_distribution_rotation_ = std::normal_distribution<>{0, rotation_noise_std_};
uniform_distribution_outliers_translation_ = std::uniform_real_distribution<>{0, sensor_range_};
uniform_distribution_outliers_rotation_ = std::uniform_real_distribution<>{-M_PI, M_PI};
uniform_distribution_draw_outlier_ = std::uniform_real_distribution<>{0, 1};
previous_symbol_ = gtsam::Symbol(robot_id_char_, number_of_poses_);
// Isotropic noise models
chordal_graph_noise_model_ = gtsam::noiseModel::Isotropic::Variance(12, 1);
// Initialize log files
if (is_simulation_ && robot_id_ == 0 && !boost::filesystem::exists(error_file_name_)) {
// Write results to csv
std::ofstream error_file;
error_file.open(error_file_name_, std::ios::out | std::ios::app);
error_file << "NumberOfRobots\tNumberOfPoses\tNumberOfSeparators\tOutlierPeriod\tUsesIncrementalSolving"
"\tRotationNoiseStd\tTranslationNoiseStd\tRotationChangeThreshold\tPoseChangeThreshold"
"\tOptimizerPeriod\tChiSquaredProbability"
"\tErrorCentralized\tErrorDecentralized\tErrorInitial\tNumberOfRotationIterations\tNumberOfPoseIterations"
"\tNumberOfInliers\tNumberOfOutliers\tNumberOfSeparatorsRejected\tNumberOfOutliersNotRejected\n";
error_file.close();
}
std::string log_file_name = log_folder_ + std::to_string(robot_id_) + "_inliers_added_keys.g2o";
std::remove(log_file_name.c_str());
log_file_name = log_folder_ + std::to_string(robot_id_) + "_outliers_added_keys.g2o";
std::remove(log_file_name.c_str());
log_file_name = log_folder_ + std::to_string(robot_id_) + "_reference_frame.g2o";
std::remove(log_file_name.c_str());
// Read .g2o dataset file
std::string dataset_file_name = dataset_name_ + "/" + std::to_string(robot_id_) + ".g2o";
auto dataset_graph_and_values = gtsam::readG2o(dataset_file_name, true);
// Fill values with odometry starting from ground truth position
auto initial_orientation = R_gt;
auto initial_translation = t_gt;
auto current_pose = gtsam::Pose3(initial_orientation, initial_translation);
auto current_key = gtsam::Symbol(robot_id_char_, 0).key();
dataset_graph_and_values.second->insert(current_key, current_pose);
for (auto factor : *dataset_graph_and_values.first) {
auto between_factor = boost::dynamic_pointer_cast<gtsam::BetweenFactor<gtsam::Pose3>>(factor);
auto first_key = between_factor->key1();
auto first_symbol = gtsam::Symbol(first_key);
auto second_key = between_factor->key2();
auto second_symbol = gtsam::Symbol(second_key);
dataset_factors_.insert(std::make_pair(std::make_pair(first_key, second_key), between_factor));
if (first_symbol.chr() == robot_id_char_ && second_symbol.chr() == robot_id_char_) {
if (first_key == current_key) {
// Measurement
gtsam::Pose3 measurement(between_factor->measured().rotation(),
gtsam::Point3(between_factor->measured().x()/10, between_factor->measured().y()/10, between_factor->measured().z()/10));
// Compose previous pose and measurement
current_pose = current_pose * measurement;
// Add pose
dataset_graph_and_values.second->insert(second_key, current_pose);
} else {
// Find first pose
current_pose = dataset_graph_and_values.second->at<gtsam::Pose3>(first_key);
// Measurement
gtsam::Pose3 measurement(between_factor->measured().rotation(),
gtsam::Point3(between_factor->measured().x()/10, between_factor->measured().y()/10, between_factor->measured().z()/10));
// Compose previous pose and measurement
current_pose = current_pose * measurement;
// Add pose
dataset_graph_and_values.second->insert(second_key, current_pose);
}
} else {
if (first_symbol.chr() == robot_id_char_ && first_symbol.index() > second_symbol.index()) {
if (loop_closure_linked_to_key_.count(first_key) == 0) {
loop_closure_linked_to_key_.insert(std::make_pair(first_key, std::make_pair(first_key, second_key)));
}
} else if (second_symbol.chr() == robot_id_char_ && second_symbol.index() > first_symbol.index()) {
if (loop_closure_linked_to_key_.count(second_key) == 0) {
loop_closure_linked_to_key_.insert(std::make_pair(second_key, std::make_pair(first_key, second_key)));
}
}
}
}
dataset_reading_ended_ = false;
dataset_values_ = dataset_graph_and_values.second;
}
/****************************************/
/****************************************/
bool BuzzSLAMDataset::KeyExists(const gtsam::Key& key) {
return dataset_values_->exists(key);
}
/****************************************/
/****************************************/
gtsam::Pose3 BuzzSLAMDataset::GetPoseAtKey(const gtsam::Key& key) {
return dataset_values_->at<gtsam::Pose3>(key);
}
/****************************************/
/****************************************/
void BuzzSLAMDataset::LoadParameters(const std::string& dataset_name, const double& sensor_range, const int& outlier_period) {
sensor_range_ = sensor_range;
dataset_name_ = dataset_name;
outlier_period_ = outlier_period;
}
/****************************************/
/****************************************/
void BuzzSLAMDataset::AddOdometryMeasurement() {
// Increase the number of poses
IncrementNumberOfPoses();
// Next symbol
gtsam::Symbol current_symbol = gtsam::Symbol(robot_id_char_, number_of_poses_);
// Initialize factor
if (dataset_factors_.count(std::make_pair(previous_symbol_, current_symbol)) != 0) {
auto new_factor = dataset_factors_.at(std::make_pair(previous_symbol_, current_symbol));
// Add gaussian noise
auto measurement = new_factor->measured();
// Update attributes
auto new_pose = poses_initial_guess_->at<gtsam::Pose3>(previous_symbol_.key()) * measurement;
auto new_pose_no_updates = poses_initial_guess_no_updates_->at<gtsam::Pose3>(previous_symbol_.key()) * measurement;
poses_initial_guess_no_updates_->insert(current_symbol.key(), new_pose_no_updates);
auto new_pose_incremental = poses_initial_guess_centralized_incremental_updates_->at<gtsam::Pose3>(previous_symbol_.key()) * measurement;
poses_initial_guess_centralized_incremental_updates_->insert(current_symbol.key(), new_pose_incremental);
// Update attributes
previous_symbol_ = current_symbol;
// Add new factor to local pose graph
local_pose_graph_->push_back(new_factor);
local_pose_graph_no_filtering_->push_back(new_factor);
// Add new pose estimate into initial guess
poses_initial_guess_->insert(current_symbol.key(), new_pose);
// Add transform to local map for pairwise consistency maximization
auto covariance_matrix = boost::dynamic_pointer_cast< gtsam::noiseModel::Gaussian >(new_factor->noiseModel())->covariance();
robot_local_map_.addTransform(*new_factor, covariance_matrix);
} else {
number_of_poses_ --;
dataset_reading_ended_ = true;
}
}
/****************************************/
/****************************************/
gtsam::Pose3 BuzzSLAMDataset::OutlierMeasurement(const gtsam::Rot3& R, const gtsam::Point3& t) {
// TODO: Add option to add noise greater than 3 or 5 sigmas, instead of totally random measurment
// This is why this method takes the measurement in parameter.
gtsam::Point3 t_outlier = { uniform_distribution_outliers_translation_(gen_outliers_),
uniform_distribution_outliers_translation_(gen_outliers_),
uniform_distribution_outliers_translation_(gen_outliers_) };
gtsam::Rot3 R_outlier = gtsam::Rot3::Ypr( uniform_distribution_outliers_rotation_(gen_outliers_),
uniform_distribution_outliers_rotation_(gen_outliers_),
uniform_distribution_outliers_rotation_(gen_outliers_));
number_of_outliers_added_++;
return gtsam::Pose3(R_outlier, t_outlier);
}
/****************************************/
/****************************************/
int BuzzSLAMDataset::AddSeparatorMeasurement() {
if (loop_closure_linked_to_key_.count(previous_symbol_.key()) == 0) {
return 0;
}
// Separator symbols
auto loop_closure_keys = loop_closure_linked_to_key_.at(previous_symbol_.key());
AddNewKnownRobot(gtsam::Symbol(loop_closure_keys.first).chr());
AddNewKnownRobot(gtsam::Symbol(loop_closure_keys.second).chr());
// Get factor or make it an outlier
boost::shared_ptr<gtsam::BetweenFactor<gtsam::Pose3>> new_factor = dataset_factors_.at(std::make_pair(loop_closure_keys.first, loop_closure_keys.second));
gtsam::Pose3 measurement = new_factor->measured();
number_of_inliers_added_++;
auto covariance_matrix = boost::dynamic_pointer_cast< gtsam::noiseModel::Gaussian >(new_factor->noiseModel())->covariance();
UpdateCurrentSeparatorBuzzStructure( (int)(gtsam::Symbol(loop_closure_keys.first).chr() - 97),
(int)(gtsam::Symbol(loop_closure_keys.second).chr() - 97),
gtsam::Symbol(loop_closure_keys.first).index(),
gtsam::Symbol(loop_closure_keys.second).index(),
measurement.x(),
measurement.y(),
measurement.z(),
measurement.rotation().quaternion()[1],
measurement.rotation().quaternion()[2],
measurement.rotation().quaternion()[3],
measurement.rotation().quaternion()[0],
covariance_matrix );
inliers_keys_.insert(std::make_pair(loop_closure_keys.first, loop_closure_keys.second));
// Add new factor to local pose graph
local_pose_graph_->push_back(new_factor);
local_pose_graph_no_filtering_->push_back(new_factor);
// Add transform to local map for pairwise consistency maximization
robot_local_map_.addTransform(*new_factor, covariance_matrix);
covariance_matrix_for_outlier_ = covariance_matrix;
// Add info for flagged initialization
IncrementNumberOfSeparatorsWithOtherRobot((int) gtsam::Symbol(loop_closure_keys.first).chr() - 97);
IncrementNumberOfSeparatorsWithOtherRobot((int) gtsam::Symbol(loop_closure_keys.second).chr() - 97);
IncrementNumberOfInliersWithOtherRobot((int) gtsam::Symbol(loop_closure_keys.first).chr() - 97);
IncrementNumberOfInliersWithOtherRobot((int) gtsam::Symbol(loop_closure_keys.second).chr() - 97);
return 1;
}
/****************************************/
/****************************************/
void BuzzSLAMDataset::IncrementNumberOfOutliersWithOtherRobot(const int& other_robot_id) {
if (other_robot_id != robot_id_) {
if (number_of_outliers_with_each_robot_.count(other_robot_id) == 0) {
number_of_outliers_with_each_robot_.insert(std::make_pair(other_robot_id, 1));
} else {
number_of_outliers_with_each_robot_[other_robot_id] = number_of_outliers_with_each_robot_[other_robot_id] + 1;
}
}
}
/****************************************/
/****************************************/
void BuzzSLAMDataset::IncrementNumberOfInliersWithOtherRobot(const int& other_robot_id) {
if (other_robot_id != robot_id_) {
if (number_of_inliers_with_each_robot_.count(other_robot_id) == 0) {
number_of_inliers_with_each_robot_.insert(std::make_pair(other_robot_id, 1));
} else {
number_of_inliers_with_each_robot_[other_robot_id] = number_of_inliers_with_each_robot_[other_robot_id] + 1;
}
}
}
/****************************************/
/****************************************/
int BuzzSLAMDataset::AddSeparatorMeasurementOutlier() {
// Separator symbols
if (known_other_robots_.empty() || dataset_reading_ended_){
return 0;
}
auto random_id = std::floor(uniform_distribution_draw_outlier_(gen_outliers_) * number_of_robots_);
while (random_id == robot_id_ || known_other_robots_.find((char) random_id + 97) == known_other_robots_.end()) {
random_id = std::floor(uniform_distribution_draw_outlier_(gen_outliers_) * number_of_robots_);
}
if (number_of_inliers_with_each_robot_[random_id] <= number_of_outliers_with_each_robot_[random_id] + 1) {
return 0;
}
auto random_index1 = std::floor(uniform_distribution_draw_outlier_(gen_outliers_) * (number_of_poses_-1) + 1);
auto random_index2 = std::floor(uniform_distribution_draw_outlier_(gen_outliers_) * (number_of_poses_-1) + 1);
auto loop_closure_keys = std::make_pair(gtsam::Symbol(robot_id_char_, random_index1), gtsam::Symbol((char)(random_id + 97), random_index2));
// Get an outlier
gtsam::Pose3 measurement = OutlierMeasurement(gtsam::Rot3(), gtsam::Point3());
boost::shared_ptr<gtsam::BetweenFactor<gtsam::Pose3>> new_factor = boost::make_shared<gtsam::BetweenFactor<gtsam::Pose3>>(gtsam::Symbol(loop_closure_keys.first), gtsam::Symbol(loop_closure_keys.second), measurement, gtsam::noiseModel::Gaussian::Covariance(covariance_matrix_for_outlier_));
UpdateCurrentSeparatorBuzzStructure( (int)(gtsam::Symbol(loop_closure_keys.first).chr() - 97),
(int)(gtsam::Symbol(loop_closure_keys.second).chr() - 97),
gtsam::Symbol(loop_closure_keys.first).index(),
gtsam::Symbol(loop_closure_keys.second).index(),
measurement.x(),
measurement.y(),
measurement.z(),
measurement.rotation().quaternion()[1],
measurement.rotation().quaternion()[2],
measurement.rotation().quaternion()[3],
measurement.rotation().quaternion()[0],
covariance_matrix_for_outlier_ );
outliers_keys_.insert(std::make_pair(loop_closure_keys.first, loop_closure_keys.second));
// Add new factor to local pose graph
local_pose_graph_->push_back(new_factor);
local_pose_graph_no_filtering_->push_back(new_factor);
// Add transform to local map for pairwise consistency maximization
robot_local_map_.addTransform(*new_factor, covariance_matrix_for_outlier_);
// Add info for flagged initialization
IncrementNumberOfOutliersWithOtherRobot((int) gtsam::Symbol(loop_closure_keys.second).chr() - 97);
return 1;
}
/****************************************/
/****************************************/
void BuzzSLAMDataset::WriteOptimizedDataset() {
BuzzSLAM::WriteOptimizedDataset();
std::string inliers_added_file_name = log_folder_ + std::to_string(robot_id_) + "_number_of_inliers_added.g2o";
std::ofstream inliers_added_file;
inliers_added_file.open(inliers_added_file_name, std::ios::trunc);
inliers_added_file << number_of_inliers_added_ << "\n" ;
inliers_added_file.close();
std::string outliers_keys_file_name = log_folder_ + std::to_string(robot_id_) + "_outliers_added_keys.g2o";
std::ofstream outliers_keys_file;
outliers_keys_file.open(outliers_keys_file_name, std::ios::trunc);
for (const auto& keys : outliers_keys_) {
outliers_keys_file << keys.first << " " << keys.second << "\n" ;
}
outliers_keys_file.close();
std::string inliers_keys_file_name = log_folder_ + std::to_string(robot_id_) + "_inliers_added_keys.g2o";
std::ofstream inliers_keys_file;
inliers_keys_file.open(inliers_keys_file_name, std::ios::trunc);
for (const auto& keys : inliers_keys_) {
inliers_keys_file << keys.first << " " << keys.second << "\n" ;
}
inliers_keys_file.close();
std::string reference_frame_file_name = log_folder_ + std::to_string(robot_id_) + "_reference_frame.g2o";
std::ofstream reference_frame_file;
reference_frame_file.open(reference_frame_file_name, std::ios::trunc);
reference_frame_file << lowest_id_included_in_global_map_ << "\n" ;
reference_frame_file.close();
}
/****************************************/
/****************************************/
void BuzzSLAMDataset::RemoveRejectedKeys() {
for (const auto& rejected_pair : rejected_keys_) {
inliers_keys_.erase(rejected_pair);
inliers_keys_.erase(std::make_pair(rejected_pair.second, rejected_pair.first));
outliers_keys_.erase(rejected_pair);
outliers_keys_.erase(std::make_pair(rejected_pair.second, rejected_pair.first));
}
rejected_keys_.clear();
}
/****************************************/
/****************************************/
std::set<std::pair<gtsam::Key, gtsam::Key>> BuzzSLAMDataset::AggregateOutliersKeys(const std::set<int>& robots) {
std::set<std::pair<gtsam::Key, gtsam::Key>> outliers_keys;
for (const auto& i : robots) {
std::string outliers_keys_file_name = log_folder_ + std::to_string(i) + "_outliers_added_keys.g2o";
std::ifstream outliers_keys_file(outliers_keys_file_name);
long unsigned int key1, key2;
while (outliers_keys_file >> key1)
{
outliers_keys_file >> key2;
outliers_keys.insert(std::make_pair(gtsam::Key(key1), gtsam::Key(key2)));
}
outliers_keys_file.close();
}
return outliers_keys;
}
/****************************************/
/****************************************/
std::pair<int, int> BuzzSLAMDataset::CountInliersAndOutliers(const std::set<int>& robots) {
std::set<std::pair<gtsam::Key, gtsam::Key>> inliers_keys;
for (const auto& i : robots) {
std::string inliers_keys_file_name = log_folder_ + std::to_string(i) + "_inliers_added_keys.g2o";
std::ifstream inliers_keys_file(inliers_keys_file_name);
long unsigned int key1, key2;
while (inliers_keys_file >> key1)
{
inliers_keys_file >> key2;
auto robot_id_1 = (int) (gtsam::Symbol(key1).chr() - 97);
auto robot_id_2 = (int) (gtsam::Symbol(key2).chr() - 97);
if (robots.find(robot_id_1) != robots.end() &&
robots.find(robot_id_2) != robots.end()) {
inliers_keys.insert(std::make_pair(gtsam::Key(key1), gtsam::Key(key2)));
}
}
inliers_keys_file.close();
}
std::set<std::pair<gtsam::Key, gtsam::Key>> outliers_keys;
for (const auto& i : robots) {
std::string outliers_keys_file_name = log_folder_ + std::to_string(i) + "_outliers_added_keys.g2o";
std::ifstream outliers_keys_file(outliers_keys_file_name);
long unsigned int key1, key2;
while (outliers_keys_file >> key1)
{
outliers_keys_file >> key2;
auto robot_id_1 = (int) (gtsam::Symbol(key1).chr() - 97);
auto robot_id_2 = (int) (gtsam::Symbol(key2).chr() - 97);
if (robots.find(robot_id_1) != robots.end() &&
robots.find(robot_id_2) != robots.end()) {
outliers_keys.insert(std::make_pair(gtsam::Key(key1), gtsam::Key(key2)));
}
}
outliers_keys_file.close();
}
return std::make_pair(inliers_keys.size(), outliers_keys.size());
}
/****************************************/
/****************************************/
bool BuzzSLAMDataset::CompareCentralizedAndDecentralizedError() {
// Initialize the set of robots on which to evaluate
std::set<int> robots = neighbors_within_communication_range_;
robots.insert(robot_id_);
// Compute incremental centralized estimates
ComputeCentralizedEstimateIncremental(robots, "");
ComputeCentralizedEstimateIncremental(robots, "_no_filtering");
// Collect expected estimate size
std::string local_dataset_file_name = log_folder_ + std::to_string(robot_id_) + "_initial.g2o";
gtsam::GraphAndValues local_graph_and_values = gtsam::readG2o(local_dataset_file_name, true);
int expected_size = local_graph_and_values.second->size();
// Aggregate estimates from all the robots
auto aggregated_outliers_keys = AggregateOutliersKeys(robots);
gtsam::Values distributed;
std::vector<gtsam::GraphAndValues> graph_and_values_vec;
int number_of_separators = 0;
int number_of_outliers_not_rejected = 0;
for (const auto& i : robots) {
std::string dataset_file_name = log_folder_ + std::to_string(i) + "_optimized.g2o";
if (!boost::filesystem::exists(dataset_file_name)) {
if (debug_level_ >= 3) {
std::cout << "Robot " << robot_id_ << " Evaluation : Other files do not exist yet" << std::endl;
}
RemoveRejectedKeys();
return false; // File does not exists yet
}
gtsam::GraphAndValues graph_and_values = gtsam::readG2o(dataset_file_name, true);
if (graph_and_values.second->size() < expected_size-2) {
if (debug_level_ >= 3) {
std::cout << "Robot " << robot_id_ << " Evaluation : Other file too small expected size=" << expected_size << ", actual size=" << graph_and_values.second->size() << std::endl;
}
RemoveRejectedKeys();
return false; // File not updated yet
}
for (const gtsam::Values::ConstKeyValuePair &key_value: *graph_and_values.second) {
gtsam::Key key = key_value.key;
if (!distributed.exists(key)) {
distributed.insert(key, (*graph_and_values.second).at<gtsam::Pose3>(key));
}
}
std::vector<int> factors_to_remove;
int current_index = 0;
for (const auto &factor: *graph_and_values.first) {
boost::shared_ptr<gtsam::BetweenFactor<gtsam::Pose3> > pose3_between = boost::dynamic_pointer_cast<gtsam::BetweenFactor<gtsam::Pose3> >(factor);
auto robot_1_id = gtsam::Symbol(pose3_between->key1()).chr();
auto robot_2_id = gtsam::Symbol(pose3_between->key2()).chr();
if (robot_1_id != robot_2_id) {
if (robots.find(((int)robot_1_id-97)) != robots.end() && robots.find(((int)robot_2_id-97)) != robots.end()) {
number_of_separators++;
if (aggregated_outliers_keys.find(std::make_pair(pose3_between->key1(), pose3_between->key2())) != aggregated_outliers_keys.end()) {
number_of_outliers_not_rejected++;
}
} else {
factors_to_remove.emplace_back(current_index);
}
}
current_index++;
}
dataset_file_name = log_folder_ + std::to_string(i) + "_initial.g2o";
graph_and_values = gtsam::readG2o(dataset_file_name, true);
// Remove factor involving values from robots not in communication range
int number_of_factors_removed = 0;
for (const auto & factor : factors_to_remove){
int factor_index = factor - number_of_factors_removed;
graph_and_values.first->erase(graph_and_values.first->begin()+factor_index);
number_of_factors_removed++;
}
graph_and_values_vec.push_back(graph_and_values);
}
gtsam::GraphAndValues full_graph_and_values = distributed_mapper::evaluation_utils::readFullGraph(robots.size(), graph_and_values_vec);
try {
// Compute Error
gtsam::noiseModel::Diagonal::shared_ptr evaluation_model = gtsam::noiseModel::Isotropic::Variance(6, 1e-12);
auto errors = distributed_mapper::evaluation_utils::evaluateEstimates(robots.size(),
full_graph_and_values,
evaluation_model,
chordal_graph_noise_model_,
false,
distributed,
(bool) debug_level_);
// Gather info on outliers rejection
double total_number_of_separators_rejected_on_all_robots = 0;
for (const auto& i : robots) {
std::string separators_rejected_file_name = log_folder_ + std::to_string(i) + "_number_of_separators_rejected.g2o";
std::ifstream separators_rejected_file(separators_rejected_file_name);
int number_of_separators_rejected = 0;
separators_rejected_file >> number_of_separators_rejected;
total_number_of_separators_rejected_on_all_robots += number_of_separators_rejected;
separators_rejected_file.close();
}
total_number_of_separators_rejected_on_all_robots /= 2;
number_of_separators /= 2;
auto inliers_outliers_added = CountInliersAndOutliers(robots);
number_of_outliers_not_rejected /= 2;
// Write results to csv
std::ofstream error_file;
error_file.open(error_file_name_, std::ios::out | std::ios::app);
auto number_of_poses = optimizer_->numberOfPosesInCurrentEstimate();
error_file << robots.size() << "\t" << number_of_poses << "\t" << number_of_separators << "\t" << outlier_period_ << std::boolalpha
<< "\t" << incremental_solving_ << "\t" << rotation_noise_std_ << "\t" << translation_noise_std_
<< "\t" << rotation_estimate_change_threshold_ << "\t" << pose_estimate_change_threshold_
<< "\t" << optimizer_period_ << "\t" << pcm_threshold_
<< "\t" << std::get<0>(errors) << "\t" << std::get<1>(errors) << "\t" << std::get<2>(errors)
<< "\t" << current_rotation_iteration_ << "\t" << current_pose_iteration_
<< "\t" << inliers_outliers_added.first
<< "\t" << inliers_outliers_added.second
<< "\t" << total_number_of_separators_rejected_on_all_robots
<< "\t" << number_of_outliers_not_rejected
<< "\n";
error_file.close();
ComputeCentralizedEstimate("");
ComputeCentralizedEstimate("_no_filtering");
RemoveRejectedKeys();
return std::abs(std::get<0>(errors) - std::get<1>(errors)) < 0.1;
} catch(...) {
RemoveRejectedKeys();
return false;
}
}
/****************************************/
/****************************************/
void BuzzSLAMDataset::ComputeCentralizedEstimate(const std::string& centralized_extension) {
// Initialize the set of robots on which to evaluate
std::set<int> robots;
for (int i = 0; i < number_of_robots_; i++) {
robots.insert(i);
}
// Aggregate estimates from all the robots
std::vector<gtsam::GraphAndValues> graph_and_values_vec;
for (const auto& i : robots) {
std::string dataset_file_name = log_folder_ + std::to_string(i) + "_initial_centralized" + centralized_extension + ".g2o";
if (boost::filesystem::exists(dataset_file_name)) {
gtsam::GraphAndValues graph_and_values = gtsam::readG2o(dataset_file_name, true);
graph_and_values_vec.push_back(graph_and_values);
}
}
gtsam::GraphAndValues full_graph_and_values = distributed_mapper::evaluation_utils::readFullGraph(graph_and_values_vec.size(), graph_and_values_vec);
gtsam::noiseModel::Diagonal::shared_ptr evaluation_model = gtsam::noiseModel::Isotropic::Variance(6, 1e-12);
std::pair<gtsam::Values, gtsam::Values> estimates = distributed_mapper::evaluation_utils::centralizedEstimates(full_graph_and_values,
evaluation_model,
chordal_graph_noise_model_,
false);
// Split estimates
std::map<int, gtsam::Values> centralized_values_by_robots;
for (const auto& i : robots) {
centralized_values_by_robots.insert(std::make_pair(i, gtsam::Values()));
}
for (const gtsam::Values::ConstKeyValuePair &key_value : estimates.first) {
int value_robot_id = (int)(gtsam::Symbol(key_value.key).chr() - 97);
centralized_values_by_robots[value_robot_id].insert(key_value.key, key_value.value);
}
std::map<int, gtsam::Values> centralized_GN_values_by_robots;
for (const auto& i : robots) {
centralized_GN_values_by_robots.insert(std::make_pair(i, gtsam::Values()));
}
for (const gtsam::Values::ConstKeyValuePair &key_value : estimates.second) {
int value_robot_id = (int)(gtsam::Symbol(key_value.key).chr() - 97);
centralized_GN_values_by_robots[value_robot_id].insert(key_value.key, key_value.value);
}
for (const auto& i : robots) {
std::string centralized_file_name = log_folder_ + std::to_string(i) + "_centralized" + centralized_extension + ".g2o";
gtsam::writeG2o(gtsam::NonlinearFactorGraph(), centralized_values_by_robots[i], centralized_file_name);
centralized_file_name = log_folder_ + std::to_string(i) + "_centralized_GN" + centralized_extension + ".g2o";
gtsam::writeG2o(gtsam::NonlinearFactorGraph(), centralized_GN_values_by_robots[i], centralized_file_name);
}
}
/****************************************/
/****************************************/
void BuzzSLAMDataset::ComputeCentralizedEstimateIncremental(std::set<int> robots, const std::string& centralized_extension) {
// Aggregate estimates from all the robots
std::vector<gtsam::GraphAndValues> graph_and_values_vec;
std::string dataset_file_name = log_folder_ + std::to_string(prior_owner_) + "_initial_centralized" + centralized_extension + "_incremental.g2o";
if (boost::filesystem::exists(dataset_file_name)) {
gtsam::GraphAndValues graph_and_values = gtsam::readG2o(dataset_file_name, true);
graph_and_values_vec.push_back(graph_and_values);
}
for (const auto& i : robots) {
if (i != prior_owner_){
dataset_file_name = log_folder_ + std::to_string(i) + "_initial_centralized" + centralized_extension + "_incremental.g2o";
if (boost::filesystem::exists(dataset_file_name)) {
gtsam::GraphAndValues graph_and_values = gtsam::readG2o(dataset_file_name, true);
graph_and_values_vec.push_back(graph_and_values);
}
}
}
gtsam::GraphAndValues full_graph_and_values = distributed_mapper::evaluation_utils::readFullGraph(graph_and_values_vec);
gtsam::noiseModel::Diagonal::shared_ptr evaluation_model = gtsam::noiseModel::Isotropic::Variance(6, 1e-12);
std::pair<gtsam::Values, gtsam::Values> estimates = distributed_mapper::evaluation_utils::centralizedEstimates(full_graph_and_values,
evaluation_model,
chordal_graph_noise_model_,
false);
// Split estimates
std::map<int, gtsam::Values> centralized_values_by_robots;
for (const auto& i : robots) {
centralized_values_by_robots.insert(std::make_pair(i, gtsam::Values()));
}
// Get anchor offset
gtsam::Point3 anchor_offset_translation = gtsam::Point3();
gtsam::Rot3 anchor_offset_rotation = gtsam::Rot3();
dataset_file_name = log_folder_ + std::to_string(prior_owner_) + "_centralized" + centralized_extension + "_incremental.g2o";
if (boost::filesystem::exists(dataset_file_name)) {
gtsam::GraphAndValues graph_and_values = gtsam::readG2o(dataset_file_name, true);
gtsam::Key first_key = gtsam::KeyVector(graph_and_values.second->keys()).at(0);
anchor_offset_translation = graph_and_values.second->at<gtsam::Pose3>(first_key).translation();
anchor_offset_rotation = graph_and_values.second->at<gtsam::Pose3>(first_key).rotation();
}
for (const gtsam::Values::ConstKeyValuePair &key_value : estimates.first) {
int value_robot_id = (int)(gtsam::Symbol(key_value.key).chr() - 97);
if (value_robot_id == prior_owner_) {
gtsam::Pose3 value = key_value.value.cast<gtsam::Pose3>();
anchor_offset_translation = anchor_offset_translation - value.translation();
anchor_offset_rotation = anchor_offset_rotation * value.rotation().inverse();
break;
}
}
for (const gtsam::Values::ConstKeyValuePair &key_value : estimates.first) {
int value_robot_id = (int)(gtsam::Symbol(key_value.key).chr() - 97);
if (robots.find(value_robot_id) != robots.end()) {
gtsam::Key new_key = gtsam::Symbol(((char) value_robot_id + 97), gtsam::Symbol(key_value.key).index());
gtsam::Pose3 value = key_value.value.cast<gtsam::Pose3>();
gtsam::Pose3 new_value = gtsam::Pose3(value.rotation(), value.translation() + anchor_offset_translation);
new_value = new_value * gtsam::Pose3(anchor_offset_rotation, gtsam::Point3());
centralized_values_by_robots[value_robot_id].insert(new_key, new_value);
}
}
std::map<int, gtsam::Values> centralized_GN_values_by_robots;
for (const auto& i : robots) {
centralized_GN_values_by_robots.insert(std::make_pair(i, gtsam::Values()));
}
anchor_offset_translation = gtsam::Point3();
dataset_file_name = log_folder_ + std::to_string(prior_owner_) + "_centralized_GN" + centralized_extension + "_incremental.g2o";
if (boost::filesystem::exists(dataset_file_name)) {
gtsam::GraphAndValues graph_and_values = gtsam::readG2o(dataset_file_name, true);
gtsam::Key first_key = gtsam::KeyVector(graph_and_values.second->keys()).at(0);
anchor_offset_translation = graph_and_values.second->at<gtsam::Pose3>(first_key).translation();
}
for (const gtsam::Values::ConstKeyValuePair &key_value : estimates.second) {
int value_robot_id = (int)(gtsam::Symbol(key_value.key).chr() - 97);
if (value_robot_id == prior_owner_) {
gtsam::Pose3 value = key_value.value.cast<gtsam::Pose3>();
anchor_offset_translation = anchor_offset_translation - value.translation();
break;
}
}
for (const gtsam::Values::ConstKeyValuePair &key_value : estimates.second) {
int value_robot_id = (int)(gtsam::Symbol(key_value.key).chr() - 97);
if (robots.find(value_robot_id) != robots.end()) {
gtsam::Key new_key = gtsam::Symbol(((char) value_robot_id + 97), gtsam::Symbol(key_value.key).index());
gtsam::Pose3 value = key_value.value.cast<gtsam::Pose3>();
gtsam::Pose3 new_value = gtsam::Pose3(value.rotation(), value.translation() + anchor_offset_translation);
centralized_GN_values_by_robots[value_robot_id].insert(new_key, new_value);
}
}
std::string centralized_file_name = log_folder_ + std::to_string(robot_id_) + "_centralized" + centralized_extension + "_incremental.g2o";
gtsam::writeG2o(gtsam::NonlinearFactorGraph(), centralized_values_by_robots[robot_id_], centralized_file_name);
centralized_file_name = log_folder_ + std::to_string(robot_id_) + "_centralized_GN" + centralized_extension + "_incremental.g2o";
gtsam::writeG2o(gtsam::NonlinearFactorGraph(), centralized_GN_values_by_robots[robot_id_], centralized_file_name);
IncrementalInitialGuessUpdate(centralized_values_by_robots[robot_id_], poses_initial_guess_centralized_incremental_updates_);
}
/****************************************/
/****************************************/
void BuzzSLAMDataset::AbortOptimization(const bool& log_info){
BuzzSLAM::AbortOptimization(log_info);
if (log_info) {
// Initialize the set of robots on which to evaluate
std::set<int> robots = neighbors_within_communication_range_;
robots.insert(robot_id_);
auto aggregated_outliers_keys = AggregateOutliersKeys(robots);
int number_of_separators = 0;
int number_of_outliers_not_rejected = 0;
for (const auto& i : robots) {
std::string dataset_file_name = log_folder_ + std::to_string(i) + "_initial.g2o";
if (!boost::filesystem::exists(dataset_file_name)) {
return; // File does not exists yet
}
gtsam::GraphAndValues graph_and_values = gtsam::readG2o(dataset_file_name, true);
int current_index = 0;
for (const auto &factor: *graph_and_values.first) {
boost::shared_ptr<gtsam::BetweenFactor<gtsam::Pose3> > pose3_between = boost::dynamic_pointer_cast<gtsam::BetweenFactor<gtsam::Pose3> >(factor);
auto robot_1_id = gtsam::Symbol(pose3_between->key1()).chr();
auto robot_2_id = gtsam::Symbol(pose3_between->key2()).chr();
if (robot_1_id != robot_2_id) {
if (robots.find(((int)robot_1_id-97)) != robots.end() && robots.find(((int)robot_2_id-97)) != robots.end()) {
number_of_separators++;
if (aggregated_outliers_keys.find(std::make_pair(pose3_between->key1(), pose3_between->key2())) != aggregated_outliers_keys.end()) {
number_of_outliers_not_rejected++;
}
}
}
current_index++;
}
}
// Gather info on outliers rejection
double total_number_of_separators_rejected_on_all_robots = 0;
for (const auto& i : robots) {
std::string separators_rejected_file_name = log_folder_ + std::to_string(i) + "_number_of_separators_rejected.g2o";
std::ifstream separators_rejected_file(separators_rejected_file_name);
int number_of_separators_rejected = 0;
separators_rejected_file >> number_of_separators_rejected;
total_number_of_separators_rejected_on_all_robots += number_of_separators_rejected;
separators_rejected_file.close();
}
total_number_of_separators_rejected_on_all_robots /= 2;
number_of_separators /= 2;
auto inliers_outliers_added = CountInliersAndOutliers(robots);
// Write results to csv
std::ofstream error_file;
error_file.open(error_file_name_, std::ios::out | std::ios::app);
auto number_of_poses = optimizer_->numberOfPosesInCurrentEstimate();
std::string place_holder = "Aborted";
error_file << robots.size() << "\t" << number_of_poses << "\t" << place_holder << "\t" << outlier_period_ << std::boolalpha
<< "\t" << incremental_solving_ << "\t" << rotation_noise_std_ << "\t" << translation_noise_std_
<< "\t" << rotation_estimate_change_threshold_ << "\t" << pose_estimate_change_threshold_
<< "\t" << optimizer_period_ << "\t" << pcm_threshold_
<< "\t" << place_holder << "\t" << place_holder << "\t" << place_holder
<< "\t" << current_rotation_iteration_ << "\t" << current_pose_iteration_
<< "\t" << inliers_outliers_added.first
<< "\t" << inliers_outliers_added.second
<< "\t" << std::round(total_number_of_separators_rejected_on_all_robots)
<< "\t" << number_of_outliers_not_rejected
<< "\n";
error_file.close();
}
}
} | 49.655514 | 292 | 0.647784 | SnowCarter |
97c0da6cbda64060a988e4b5a102a8446fb342aa | 1,465 | hpp | C++ | Runtime/MP1/CCredits.hpp | RetroView/RetroCommon | a413a010b50a53ebc6b0c726203181fc179d3370 | [
"MIT"
] | 267 | 2016-03-10T21:59:16.000Z | 2021-03-28T18:21:03.000Z | Runtime/MP1/CCredits.hpp | cobalt2727/metaforce | 3bb05c0ee5dd9b1b8eaa861fc49713aef62c844a | [
"MIT"
] | 129 | 2016-03-12T10:17:32.000Z | 2021-04-05T20:45:19.000Z | Runtime/MP1/CCredits.hpp | cobalt2727/metaforce | 3bb05c0ee5dd9b1b8eaa861fc49713aef62c844a | [
"MIT"
] | 31 | 2016-03-20T00:20:11.000Z | 2021-03-10T21:14:11.000Z | #pragma once
#include "Runtime/CIOWin.hpp"
#include "Runtime/CToken.hpp"
#include "Runtime/Audio/CStaticAudioPlayer.hpp"
#include "Runtime/Camera/CCameraFilter.hpp"
#include "zeus/CVector2i.hpp"
namespace metaforce {
class CGuiTextSupport;
class CStringTable;
class CRasterFont;
class CMoviePlayer;
struct CFinalInput;
namespace MP1 {
class CCredits : public CIOWin {
u32 x14_ = 0;
TLockedToken<CStringTable> x18_creditsTable;
TLockedToken<CRasterFont> x20_creditsFont;
std::unique_ptr<CMoviePlayer> x28_;
std::unique_ptr<CStaticAudioPlayer> x2c_;
std::vector<std::pair<std::unique_ptr<CGuiTextSupport>, zeus::CVector2i>> x30_text;
int x44_textSupport = 0;
float x48_ = 0.f;
float x4c_ = 0.f;
float x50_ = 8.f;
float x54_;
float x58_ = 0.f;
bool x5c_24_ : 1 = false;
bool x5c_25_ : 1 = false;
bool x5c_26_ : 1 = false;
bool x5c_27_ : 1 = true;
bool x5c_28_ : 1 = false;
void DrawVideo();
void DrawText();
static void DrawText(CGuiTextSupport&, const zeus::CVector3f& translation);
CCameraFilterPassPoly m_videoFilter;
CCameraFilterPassPoly m_textFilter;
public:
CCredits();
EMessageReturn OnMessage(const CArchitectureMessage&, CArchitectureQueue&) override;
bool GetIsContinueDraw() const override { return false; }
void Draw() override;
EMessageReturn Update(float, CArchitectureQueue& queue);
EMessageReturn ProcessUserInput(const CFinalInput& input);
};
} // namespace MP1
} // namespace metaforce
| 27.12963 | 86 | 0.750853 | RetroView |
97c7893ecd1d138f17c1405ee6ac369f1073a86f | 6,689 | cc | C++ | src/relay/qnn/csi_op/arg.cc | T-head-Semi/tvm | c1b8e06685c92fb7cacbe989e147b0622aee4503 | [
"Apache-2.0"
] | 4 | 2021-10-19T06:22:55.000Z | 2022-03-17T22:55:12.000Z | src/relay/qnn/csi_op/arg.cc | T-head-Semi/tvm | c1b8e06685c92fb7cacbe989e147b0622aee4503 | [
"Apache-2.0"
] | null | null | null | src/relay/qnn/csi_op/arg.cc | T-head-Semi/tvm | c1b8e06685c92fb7cacbe989e147b0622aee4503 | [
"Apache-2.0"
] | 2 | 2021-10-19T03:28:37.000Z | 2022-03-17T22:55:14.000Z | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/*!
* \file src/relay/qnn/op/mul.cc
* \brief QNN mul operator.
*/
#include <tvm/relay/analysis.h>
#include <tvm/relay/op_attr_types.h>
#include <tvm/relay/qnn/attrs.h>
#include "../op/op_common.h"
#include "../utils.h"
namespace tvm {
namespace relay {
namespace qnn {
TVM_REGISTER_NODE_TYPE(QnnCSIReduceAttrs);
inline std::vector<int64_t> GetCSIReduceAxes(const uint32_t indim, const Array<Integer>& inaxis,
bool exclude) {
if (!inaxis.defined()) {
std::vector<int64_t> r_axes(indim);
for (uint32_t i = 0; i < indim; i++) {
r_axes[i] = 0;
}
return r_axes;
}
std::vector<int64_t> in_axes;
for (auto i : inaxis) {
int64_t axis = i->value;
if (axis < 0) {
axis = axis + indim;
}
// Check out of bounds error
CHECK(axis >= 0) << "Axis out of bounds in reduce operator.";
CHECK(axis < indim) << "Axis out of bounds in reduce operator.";
in_axes.push_back(axis);
}
CHECK(in_axes[in_axes.size() - 1] < indim)
<< "Reduction axis " << in_axes[in_axes.size() - 1] << " exceeds input dimensions " << indim;
std::sort(in_axes.begin(), in_axes.end());
if (!exclude) {
return in_axes;
}
auto r_size = indim - in_axes.size();
std::vector<int64_t> r_axes(r_size);
for (uint32_t i = 0, j = 0, k = 0; i < indim; ++i) {
if (j < in_axes.size() && in_axes[j] == i) {
++j;
continue;
}
r_axes[k++] = i;
}
return r_axes;
}
inline std::vector<IndexExpr> ReduceShapeImpl(const std::vector<IndexExpr>& in_shape,
const QnnCSIReduceAttrs* param,
const TypeReporter& reporter) {
uint32_t indim = in_shape.size();
Array<Integer> inaxis = param->axis;
bool exclude = param->exclude;
auto r_axes = GetCSIReduceAxes(indim, inaxis, exclude);
if (!r_axes.size()) {
return in_shape;
}
auto max_shape = tir::make_const(DataType::Int(64), 1);
bool is_dynamic_input = false;
for (int64_t axis : r_axes) {
if (in_shape[axis].as<IntImmNode>()) {
max_shape *= in_shape[axis];
} else {
is_dynamic_input = true;
break;
}
}
if (is_dynamic_input) {
CHECK(reporter->Assert(max_shape <
tir::make_const(DataType::Int(64), std::numeric_limits<int32_t>::max())))
<< "The maximum possible index of reduced shape cannot be more than int32 max.";
}
if (param->keepdims) {
std::vector<IndexExpr> oshape(in_shape);
for (unsigned i = 0, j = 0; i < indim; ++i) {
if (j >= r_axes.size() || !(r_axes[j] == i)) {
continue;
}
oshape[i] = 1;
++j;
}
return oshape;
} else {
auto osize = indim - r_axes.size();
std::vector<IndexExpr> oshape(osize);
for (unsigned i = 0, j = 0, k = 0; i < indim; ++i) {
if (j < r_axes.size() && (r_axes[j] == i)) {
++j;
continue;
}
oshape[k++] = in_shape[i];
}
return oshape;
}
}
bool QnnCSIArgReduceRel(const Array<Type>& types, int num_inputs, const Attrs& attrs,
const TypeReporter& reporter) {
CHECK_EQ(types.size(), 2);
const auto* data = types[0].as<TensorTypeNode>();
if (data == nullptr) return false;
CHECK(static_cast<int>(data->shape.size()) != 0);
std::vector<IndexExpr> in_shape(data->shape.begin(), data->shape.end());
const QnnCSIReduceAttrs* param = attrs.as<QnnCSIReduceAttrs>();
CHECK(param != nullptr);
// assign output type and shape
auto oshape = ReduceShapeImpl(in_shape, param, reporter);
reporter->Assign(types[1], TensorType(oshape, DataType::Int(32)));
return true;
}
// QNN argmax operator.
Expr MakeQnnCSIArgmax(Expr data, Array<Integer> axis, bool keepdims, bool exclude,
DataType out_dtype, Array<Array<IndexExpr>> q_params, String layer_name) {
auto attrs = make_object<QnnCSIReduceAttrs>();
attrs->axis = axis;
attrs->keepdims = keepdims;
attrs->exclude = exclude;
attrs->out_dtype = out_dtype;
attrs->q_params = std::move(q_params);
attrs->layer_name = std::move(layer_name);
static const Op& op = Op::Get("qnn.csi.argmax");
return Call(op, {data}, Attrs(attrs), {});
}
RELAY_REGISTER_OP("qnn.csi.argmax")
.describe(R"code(Returns the argmax input array.)code" TVM_ADD_FILELINE)
.set_attrs_type<QnnCSIReduceAttrs>()
.set_num_inputs(1)
.add_argument("data", "Tensor", "The quantized data tensor.")
.add_argument("axis", "Array", "axis.")
.set_support_level(11)
.add_type_rel("QnnCSIArgReduceRel", QnnCSIArgReduceRel)
.set_attr<TOpPattern>("TOpPattern", kOpaque);
TVM_REGISTER_GLOBAL("relay.qnn.op._make.CSIArgmax").set_body_typed(MakeQnnCSIArgmax);
// QNN argmin operator.
Expr MakeQnnCSIArgmin(Expr data, Array<Integer> axis, bool keepdims, bool exclude,
DataType out_dtype, Array<Array<IndexExpr>> q_params, String layer_name) {
auto attrs = make_object<QnnCSIReduceAttrs>();
attrs->axis = axis;
attrs->keepdims = keepdims;
attrs->exclude = exclude;
attrs->out_dtype = out_dtype;
attrs->q_params = std::move(q_params);
attrs->layer_name = std::move(layer_name);
static const Op& op = Op::Get("qnn.csi.argmin");
return Call(op, {data}, Attrs(attrs), {});
}
RELAY_REGISTER_OP("qnn.csi.argmin")
.describe(R"code(Returns the argmin input array.)code" TVM_ADD_FILELINE)
.set_attrs_type<QnnCSIReduceAttrs>()
.set_num_inputs(1)
.add_argument("data", "Tensor", "The quantized data tensor.")
.add_argument("axis", "Array", "axis.")
.set_support_level(11)
.add_type_rel("QnnCSIArgReduceRel", QnnCSIArgReduceRel)
.set_attr<TOpPattern>("TOpPattern", kOpaque);
TVM_REGISTER_GLOBAL("relay.qnn.op._make.CSIArgmin").set_body_typed(MakeQnnCSIArgmin);
} // namespace qnn
} // namespace relay
} // namespace tvm
| 31.701422 | 100 | 0.645687 | T-head-Semi |
97c8e05a5d28adae9c8b1bc238d66655da40cea0 | 11,432 | cpp | C++ | src/Plugins/napoleon/NearestEnemyComponent.cpp | pgruenbacher/Menge | efd577bf5d318b01b2888d281258c8b7b0a7e4fe | [
"Apache-2.0"
] | null | null | null | src/Plugins/napoleon/NearestEnemyComponent.cpp | pgruenbacher/Menge | efd577bf5d318b01b2888d281258c8b7b0a7e4fe | [
"Apache-2.0"
] | null | null | null | src/Plugins/napoleon/NearestEnemyComponent.cpp | pgruenbacher/Menge | efd577bf5d318b01b2888d281258c8b7b0a7e4fe | [
"Apache-2.0"
] | null | null | null | /*
License
Menge
Copyright © and trademark ™ 2012-14 University of North Carolina at Chapel Hill.
All rights reserved.
Permission to use, copy, modify, and distribute this software and its documentation
for educational, research, and non-profit purposes, without fee, and without a
written agreement is hereby granted, provided that the above copyright notice,
this paragraph, and the following four paragraphs appear in all copies.
This software program and documentation are copyrighted by the University of North
Carolina at Chapel Hill. The software program and documentation are supplied "as is,"
without any accompanying services from the University of North Carolina at Chapel
Hill or the authors. The University of North Carolina at Chapel Hill and the
authors do not warrant that the operation of the program will be uninterrupted
or error-free. The end-user understands that the program was developed for research
purposes and is advised not to rely exclusively on the program for any reason.
IN NO EVENT SHALL THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL OR THE AUTHORS
BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
DOCUMENTATION, EVEN IF THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL OR THE
AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL AND THE AUTHORS SPECIFICALLY
DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND ANY STATUTORY WARRANTY
OF NON-INFRINGEMENT. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND
THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL AND THE AUTHORS HAVE NO OBLIGATIONS
TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
Any questions or comments should be sent to the authors {menge,geom}@cs.unc.edu
*/
// #include "MengeCore/BFSM/VelocityComponents/VelCompGoal.h"
#include "NearestEnemyComponent.h"
#include "MengeCore/resources/Resource.h"
#include "MengeCore/Core.h"
#include "MengeCore/Agents/BaseAgent.h"
#include "MengeCore/Agents/PrefVelocity.h"
#include "MengeCore/BFSM/Goals/Goal.h"
#include "MengeCore/Runtime/os.h"
#include "NearestEnemTask.h"
const float sumNearAgentWeights(const std::vector<Menge::Agents::NearAgent>& nearAgents, float checkDist = 3.0) {
// return nearAgents.size();
// WTF C++, if I don't set to 0.0, then it defaults to whatever previous value was!??
// Apparently uninitalized variables don't default to zero...
// return nearAgents.size();
// const float meleeDist = 3.0;
float result = 0.0;
// std::cout << "RESULT?" << result << std::endl;
for (Menge::Agents::NearAgent agent : nearAgents) {
// result += agent.distanceSquared;
if (checkDist < agent.distanceSquared) {
continue;
}
// std::cout << "V " << (agent.agent->_neighborDist * agent.agent->_neighborDist) << " " << agent.distanceSquared << std::endl;
result += 1.0f;
}
// std::cout << "RESULT" << result << " " << nearAgents.size() << std::endl;
return result;
}
namespace Napoleon {
using Menge::logger;
/////////////////////////////////////////////////////////////////////
// Implementation of GoalVelComponent
/////////////////////////////////////////////////////////////////////
const std::string NearestEnemComponent::NAME = "enemy_near_comp";
/////////////////////////////////////////////////////////////////////
void NearestEnemComponent::onEnter(BaseAgent* agent) {
// _lock.lockWrite();
// // _formation->addAgent(agent);
// _agents[agent->_id] = agent;
// _lock.releaseWrite();
NearestEnemTask* task = NearestEnemTask::getSingleton();
task->addAgent(agent->_id);
}
void NearestEnemComponent::onExit(BaseAgent* agent) {
// _lock.lockWrite();
// // _formation->addAgent(agent);
// _agents[agent->_id] = agent;
// _lock.releaseWrite();
NearestEnemTask* task = NearestEnemTask::getSingleton();
task->removeAgent(agent->_id);
}
/////////////////////////////////////////////////////////////////////
NearestEnemComponent::NearestEnemComponent() : VelComponent(),
_targetMethod(MELEE),
_actionType(IDLE),
_slowToArrive(false)
{
}
void NearestEnemComponent::setIdleVelocity(const BaseAgent* enem, const BaseAgent * agent, const Goal * goal,
PrefVelocity & pVel ) const {
using Menge::SIM_TIME_STEP;
Vector2 target = enem->_pos;
goal->setDirections( agent->_pos, agent->_radius, pVel );
// speed
Vector2 goalPoint = pVel.getTarget();
Vector2 disp = goalPoint - agent->_pos;
const float distSq = absSq( disp );
float speed = agent->_prefSpeed;
if ( distSq <= 0.0001f ) {
// I've basically arrived -- speed should be zero.
speed = 0.f;
} else {
const float speedSq = speed * speed;
const float TS_SQD = SIM_TIME_STEP * SIM_TIME_STEP;
if ( distSq / speedSq < TS_SQD ) {
// The distance is less than I would travel in a single time step.
speed = sqrtf( distSq ) / SIM_TIME_STEP;
}
}
pVel.setSpeed( speed );
// also make sure target is set for orientation.
pVel.setTarget( target );
}
void NearestEnemComponent::setWithdrawingVelocity(const BaseAgent* enem,
const BaseAgent* agent,
PrefVelocity& pVel,
float distSq) const {
Vector2 target = enem->_pos;
Vector2 disp = target - agent->_pos;
Vector2 dir(0.0, 0.0);
if ( distSq > 1e-8 ) {
// Distant enough that I can normalize the direction.
dir.set( disp / sqrtf( distSq ) );
} else {
dir.set( 0.f, 0.f );
}
pVel.setSingle(-dir);
pVel.setSpeed(0.1);
pVel.setTarget(target);
return;
}
void NearestEnemComponent::setAdvancingVelocity(const BaseAgent* enem,
const BaseAgent* agent,
PrefVelocity& pVel,
float distSq) const {
Vector2 target = enem->_pos;
Vector2 disp = target - agent->_pos;
Vector2 dir(0.0, 0.0);
if ( distSq > 1e-8 ) {
// Distant enough that I can normalize the direction.
dir.set( disp / sqrtf( distSq ) );
} else {
dir.set( 0.f, 0.f );
}
pVel.setTarget(target);
float speed = agent->_prefSpeed;
if (distSq <= (agent->getMeleeRange() - 0.2) && _slowToArrive) {
// I've basically arrived -- speed should be zero.
speed = 0.f;
} else {
const float speedSq = speed * speed;
const float TS_SQD = Menge::SIM_TIME_STEP * Menge::SIM_TIME_STEP;
if (distSq / speedSq < TS_SQD && _slowToArrive) {
// The distance is less than I would travel in a single time step.
speed = sqrtf(distSq) / Menge::SIM_TIME_STEP;
} else {
// std:: cout << "?? " << distSq / speedSq << " " << TS_SQD << " " <<
// SIM_TIME_STEP << std::endl; speed = agent->_prefSpeed;
}
}
// std::cout << "SPEED " << speed << std::endl;
pVel.setSingle(dir);
pVel.setSpeed(speed);
}
const NearAgent NearestEnemComponent::getTargetEnem(const BaseAgent* agent) const {
// float distSq = 1000.f * 1000.f;
// NearAgent targetEnem(distSq, 0x0);
// for (Menge::Agents::NearAgent enem : agent->_nearEnems) {
// if (enem.distanceSquared < distSq) {
// distSq = enem.distanceSquared;
// targetEnem = enem;
// }
// }
const NearestEnemTask* task = NearestEnemTask::getSingleton();
NearAgent d(100, 0x0);
task->getCurrentTarget(agent, d);
return d;
}
/////////////////////////////////////////////////////////////////////
void NearestEnemComponent::setPrefVelocity( const BaseAgent * agent, const Goal * goal,
PrefVelocity & pVel ) const {
bool modify = agent->_nearEnems.size() > 0;
Vector2 target(0.f, 0.f);
if ( !modify ) {
// pVel.setSpeed(agent->_prefSpeed);
// Vector2 returnToOrig = (agent->_pos) * -1;
// returnToOrig.normalize();
// pVel.setSingle(returnToOrig);
// std::cout << "no modify! fix! " << agent->_id << "GOAL" << goal << " " << std::endl;
// return setIdleVelocity(agent, goal, pVel);
goal->setDirections(agent->_pos, agent->_radius, pVel);
// goal.
return;
}
const NearestEnemData targetEnem = getTargetEnem(agent);
if (targetEnem.agent == 0x0) return;
// target = targetEnem.agent->_pos;
float distSq = targetEnem.distanceSquared;
if (_actionType == WITHDRAWING) {
return setWithdrawingVelocity(targetEnem.agent, agent, pVel, distSq);
} else if (_actionType == IDLE) {
return setIdleVelocity(targetEnem.agent, agent, goal, pVel);
} else {
return setAdvancingVelocity(targetEnem.agent, agent, pVel, distSq);
}
}
Task * NearestEnemComponent::getTask(){
return NearestEnemTask::getSingleton();
};
/////////////////////////////////////////////////////////////////////
NearestEnemComponentFactory::NearestEnemComponentFactory() : VelCompFactory() {
_methodID = _attrSet.addStringAttribute("method", true /* required */);
_targetMethodID = _attrSet.addStringAttribute("target", false, "melee");
_slowToArriveID = _attrSet.addBoolAttribute("slow_to_arrive", false, false);
}
/////////////////////////////////////////////////////////////////////
bool NearestEnemComponentFactory::setFromXML( VelComponent * component, TiXmlElement * node,
const std::string & behaveFldr ) const {
NearestEnemComponent * nearestEnemComp = dynamic_cast<NearestEnemComponent *>(component);
if ( ! VelCompFactory::setFromXML( component, node, behaveFldr ) ) return false;
assert( nearestEnemComp != 0x0 &&
"Trying to set property component properties on an incompatible object" );
if (_attrSet.getString(_methodID).empty()) {
logger << Logger::ERR_MSG << "Require method for velocity component";
logger.close();
throw Menge::BFSM::VelCompFatalException( "Require method for velocity component." );
}
std::string _typeString = _attrSet.getString(_methodID);
std::string _targetMethod = _attrSet.getString(_targetMethodID);
if (_targetMethod == "melee") {
nearestEnemComp->_targetMethod = MELEE;
} else if (_targetMethod == "pike") {
nearestEnemComp->_targetMethod = PIKE;
} else if (_targetMethod == "aiming") {
nearestEnemComp->_targetMethod = AIMING;
}
if (_typeString == "advancing") {
nearestEnemComp->_actionType = NearestEnemComponent::ADVANCING;
} else if (_typeString == "withdrawing") {
nearestEnemComp->_actionType = NearestEnemComponent::WITHDRAWING;
} else if (_typeString == "idle") {
nearestEnemComp->_actionType = NearestEnemComponent::IDLE;
} else {
logger << Logger::ERR_MSG << "Should be advancing or withdrawing got: '" << _typeString << "' instead...";
return false;
}
nearestEnemComp->_slowToArrive = _attrSet.getBool(_slowToArriveID);
return true;
}
} // namespace Formations
| 39.285223 | 131 | 0.627362 | pgruenbacher |
97d56573185cbbc365c051f39548cc52558e750f | 5,477 | cpp | C++ | snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ComboBoxRenderer/cpp/form1.cpp | BohdanMosiyuk/samples | 59d435ba9e61e0fc19f5176c96b1cdbd53596142 | [
"CC-BY-4.0",
"MIT"
] | 834 | 2017-06-24T10:40:36.000Z | 2022-03-31T19:48:51.000Z | snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ComboBoxRenderer/cpp/form1.cpp | BohdanMosiyuk/samples | 59d435ba9e61e0fc19f5176c96b1cdbd53596142 | [
"CC-BY-4.0",
"MIT"
] | 7,042 | 2017-06-23T22:34:47.000Z | 2022-03-31T23:05:23.000Z | snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ComboBoxRenderer/cpp/form1.cpp | BohdanMosiyuk/samples | 59d435ba9e61e0fc19f5176c96b1cdbd53596142 | [
"CC-BY-4.0",
"MIT"
] | 1,640 | 2017-06-23T22:31:39.000Z | 2022-03-31T02:45:37.000Z | // This sample can go in ComboBoxRenderer class overview.
// - Snippet2 can go in IsSupported
// - Snippet4 can go in DrawTextBox and DrawDropDownButton
// It renders the pieces of a combo box with visual styles, provided
// that visual styles are enabled in the Display Panel.
// For simplicity, this sample does not handle run-time visual style switching.
//<Snippet0>
#using <System.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>
using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;
using namespace System::Windows::Forms::VisualStyles;
namespace ComboBoxRendererSample
{
ref class CustomComboBox: public Control
{
private:
System::Drawing::Size arrowSize;
Rectangle arrowRectangle;
Rectangle topTextBoxRectangle;
Rectangle bottomTextBoxRectangle;
ComboBoxState textBoxState;
ComboBoxState arrowState;
String^ bottomText;
bool isActivated;
int minHeight;
int minWidth;
public:
CustomComboBox() : Control()
{
minHeight = 38;
minWidth = 40;
this->Location = Point(10, 10);
this->Size = System::Drawing::Size(140, 38);
this->Font = SystemFonts::IconTitleFont;
this->Text = "Click the button";
textBoxState = ComboBoxState::Normal;
bottomText = "Using ComboBoxRenderer";
arrowState = ComboBoxState::Normal;
// Initialize the rectangles to look like the standard combo
// box control.
arrowSize = System::Drawing::Size(18, 20);
arrowRectangle = Rectangle(ClientRectangle.X +
ClientRectangle.Width - arrowSize.Width - 1,
ClientRectangle.Y + 1,
arrowSize.Width,
arrowSize.Height);
topTextBoxRectangle = Rectangle(ClientRectangle.X,
ClientRectangle.Y,
ClientRectangle.Width,
arrowSize.Height + 2);
bottomTextBoxRectangle = Rectangle(ClientRectangle.X,
ClientRectangle.Y + topTextBoxRectangle.Height,
ClientRectangle.Width,
topTextBoxRectangle.Height - 6);
}
//<Snippet4>
//<Snippet2>
// Draw the combo box in the current state.
protected:
virtual void OnPaint(PaintEventArgs^ e) override
{
Control::OnPaint(e);
if (!ComboBoxRenderer::IsSupported)
{
this->Parent->Text = "Visual Styles Disabled";
return;
}
this->Parent->Text = "CustomComboBox Enabled";
// Always draw the main text box and drop down arrow in their
// current states
ComboBoxRenderer::DrawTextBox(e->Graphics, topTextBoxRectangle,
this->Text, this->Font, textBoxState);
ComboBoxRenderer::DrawDropDownButton(e->Graphics, arrowRectangle,
arrowState);
// Only draw the bottom text box if the arrow has been clicked
if (isActivated)
{
ComboBoxRenderer::DrawTextBox(e->Graphics,
bottomTextBoxRectangle, bottomText, this->Font,
textBoxState);
}
}
//</Snippet2>
protected:
virtual void OnMouseDown(MouseEventArgs^ e) override
{
Control::OnMouseDown(e);
// Check whether the user clicked the arrow.
if (arrowRectangle.Contains(e->Location) &&
ComboBoxRenderer::IsSupported)
{
// Draw the arrow in the pressed state.
arrowState = ComboBoxState::Pressed;
// The user has activated the combo box.
if (!isActivated)
{
this->Text = "Clicked!";
textBoxState = ComboBoxState::Pressed;
isActivated = true;
}
// The user has deactivated the combo box.
else
{
this->Text = "Click here";
textBoxState = ComboBoxState::Normal;
isActivated = false;
}
// Redraw the control.
Invalidate();
}
}
//</Snippet4>
protected:
virtual void OnMouseUp(MouseEventArgs^ e) override
{
Control::OnMouseUp(e);
if (arrowRectangle.Contains(e->Location) &&
ComboBoxRenderer::IsSupported)
{
arrowState = ComboBoxState::Normal;
Invalidate();
}
}
};
ref class Form1 : public Form
{
public:
Form1() : Form()
{
this->Size = System::Drawing::Size(300, 300);
CustomComboBox^ ComboBox1 = gcnew CustomComboBox();
Controls->Add(ComboBox1);
}
};
}
[STAThread]
int main()
{
// The call to EnableVisualStyles below does not affect
// whether ComboBoxRenderer.IsSupported is true; as long as visual
// styles are enabled by the operating system, IsSupported is true.
Application::EnableVisualStyles();
Application::Run(gcnew ComboBoxRendererSample::Form1());
}
//</Snippet0>
| 31.65896 | 79 | 0.554135 | BohdanMosiyuk |
97d684525c44125b4ffe7639b450893155f795ef | 4,021 | cpp | C++ | android-31/android/hardware/camera2/params/OutputConfiguration.cpp | YJBeetle/QtAndroidAPI | 1468b5dc6eafaf7709f0b00ba1a6ec2b70684266 | [
"Apache-2.0"
] | 12 | 2020-03-26T02:38:56.000Z | 2022-03-14T08:17:26.000Z | android-31/android/hardware/camera2/params/OutputConfiguration.cpp | YJBeetle/QtAndroidAPI | 1468b5dc6eafaf7709f0b00ba1a6ec2b70684266 | [
"Apache-2.0"
] | 1 | 2021-01-27T06:07:45.000Z | 2021-11-13T19:19:43.000Z | android-31/android/hardware/camera2/params/OutputConfiguration.cpp | YJBeetle/QtAndroidAPI | 1468b5dc6eafaf7709f0b00ba1a6ec2b70684266 | [
"Apache-2.0"
] | 3 | 2021-02-02T12:34:55.000Z | 2022-03-08T07:45:57.000Z | #include "../MultiResolutionImageReader.hpp"
#include "../../../os/Parcel.hpp"
#include "../../../util/Size.hpp"
#include "../../../view/Surface.hpp"
#include "../../../../JClass.hpp"
#include "../../../../JObject.hpp"
#include "../../../../JString.hpp"
#include "./OutputConfiguration.hpp"
namespace android::hardware::camera2::params
{
// Fields
JObject OutputConfiguration::CREATOR()
{
return getStaticObjectField(
"android.hardware.camera2.params.OutputConfiguration",
"CREATOR",
"Landroid/os/Parcelable$Creator;"
);
}
jint OutputConfiguration::SURFACE_GROUP_ID_NONE()
{
return getStaticField<jint>(
"android.hardware.camera2.params.OutputConfiguration",
"SURFACE_GROUP_ID_NONE"
);
}
// QJniObject forward
OutputConfiguration::OutputConfiguration(QJniObject obj) : JObject(obj) {}
// Constructors
OutputConfiguration::OutputConfiguration(android::view::Surface arg0)
: JObject(
"android.hardware.camera2.params.OutputConfiguration",
"(Landroid/view/Surface;)V",
arg0.object()
) {}
OutputConfiguration::OutputConfiguration(android::util::Size arg0, JClass arg1)
: JObject(
"android.hardware.camera2.params.OutputConfiguration",
"(Landroid/util/Size;Ljava/lang/Class;)V",
arg0.object(),
arg1.object<jclass>()
) {}
OutputConfiguration::OutputConfiguration(jint arg0, android::view::Surface arg1)
: JObject(
"android.hardware.camera2.params.OutputConfiguration",
"(ILandroid/view/Surface;)V",
arg0,
arg1.object()
) {}
// Methods
JObject OutputConfiguration::createInstancesForMultiResolutionOutput(android::hardware::camera2::MultiResolutionImageReader arg0)
{
return callStaticObjectMethod(
"android.hardware.camera2.params.OutputConfiguration",
"createInstancesForMultiResolutionOutput",
"(Landroid/hardware/camera2/MultiResolutionImageReader;)Ljava/util/Collection;",
arg0.object()
);
}
void OutputConfiguration::addSensorPixelModeUsed(jint arg0) const
{
callMethod<void>(
"addSensorPixelModeUsed",
"(I)V",
arg0
);
}
void OutputConfiguration::addSurface(android::view::Surface arg0) const
{
callMethod<void>(
"addSurface",
"(Landroid/view/Surface;)V",
arg0.object()
);
}
jint OutputConfiguration::describeContents() const
{
return callMethod<jint>(
"describeContents",
"()I"
);
}
void OutputConfiguration::enableSurfaceSharing() const
{
callMethod<void>(
"enableSurfaceSharing",
"()V"
);
}
jboolean OutputConfiguration::equals(JObject arg0) const
{
return callMethod<jboolean>(
"equals",
"(Ljava/lang/Object;)Z",
arg0.object<jobject>()
);
}
jint OutputConfiguration::getMaxSharedSurfaceCount() const
{
return callMethod<jint>(
"getMaxSharedSurfaceCount",
"()I"
);
}
android::view::Surface OutputConfiguration::getSurface() const
{
return callObjectMethod(
"getSurface",
"()Landroid/view/Surface;"
);
}
jint OutputConfiguration::getSurfaceGroupId() const
{
return callMethod<jint>(
"getSurfaceGroupId",
"()I"
);
}
JObject OutputConfiguration::getSurfaces() const
{
return callObjectMethod(
"getSurfaces",
"()Ljava/util/List;"
);
}
jint OutputConfiguration::hashCode() const
{
return callMethod<jint>(
"hashCode",
"()I"
);
}
void OutputConfiguration::removeSensorPixelModeUsed(jint arg0) const
{
callMethod<void>(
"removeSensorPixelModeUsed",
"(I)V",
arg0
);
}
void OutputConfiguration::removeSurface(android::view::Surface arg0) const
{
callMethod<void>(
"removeSurface",
"(Landroid/view/Surface;)V",
arg0.object()
);
}
void OutputConfiguration::setPhysicalCameraId(JString arg0) const
{
callMethod<void>(
"setPhysicalCameraId",
"(Ljava/lang/String;)V",
arg0.object<jstring>()
);
}
void OutputConfiguration::writeToParcel(android::os::Parcel arg0, jint arg1) const
{
callMethod<void>(
"writeToParcel",
"(Landroid/os/Parcel;I)V",
arg0.object(),
arg1
);
}
} // namespace android::hardware::camera2::params
| 23.377907 | 130 | 0.700323 | YJBeetle |
97d9ad30730abddd9eb15b1bd9081357a0f6ad56 | 532 | cpp | C++ | tests/unit_tests/Entity/Tools.cpp | Allaeddineattia/Valravn | 7afa00bfe3c6f0c8357209601a67508a35b466b5 | [
"MIT"
] | null | null | null | tests/unit_tests/Entity/Tools.cpp | Allaeddineattia/Valravn | 7afa00bfe3c6f0c8357209601a67508a35b466b5 | [
"MIT"
] | null | null | null | tests/unit_tests/Entity/Tools.cpp | Allaeddineattia/Valravn | 7afa00bfe3c6f0c8357209601a67508a35b466b5 | [
"MIT"
] | 2 | 2021-05-07T20:35:55.000Z | 2021-07-08T15:14:43.000Z | //
// Created by ismail on 22/11/2020.
//
#include "gtest/gtest.h"
#include <string>
#include "Shared/Tools.h"
using namespace std ;
TEST(Tools, Valid_remove_blanks) {
string str = "120 : 120";
Tools::remove_blanks(str);
ASSERT_EQ(str,"120:120");
}
TEST(Tools,Throw_error_on_check_resolution){
string str = "12:58";
ASSERT_THROW(Tools::check_resolution_string_pattern(str),invalid_argument);
}
TEST(Tools,Valid_check_resolution){
string str = "1080:720";
Tools::check_resolution_string_pattern(str);
} | 25.333333 | 79 | 0.714286 | Allaeddineattia |
97ddccd4a66f13f721b7c89c02251856ff2b74d2 | 1,267 | cpp | C++ | build/design/clock.cpp | laxtools/lax | 4b6ac5e042787f1c66e6f4771ec9aafe6b2df26b | [
"MIT"
] | 2 | 2018-09-27T11:45:06.000Z | 2019-06-28T10:41:59.000Z | build/design/clock.cpp | laxtools/lax | 4b6ac5e042787f1c66e6f4771ec9aafe6b2df26b | [
"MIT"
] | 1 | 2017-08-28T07:39:31.000Z | 2018-01-26T05:03:29.000Z | build/design/clock.cpp | laxtools/lax | 4b6ac5e042787f1c66e6f4771ec9aafe6b2df26b | [
"MIT"
] | 1 | 2018-09-27T11:45:26.000Z | 2018-09-27T11:45:26.000Z | #include "stdafx.h"
#include "catch.hpp"
#include <chrono>
#include <iostream>
#include <thread>
#include <map>
namespace ex
{
struct perf_span
{
perf_span()
: begin_(std::chrono::high_resolution_clock::now())
{
}
void reset()
{
begin_ = std::chrono::high_resolution_clock::now();
}
float elapsed() const
{
std::chrono::duration<float> span = std::chrono::high_resolution_clock::now() - begin_;
return span.count();
}
std::chrono::high_resolution_clock::time_point begin_;
};
}
TEST_CASE("high resolution", "clock")
{
SECTION("simple usage")
{
auto clk = std::chrono::high_resolution_clock::now();
std::this_thread::sleep_for(std::chrono::milliseconds(100));
auto now = std::chrono::high_resolution_clock::now();
std::chrono::duration<float> span = (now - clk);
std::cout << "seconds: " << span.count() << std::endl;
}
SECTION("simple timer")
{
ex::perf_span pspan;
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
std::cout << "seconds: " << pspan.elapsed() << std::endl;
}
SECTION("c++ test")
{
std::map<int, std::string> hello;
auto iter = hello.find(3);
REQUIRE(iter->second == "hello");
int v = 600'000;
}
} | 18.362319 | 90 | 0.615627 | laxtools |
97ddd8618309535b31a20cccb5a68dc3bc47168c | 1,939 | cpp | C++ | compiler/locoex-customop/src/Service/COpTypeInference.test.cpp | juitem/ONE | 8c6a4b7738074573b6ac5c82dcf1f6697520d1ed | [
"Apache-2.0"
] | 255 | 2020-05-22T07:45:29.000Z | 2022-03-29T23:58:22.000Z | compiler/locoex-customop/src/Service/COpTypeInference.test.cpp | juitem/ONE | 8c6a4b7738074573b6ac5c82dcf1f6697520d1ed | [
"Apache-2.0"
] | 5,102 | 2020-05-22T07:48:33.000Z | 2022-03-31T23:43:39.000Z | compiler/locoex-customop/src/Service/COpTypeInference.test.cpp | juitem/ONE | 8c6a4b7738074573b6ac5c82dcf1f6697520d1ed | [
"Apache-2.0"
] | 120 | 2020-05-22T07:51:08.000Z | 2022-02-16T19:08:05.000Z | /*
* Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <locoex/Service/COpTypeInference.h>
#include <locoex/COpCall.h>
#include <locoex/COpDialect.h>
#include <loco/IR/CanonicalDialect.h>
#include <loco/Service/TypeInference.h>
#include <gtest/gtest.h>
TEST(TypeInferenceRuleTest, COpTypeInference)
{
// Create a simple Relu6 network
auto g = loco::make_graph();
auto pull_node = g->nodes()->create<loco::Pull>();
pull_node->dtype(loco::DataType::FLOAT32);
auto call_node = g->nodes()->create<locoex::COpCall>(1);
call_node->input(0, pull_node);
call_node->dtype(loco::DataType::FLOAT32);
auto push_node = g->nodes()->create<loco::Push>();
push_node->from(call_node);
auto graph_input = g->inputs()->create();
graph_input->name("input");
loco::link(graph_input, pull_node);
auto graph_output = g->outputs()->create();
graph_output->name("output");
loco::link(graph_output, push_node);
// Run Type Inference
locoex::COpTypeInferenceRule cop_rule;
loco::CanonicalTypeInferenceRule canon_rule;
loco::MultiDialectTypeInferenceRule rules;
rules.bind(locoex::COpDialect::get(), &cop_rule).bind(loco::CanonicalDialect::get(), &canon_rule);
loco::apply(&rules).to(g.get());
// Verify!
ASSERT_TRUE(loco::dtype_known(call_node));
ASSERT_EQ(loco::dtype_get(call_node), loco::DataType::FLOAT32);
}
| 30.296875 | 100 | 0.723569 | juitem |
97e0a64ccaefdf9086ed2c9d046856880d049c0a | 392 | cc | C++ | example/tuntap/main.cc | slankdev/libslankdev | 260296935e0ad8e2dc4b08f3029bf2607fb0278e | [
"MIT"
] | 6 | 2016-06-07T02:20:29.000Z | 2017-11-10T07:43:59.000Z | example/tuntap/main.cc | slankdev/libslankdev | 260296935e0ad8e2dc4b08f3029bf2607fb0278e | [
"MIT"
] | 3 | 2016-06-11T05:42:05.000Z | 2016-12-08T02:03:18.000Z | example/tuntap/main.cc | slankdev/libslankdev | 260296935e0ad8e2dc4b08f3029bf2607fb0278e | [
"MIT"
] | null | null | null |
#include <stdio.h>
#include <slankdev/net/tuntap.h>
#include <slankdev/hexdump.h>
int main()
{
slankdev::tap tap_in ("tap0");
slankdev::tap tap_out("tap1");
while (1) {
uint8_t buf[10000];
size_t recvlen = tap_in.read(buf, sizeof(buf));
printf("Received Packet len=%zd \n", recvlen);
slankdev::hexdump(stdout, buf, recvlen);
tap_out.write(buf, recvlen);
}
}
| 17.818182 | 51 | 0.645408 | slankdev |
97e3066692a37f0a44eae8486f3dae71e9edcea4 | 200,714 | inl | C++ | 2d_samples/pmj02_135.inl | st-ario/rayme | 315c57c23f4aa4934a8a80e84e3243acd3400808 | [
"MIT"
] | 1 | 2021-12-10T23:35:04.000Z | 2021-12-10T23:35:04.000Z | 2d_samples/pmj02_135.inl | st-ario/rayme | 315c57c23f4aa4934a8a80e84e3243acd3400808 | [
"MIT"
] | null | null | null | 2d_samples/pmj02_135.inl | st-ario/rayme | 315c57c23f4aa4934a8a80e84e3243acd3400808 | [
"MIT"
] | null | null | null | {std::array<float,2>{0.203858882f, 0.797032833f},
std::array<float,2>{0.892523766f, 0.441579163f},
std::array<float,2>{0.407151997f, 0.0233917385f},
std::array<float,2>{0.644022763f, 0.690212846f},
std::array<float,2>{0.334998846f, 0.524249792f},
std::array<float,2>{0.555751503f, 0.192193568f},
std::array<float,2>{0.0291189123f, 0.25819692f},
std::array<float,2>{0.760083973f, 0.976848543f},
std::array<float,2>{0.0948297009f, 0.635060787f},
std::array<float,2>{0.865484834f, 0.089720048f},
std::array<float,2>{0.265196323f, 0.397465646f},
std::array<float,2>{0.623164892f, 0.836701274f},
std::array<float,2>{0.475756586f, 0.912104547f},
std::array<float,2>{0.731368124f, 0.34919104f},
std::array<float,2>{0.138763994f, 0.15922524f},
std::array<float,2>{0.96198684f, 0.571642935f},
std::array<float,2>{0.0532597825f, 0.953336298f},
std::array<float,2>{0.79172045f, 0.286885858f},
std::array<float,2>{0.344946623f, 0.227497235f},
std::array<float,2>{0.528218329f, 0.549673855f},
std::array<float,2>{0.397521913f, 0.734130561f},
std::array<float,2>{0.661419332f, 0.0528524034f},
std::array<float,2>{0.246129334f, 0.498851538f},
std::array<float,2>{0.928507626f, 0.777858555f},
std::array<float,2>{0.163662165f, 0.620304585f},
std::array<float,2>{0.983067453f, 0.1562116f},
std::array<float,2>{0.45795399f, 0.327422649f},
std::array<float,2>{0.707488954f, 0.883500159f},
std::array<float,2>{0.287198424f, 0.872861087f},
std::array<float,2>{0.56512475f, 0.410695046f},
std::array<float,2>{0.0864644647f, 0.105648771f},
std::array<float,2>{0.830015421f, 0.674185276f},
std::array<float,2>{0.145617545f, 0.902712464f},
std::array<float,2>{0.940263271f, 0.330396593f},
std::array<float,2>{0.489332139f, 0.138494521f},
std::array<float,2>{0.742275119f, 0.596361637f},
std::array<float,2>{0.277266234f, 0.665036976f},
std::array<float,2>{0.598041534f, 0.112179466f},
std::array<float,2>{0.113281518f, 0.431559324f},
std::array<float,2>{0.849877894f, 0.85550642f},
std::array<float,2>{0.00682157231f, 0.543917596f},
std::array<float,2>{0.777728021f, 0.241208389f},
std::array<float,2>{0.321019083f, 0.299486369f},
std::array<float,2>{0.538520873f, 0.941763461f},
std::array<float,2>{0.435276687f, 0.755790234f},
std::array<float,2>{0.626712561f, 0.475175381f},
std::array<float,2>{0.198607326f, 0.0456907414f},
std::array<float,2>{0.881435573f, 0.745467901f},
std::array<float,2>{0.0719156191f, 0.812943637f},
std::array<float,2>{0.814076006f, 0.376947641f},
std::array<float,2>{0.303506076f, 0.0747235566f},
std::array<float,2>{0.587246954f, 0.653481662f},
std::array<float,2>{0.441132486f, 0.582971513f},
std::array<float,2>{0.700124919f, 0.172124118f},
std::array<float,2>{0.175892949f, 0.367257237f},
std::array<float,2>{0.986017883f, 0.929511189f},
std::array<float,2>{0.21928221f, 0.711602688f},
std::array<float,2>{0.91003716f, 0.00154905533f},
std::array<float,2>{0.386837095f, 0.453237683f},
std::array<float,2>{0.676249444f, 0.782782972f},
std::array<float,2>{0.362486869f, 0.984396458f},
std::array<float,2>{0.504981458f, 0.26817596f},
std::array<float,2>{0.034213528f, 0.206252769f},
std::array<float,2>{0.806237459f, 0.515462041f},
std::array<float,2>{0.181877881f, 0.847751081f},
std::array<float,2>{0.997891784f, 0.425121516f},
std::array<float,2>{0.451130062f, 0.123049125f},
std::array<float,2>{0.688606203f, 0.656559527f},
std::array<float,2>{0.308212548f, 0.609220803f},
std::array<float,2>{0.585447013f, 0.13086386f},
std::array<float,2>{0.0697878376f, 0.337326735f},
std::array<float,2>{0.821581602f, 0.89366883f},
std::array<float,2>{0.0405593403f, 0.735280275f},
std::array<float,2>{0.79980576f, 0.0388865955f},
std::array<float,2>{0.374758542f, 0.479913503f},
std::array<float,2>{0.515005171f, 0.759033084f},
std::array<float,2>{0.378568918f, 0.951411843f},
std::array<float,2>{0.682780564f, 0.308468401f},
std::array<float,2>{0.230273664f, 0.247060612f},
std::array<float,2>{0.920321465f, 0.534017324f},
std::array<float,2>{0.122228496f, 0.930253267f},
std::array<float,2>{0.852124155f, 0.363938361f},
std::array<float,2>{0.266912639f, 0.182417542f},
std::array<float,2>{0.606351674f, 0.587576509f},
std::array<float,2>{0.495955557f, 0.641768932f},
std::array<float,2>{0.740915954f, 0.0658510625f},
std::array<float,2>{0.15206489f, 0.385228902f},
std::array<float,2>{0.949000299f, 0.825424373f},
std::array<float,2>{0.194771439f, 0.501712024f},
std::array<float,2>{0.890093327f, 0.211224824f},
std::array<float,2>{0.42741999f, 0.280480921f},
std::array<float,2>{0.638358891f, 0.993505836f},
std::array<float,2>{0.314198107f, 0.794080436f},
std::array<float,2>{0.540714622f, 0.464980185f},
std::array<float,2>{0.00847364403f, 0.00863354374f},
std::array<float,2>{0.770728707f, 0.71007818f},
std::array<float,2>{0.238283932f, 0.972209513f},
std::array<float,2>{0.932776392f, 0.253454149f},
std::array<float,2>{0.405927956f, 0.197234675f},
std::array<float,2>{0.669301152f, 0.520017147f},
std::array<float,2>{0.357030183f, 0.702003419f},
std::array<float,2>{0.519353569f, 0.0252033472f},
std::array<float,2>{0.0621023588f, 0.447789401f},
std::array<float,2>{0.788672745f, 0.810492814f},
std::array<float,2>{0.0811370015f, 0.5687235f},
std::array<float,2>{0.84357059f, 0.169954062f},
std::array<float,2>{0.291642308f, 0.357075155f},
std::array<float,2>{0.57529366f, 0.916478097f},
std::array<float,2>{0.462287635f, 0.835338593f},
std::array<float,2>{0.718205929f, 0.404016286f},
std::array<float,2>{0.167194635f, 0.0824814215f},
std::array<float,2>{0.974900305f, 0.632306218f},
std::array<float,2>{0.0207797773f, 0.770372748f},
std::array<float,2>{0.753701508f, 0.491364181f},
std::array<float,2>{0.342472464f, 0.0602637567f},
std::array<float,2>{0.548422933f, 0.726285815f},
std::array<float,2>{0.417013526f, 0.562468112f},
std::array<float,2>{0.65564549f, 0.222608387f},
std::array<float,2>{0.211194649f, 0.289171755f},
std::array<float,2>{0.904432118f, 0.96281904f},
std::array<float,2>{0.12749137f, 0.685062528f},
std::array<float,2>{0.954525113f, 0.0999747813f},
std::array<float,2>{0.483644634f, 0.42001161f},
std::array<float,2>{0.720845401f, 0.860657632f},
std::array<float,2>{0.257699817f, 0.877157688f},
std::array<float,2>{0.61019206f, 0.313242555f},
std::array<float,2>{0.108702853f, 0.148158655f},
std::array<float,2>{0.874944746f, 0.614130616f},
std::array<float,2>{0.135296211f, 0.76429534f},
std::array<float,2>{0.968114853f, 0.481395483f},
std::array<float,2>{0.470778078f, 0.0351122245f},
std::array<float,2>{0.729368448f, 0.741158783f},
std::array<float,2>{0.260920286f, 0.538396299f},
std::array<float,2>{0.6194911f, 0.243664369f},
std::array<float,2>{0.101538457f, 0.310848922f},
std::array<float,2>{0.86319375f, 0.9456833f},
std::array<float,2>{0.0258552432f, 0.662528038f},
std::array<float,2>{0.765491962f, 0.118141733f},
std::array<float,2>{0.330100805f, 0.427771151f},
std::array<float,2>{0.560774088f, 0.846616983f},
std::array<float,2>{0.412327707f, 0.895298243f},
std::array<float,2>{0.645223796f, 0.340233743f},
std::array<float,2>{0.207181737f, 0.126087502f},
std::array<float,2>{0.898331761f, 0.601801693f},
std::array<float,2>{0.0936021209f, 0.998727918f},
std::array<float,2>{0.832439244f, 0.273942679f},
std::array<float,2>{0.284331203f, 0.217868865f},
std::array<float,2>{0.569057882f, 0.507257283f},
std::array<float,2>{0.455226898f, 0.703589678f},
std::array<float,2>{0.705530882f, 0.011982834f},
std::array<float,2>{0.160132006f, 0.46190998f},
std::array<float,2>{0.979568899f, 0.789561629f},
std::array<float,2>{0.244097501f, 0.589995921f},
std::array<float,2>{0.925384283f, 0.185543299f},
std::array<float,2>{0.391247392f, 0.362980932f},
std::array<float,2>{0.65886271f, 0.935291529f},
std::array<float,2>{0.351319939f, 0.824185133f},
std::array<float,2>{0.523899794f, 0.389804989f},
std::array<float,2>{0.0472298935f, 0.0666070804f},
std::array<float,2>{0.795736074f, 0.644868731f},
std::array<float,2>{0.202005416f, 0.921430886f},
std::array<float,2>{0.876387179f, 0.354918092f},
std::array<float,2>{0.431727797f, 0.164891198f},
std::array<float,2>{0.62953645f, 0.563611805f},
std::array<float,2>{0.326379508f, 0.625210941f},
std::array<float,2>{0.534610271f, 0.0800717846f},
std::array<float,2>{0.00162338943f, 0.401142865f},
std::array<float,2>{0.774004281f, 0.831011713f},
std::array<float,2>{0.110832945f, 0.518205583f},
std::array<float,2>{0.847340822f, 0.200219974f},
std::array<float,2>{0.277489036f, 0.253967375f},
std::array<float,2>{0.595484197f, 0.975665271f},
std::array<float,2>{0.488043159f, 0.807488501f},
std::array<float,2>{0.746940732f, 0.450172335f},
std::array<float,2>{0.142827898f, 0.0306224786f},
std::array<float,2>{0.945118308f, 0.696668327f},
std::array<float,2>{0.0354534984f, 0.864028156f},
std::array<float,2>{0.809004486f, 0.415835559f},
std::array<float,2>{0.363831758f, 0.0954794213f},
std::array<float,2>{0.500801444f, 0.680122733f},
std::array<float,2>{0.386491507f, 0.609625101f},
std::array<float,2>{0.67321682f, 0.140893504f},
std::array<float,2>{0.225183487f, 0.316997677f},
std::array<float,2>{0.91243273f, 0.880906641f},
std::array<float,2>{0.174868241f, 0.72173351f},
std::array<float,2>{0.991965652f, 0.056832768f},
std::array<float,2>{0.444585949f, 0.484937489f},
std::array<float,2>{0.696254849f, 0.769145548f},
std::array<float,2>{0.299537152f, 0.967524052f},
std::array<float,2>{0.591276824f, 0.294574022f},
std::array<float,2>{0.0749417022f, 0.226275504f},
std::array<float,2>{0.817152619f, 0.558014512f},
std::array<float,2>{0.232641906f, 0.842726827f},
std::array<float,2>{0.917329788f, 0.393307626f},
std::array<float,2>{0.382201433f, 0.0907223746f},
std::array<float,2>{0.685936987f, 0.639344037f},
std::array<float,2>{0.37093237f, 0.577824175f},
std::array<float,2>{0.511234522f, 0.16389212f},
std::array<float,2>{0.0468490236f, 0.345061719f},
std::array<float,2>{0.801810205f, 0.908026755f},
std::array<float,2>{0.0657193884f, 0.693525791f},
std::array<float,2>{0.825768352f, 0.0158438869f},
std::array<float,2>{0.31091091f, 0.438679665f},
std::array<float,2>{0.581875205f, 0.800866008f},
std::array<float,2>{0.447513252f, 0.982137144f},
std::array<float,2>{0.692927361f, 0.26182425f},
std::array<float,2>{0.186087295f, 0.187863857f},
std::array<float,2>{0.995164335f, 0.527833641f},
std::array<float,2>{0.0121059623f, 0.888004601f},
std::array<float,2>{0.768535614f, 0.32182458f},
std::array<float,2>{0.318221152f, 0.15058212f},
std::array<float,2>{0.546494246f, 0.622562885f},
std::array<float,2>{0.422083735f, 0.679175615f},
std::array<float,2>{0.634608924f, 0.102468066f},
std::array<float,2>{0.18923755f, 0.407767653f},
std::array<float,2>{0.884441078f, 0.870638847f},
std::array<float,2>{0.155289218f, 0.552682698f},
std::array<float,2>{0.952690721f, 0.231542885f},
std::array<float,2>{0.497831762f, 0.284841001f},
std::array<float,2>{0.737081528f, 0.957701325f},
std::array<float,2>{0.272431344f, 0.776972413f},
std::array<float,2>{0.602447808f, 0.496079147f},
std::array<float,2>{0.120172247f, 0.0482298248f},
std::array<float,2>{0.859170794f, 0.72737062f},
std::array<float,2>{0.16999492f, 0.941110969f},
std::array<float,2>{0.969544709f, 0.304283589f},
std::array<float,2>{0.465298206f, 0.236244097f},
std::array<float,2>{0.713692904f, 0.540824413f},
std::array<float,2>{0.294680119f, 0.746830046f},
std::array<float,2>{0.570983529f, 0.041403573f},
std::array<float,2>{0.083376281f, 0.470575631f},
std::array<float,2>{0.839673162f, 0.752566576f},
std::array<float,2>{0.057745304f, 0.600618899f},
std::array<float,2>{0.782148302f, 0.13589327f},
std::array<float,2>{0.354591191f, 0.333026141f},
std::array<float,2>{0.52142477f, 0.901878715f},
std::array<float,2>{0.401975036f, 0.85382098f},
std::array<float,2>{0.667541027f, 0.434025407f},
std::array<float,2>{0.238139689f, 0.115473852f},
std::array<float,2>{0.933799148f, 0.668767273f},
std::array<float,2>{0.102548249f, 0.786319256f},
std::array<float,2>{0.86823982f, 0.457326382f},
std::array<float,2>{0.251922905f, 0.0040398906f},
std::array<float,2>{0.613882542f, 0.714933038f},
std::array<float,2>{0.478857309f, 0.509544909f},
std::array<float,2>{0.723399162f, 0.210130051f},
std::array<float,2>{0.130561054f, 0.27291882f},
std::array<float,2>{0.959838271f, 0.990518093f},
std::array<float,2>{0.218021795f, 0.650587976f},
std::array<float,2>{0.901201308f, 0.0739958137f},
std::array<float,2>{0.41965121f, 0.382443488f},
std::array<float,2>{0.651987314f, 0.816428363f},
std::array<float,2>{0.336976677f, 0.925086498f},
std::array<float,2>{0.552624404f, 0.371365577f},
std::array<float,2>{0.0191302299f, 0.177449957f},
std::array<float,2>{0.754899859f, 0.58051616f},
std::array<float,2>{0.248882532f, 0.780858159f},
std::array<float,2>{0.927727699f, 0.497516334f},
std::array<float,2>{0.394620061f, 0.0511483476f},
std::array<float,2>{0.66271776f, 0.731797993f},
std::array<float,2>{0.346334934f, 0.548772633f},
std::array<float,2>{0.530750632f, 0.229295433f},
std::array<float,2>{0.0526745878f, 0.288929433f},
std::array<float,2>{0.78952831f, 0.95684278f},
std::array<float,2>{0.0886957869f, 0.673217177f},
std::array<float,2>{0.830906153f, 0.108256444f},
std::array<float,2>{0.286642224f, 0.413650393f},
std::array<float,2>{0.562795222f, 0.873720348f},
std::array<float,2>{0.460739344f, 0.886167943f},
std::array<float,2>{0.710605204f, 0.324285507f},
std::array<float,2>{0.161810368f, 0.152926311f},
std::array<float,2>{0.981949389f, 0.618319631f},
std::array<float,2>{0.0295058396f, 0.980412662f},
std::array<float,2>{0.758744836f, 0.260401338f},
std::array<float,2>{0.332710147f, 0.19363445f},
std::array<float,2>{0.5579741f, 0.525788248f},
std::array<float,2>{0.409814835f, 0.688348353f},
std::array<float,2>{0.642128587f, 0.0213072281f},
std::array<float,2>{0.205956191f, 0.443901122f},
std::array<float,2>{0.892731965f, 0.800495505f},
std::array<float,2>{0.137137219f, 0.572784603f},
std::array<float,2>{0.963313818f, 0.156947047f},
std::array<float,2>{0.473271757f, 0.349886835f},
std::array<float,2>{0.733071983f, 0.912664592f},
std::array<float,2>{0.262550294f, 0.839654922f},
std::array<float,2>{0.62251538f, 0.396031797f},
std::array<float,2>{0.0968131125f, 0.0869121775f},
std::array<float,2>{0.863943219f, 0.634604454f},
std::array<float,2>{0.179656684f, 0.926373005f},
std::array<float,2>{0.987347066f, 0.369765699f},
std::array<float,2>{0.438877404f, 0.174272686f},
std::array<float,2>{0.702862561f, 0.584146559f},
std::array<float,2>{0.302155614f, 0.654425085f},
std::array<float,2>{0.589808702f, 0.0779812336f},
std::array<float,2>{0.0740647763f, 0.377010345f},
std::array<float,2>{0.814909399f, 0.814596295f},
std::array<float,2>{0.0313699171f, 0.51207757f},
std::array<float,2>{0.806835532f, 0.203681976f},
std::array<float,2>{0.360822529f, 0.266637027f},
std::array<float,2>{0.507373095f, 0.987344384f},
std::array<float,2>{0.390407205f, 0.784326136f},
std::array<float,2>{0.677771568f, 0.456670493f},
std::array<float,2>{0.220813766f, 0.00279564201f},
std::array<float,2>{0.906404316f, 0.714257479f},
std::array<float,2>{0.116837956f, 0.858540177f},
std::array<float,2>{0.847736239f, 0.432454795f},
std::array<float,2>{0.274039924f, 0.109866284f},
std::array<float,2>{0.600194335f, 0.666837096f},
std::array<float,2>{0.490965992f, 0.594801366f},
std::array<float,2>{0.745493352f, 0.139241815f},
std::array<float,2>{0.147019848f, 0.329251468f},
std::array<float,2>{0.93794769f, 0.905185282f},
std::array<float,2>{0.195919245f, 0.742723346f},
std::array<float,2>{0.879946947f, 0.0436179824f},
std::array<float,2>{0.436030179f, 0.473018318f},
std::array<float,2>{0.628794014f, 0.757187724f},
std::array<float,2>{0.323728442f, 0.945015311f},
std::array<float,2>{0.535479546f, 0.297981977f},
std::array<float,2>{0.00429692352f, 0.239067137f},
std::array<float,2>{0.780011058f, 0.54656595f},
std::array<float,2>{0.149491042f, 0.82710737f},
std::array<float,2>{0.946998298f, 0.383273602f},
std::array<float,2>{0.493285716f, 0.0631457269f},
std::array<float,2>{0.739424467f, 0.643700302f},
std::array<float,2>{0.267927766f, 0.589136422f},
std::array<float,2>{0.608914256f, 0.181095734f},
std::array<float,2>{0.123854525f, 0.365731865f},
std::array<float,2>{0.85486275f, 0.933189452f},
std::array<float,2>{0.0114121316f, 0.70768708f},
std::array<float,2>{0.772139668f, 0.0115786623f},
std::array<float,2>{0.315609008f, 0.468097091f},
std::array<float,2>{0.542075574f, 0.796135008f},
std::array<float,2>{0.427856266f, 0.994973302f},
std::array<float,2>{0.639052451f, 0.278919786f},
std::array<float,2>{0.192636222f, 0.213390142f},
std::array<float,2>{0.887511671f, 0.502941787f},
std::array<float,2>{0.0679632425f, 0.892260134f},
std::array<float,2>{0.823539019f, 0.338992417f},
std::array<float,2>{0.306624353f, 0.129599929f},
std::array<float,2>{0.583417177f, 0.606024206f},
std::array<float,2>{0.452800065f, 0.659184694f},
std::array<float,2>{0.691308022f, 0.121213205f},
std::array<float,2>{0.181286037f, 0.423595816f},
std::array<float,2>{0.999395907f, 0.851346016f},
std::array<float,2>{0.227446735f, 0.531368792f},
std::array<float,2>{0.919223785f, 0.248505831f},
std::array<float,2>{0.375892192f, 0.306347579f},
std::array<float,2>{0.680550337f, 0.949685872f},
std::array<float,2>{0.371750653f, 0.760830998f},
std::array<float,2>{0.513247132f, 0.478374153f},
std::array<float,2>{0.042736154f, 0.0356544033f},
std::array<float,2>{0.797687411f, 0.737968504f},
std::array<float,2>{0.213901043f, 0.964001298f},
std::array<float,2>{0.904062331f, 0.292965919f},
std::array<float,2>{0.415461183f, 0.220701993f},
std::array<float,2>{0.652677238f, 0.559464753f},
std::array<float,2>{0.341119736f, 0.724463463f},
std::array<float,2>{0.549390972f, 0.0608374253f},
std::array<float,2>{0.0225945208f, 0.490158319f},
std::array<float,2>{0.750019014f, 0.772994936f},
std::array<float,2>{0.106070213f, 0.61569488f},
std::array<float,2>{0.872325122f, 0.144814461f},
std::array<float,2>{0.25457111f, 0.315500796f},
std::array<float,2>{0.611589253f, 0.875528276f},
std::array<float,2>{0.481133163f, 0.862335145f},
std::array<float,2>{0.72015065f, 0.418340892f},
std::array<float,2>{0.125781596f, 0.0992153808f},
std::array<float,2>{0.956885099f, 0.68587172f},
std::array<float,2>{0.0592976585f, 0.811028302f},
std::array<float,2>{0.786320984f, 0.445491195f},
std::array<float,2>{0.358453572f, 0.0264056269f},
std::array<float,2>{0.517376602f, 0.69947058f},
std::array<float,2>{0.402483463f, 0.5218485f},
std::array<float,2>{0.671518803f, 0.198312014f},
std::array<float,2>{0.241055012f, 0.251404405f},
std::array<float,2>{0.930873096f, 0.970116794f},
std::array<float,2>{0.164476201f, 0.630404115f},
std::array<float,2>{0.973125637f, 0.0843170583f},
std::array<float,2>{0.464349896f, 0.405932307f},
std::array<float,2>{0.716064334f, 0.83374542f},
std::array<float,2>{0.289347827f, 0.914989889f},
std::array<float,2>{0.577967346f, 0.358340323f},
std::array<float,2>{0.0790177211f, 0.168443903f},
std::array<float,2>{0.840345621f, 0.567066133f},
std::array<float,2>{0.15722467f, 0.792697847f},
std::array<float,2>{0.97716552f, 0.464363813f},
std::array<float,2>{0.453883111f, 0.0141269155f},
std::array<float,2>{0.70316124f, 0.705434144f},
std::array<float,2>{0.282894671f, 0.505809963f},
std::array<float,2>{0.566785455f, 0.214976177f},
std::array<float,2>{0.0899263844f, 0.276549816f},
std::array<float,2>{0.83492136f, 0.997883439f},
std::array<float,2>{0.0494708344f, 0.647895098f},
std::array<float,2>{0.793664515f, 0.0702493712f},
std::array<float,2>{0.349042326f, 0.388266683f},
std::array<float,2>{0.525796056f, 0.821049809f},
std::array<float,2>{0.393860161f, 0.93679297f},
std::array<float,2>{0.656737804f, 0.360096812f},
std::array<float,2>{0.244550094f, 0.185705468f},
std::array<float,2>{0.923546255f, 0.593458593f},
std::array<float,2>{0.099282518f, 0.947819471f},
std::array<float,2>{0.86068213f, 0.31047371f},
std::array<float,2>{0.257822961f, 0.24451378f},
std::array<float,2>{0.61864531f, 0.536196947f},
std::array<float,2>{0.469001412f, 0.738527775f},
std::array<float,2>{0.728332579f, 0.0313968882f},
std::array<float,2>{0.13369453f, 0.484363377f},
std::array<float,2>{0.966704249f, 0.763336897f},
std::array<float,2>{0.209052816f, 0.604042709f},
std::array<float,2>{0.895482481f, 0.127119049f},
std::array<float,2>{0.410194695f, 0.343152612f},
std::array<float,2>{0.647372544f, 0.897714555f},
std::array<float,2>{0.328700155f, 0.845391929f},
std::array<float,2>{0.559967101f, 0.427005798f},
std::array<float,2>{0.0243948065f, 0.1201737f},
std::array<float,2>{0.762049317f, 0.66019243f},
std::array<float,2>{0.224488586f, 0.88018465f},
std::array<float,2>{0.910185635f, 0.31863904f},
std::array<float,2>{0.383172125f, 0.144497484f},
std::array<float,2>{0.674465954f, 0.613019884f},
std::array<float,2>{0.365735531f, 0.68180126f},
std::array<float,2>{0.50353539f, 0.0969202593f},
std::array<float,2>{0.0386642963f, 0.417596608f},
std::array<float,2>{0.810605824f, 0.866454184f},
std::array<float,2>{0.077457726f, 0.555906177f},
std::array<float,2>{0.819791436f, 0.224437222f},
std::array<float,2>{0.297585636f, 0.296740025f},
std::array<float,2>{0.592168272f, 0.966430068f},
std::array<float,2>{0.44207105f, 0.765674651f},
std::array<float,2>{0.699132919f, 0.487878978f},
std::array<float,2>{0.173227116f, 0.0563914515f},
std::array<float,2>{0.990086913f, 0.719587266f},
std::array<float,2>{0.00247562514f, 0.828413486f},
std::array<float,2>{0.775981128f, 0.399297535f},
std::array<float,2>{0.324552864f, 0.0804656297f},
std::array<float,2>{0.531797409f, 0.627203107f},
std::array<float,2>{0.431393802f, 0.565142632f},
std::array<float,2>{0.632379055f, 0.166631833f},
std::array<float,2>{0.200290456f, 0.351634651f},
std::array<float,2>{0.878674328f, 0.917997539f},
std::array<float,2>{0.142491713f, 0.698124826f},
std::array<float,2>{0.942452192f, 0.0278377626f},
std::array<float,2>{0.485532373f, 0.451917678f},
std::array<float,2>{0.749060214f, 0.80622977f},
std::array<float,2>{0.281043649f, 0.973544359f},
std::array<float,2>{0.596448779f, 0.256677151f},
std::array<float,2>{0.111658439f, 0.202548742f},
std::array<float,2>{0.844542861f, 0.517396986f},
std::array<float,2>{0.190452263f, 0.868139982f},
std::array<float,2>{0.886350811f, 0.409449011f},
std::array<float,2>{0.423879445f, 0.104166418f},
std::array<float,2>{0.634965599f, 0.677580655f},
std::array<float,2>{0.318837911f, 0.623509288f},
std::array<float,2>{0.54319334f, 0.149417818f},
std::array<float,2>{0.0155411586f, 0.322761834f},
std::array<float,2>{0.767445683f, 0.889800787f},
std::array<float,2>{0.119059399f, 0.72999531f},
std::array<float,2>{0.856117725f, 0.0505576506f},
std::array<float,2>{0.271170586f, 0.492820114f},
std::array<float,2>{0.605031669f, 0.77532053f},
std::array<float,2>{0.498972386f, 0.960199237f},
std::array<float,2>{0.736017883f, 0.283186287f},
std::array<float,2>{0.152509987f, 0.233047411f},
std::array<float,2>{0.950432479f, 0.552914858f},
std::array<float,2>{0.0441619381f, 0.908871531f},
std::array<float,2>{0.803923368f, 0.34610644f},
std::array<float,2>{0.368810564f, 0.161929086f},
std::array<float,2>{0.507976055f, 0.574225724f},
std::array<float,2>{0.380507112f, 0.636833012f},
std::array<float,2>{0.684658229f, 0.093248859f},
std::array<float,2>{0.230998769f, 0.391099155f},
std::array<float,2>{0.914573669f, 0.840143025f},
std::array<float,2>{0.18381229f, 0.530112088f},
std::array<float,2>{0.992588639f, 0.1900713f},
std::array<float,2>{0.445628732f, 0.263707131f},
std::array<float,2>{0.695285797f, 0.982470155f},
std::array<float,2>{0.309485525f, 0.804537892f},
std::array<float,2>{0.5783512f, 0.441158116f},
std::array<float,2>{0.064065367f, 0.0181566682f},
std::array<float,2>{0.827893317f, 0.693264961f},
std::array<float,2>{0.132060602f, 0.98938632f},
std::array<float,2>{0.957894385f, 0.271279067f},
std::array<float,2>{0.477411062f, 0.207220927f},
std::array<float,2>{0.724875569f, 0.510127366f},
std::array<float,2>{0.252018154f, 0.717437744f},
std::array<float,2>{0.615305126f, 0.00700955f},
std::array<float,2>{0.104056247f, 0.460189313f},
std::array<float,2>{0.870569706f, 0.788001955f},
std::array<float,2>{0.0174724404f, 0.579916358f},
std::array<float,2>{0.757338822f, 0.179531664f},
std::array<float,2>{0.338941634f, 0.374281883f},
std::array<float,2>{0.552824974f, 0.923742115f},
std::array<float,2>{0.420205116f, 0.819452405f},
std::array<float,2>{0.650133252f, 0.380486101f},
std::array<float,2>{0.214886025f, 0.0715020448f},
std::array<float,2>{0.898499846f, 0.649030387f},
std::array<float,2>{0.0842719078f, 0.750348985f},
std::array<float,2>{0.836887538f, 0.471745491f},
std::array<float,2>{0.296549648f, 0.0397165418f},
std::array<float,2>{0.573416889f, 0.748661578f},
std::array<float,2>{0.468113303f, 0.541421473f},
std::array<float,2>{0.711671233f, 0.237387538f},
std::array<float,2>{0.169280708f, 0.301790029f},
std::array<float,2>{0.972423673f, 0.939114332f},
std::array<float,2>{0.23458764f, 0.670532882f},
std::array<float,2>{0.936405063f, 0.114396468f},
std::array<float,2>{0.399864018f, 0.436099321f},
std::array<float,2>{0.665544689f, 0.853333473f},
std::array<float,2>{0.352764368f, 0.898441851f},
std::array<float,2>{0.521953285f, 0.335017413f},
std::array<float,2>{0.0547360517f, 0.133841574f},
std::array<float,2>{0.784471691f, 0.598298788f},
std::array<float,2>{0.221872494f, 0.782191932f},
std::array<float,2>{0.908006728f, 0.454464972f},
std::array<float,2>{0.389343858f, 1.08594031e-06f},
std::array<float,2>{0.678890824f, 0.712195933f},
std::array<float,2>{0.359485388f, 0.514113128f},
std::array<float,2>{0.506151676f, 0.205400646f},
std::array<float,2>{0.032940723f, 0.269329011f},
std::array<float,2>{0.808313787f, 0.98608309f},
std::array<float,2>{0.0728891119f, 0.653279185f},
std::array<float,2>{0.816082418f, 0.0761170685f},
std::array<float,2>{0.301240206f, 0.375684261f},
std::array<float,2>{0.588160813f, 0.814193249f},
std::array<float,2>{0.437884331f, 0.927830756f},
std::array<float,2>{0.701382577f, 0.368433148f},
std::array<float,2>{0.178107038f, 0.173361927f},
std::array<float,2>{0.986665547f, 0.583939254f},
std::array<float,2>{0.00539048295f, 0.943131745f},
std::array<float,2>{0.780913651f, 0.300346464f},
std::array<float,2>{0.322956204f, 0.241927147f},
std::array<float,2>{0.536782384f, 0.544354796f},
std::array<float,2>{0.436778814f, 0.744755745f},
std::array<float,2>{0.627770245f, 0.0461244136f},
std::array<float,2>{0.196601033f, 0.475922644f},
std::array<float,2>{0.879518688f, 0.754752278f},
std::array<float,2>{0.148392171f, 0.597029865f},
std::array<float,2>{0.938678563f, 0.137687668f},
std::array<float,2>{0.492110193f, 0.331167608f},
std::array<float,2>{0.744695961f, 0.90395695f},
std::array<float,2>{0.275185674f, 0.857206762f},
std::array<float,2>{0.601307392f, 0.43062225f},
std::array<float,2>{0.115750939f, 0.112657093f},
std::array<float,2>{0.849018991f, 0.665468514f},
std::array<float,2>{0.16040273f, 0.884215772f},
std::array<float,2>{0.981368482f, 0.327014983f},
std::array<float,2>{0.459155321f, 0.154958516f},
std::array<float,2>{0.709676325f, 0.619216263f},
std::array<float,2>{0.285248876f, 0.675217748f},
std::array<float,2>{0.563572466f, 0.106767617f},
std::array<float,2>{0.0891588554f, 0.411738813f},
std::array<float,2>{0.831848681f, 0.871214867f},
std::array<float,2>{0.0509531796f, 0.550541222f},
std::array<float,2>{0.790749073f, 0.228292048f},
std::array<float,2>{0.347178847f, 0.286037177f},
std::array<float,2>{0.529741645f, 0.955041349f},
std::array<float,2>{0.396097571f, 0.778377831f},
std::array<float,2>{0.66364795f, 0.499474436f},
std::array<float,2>{0.249237284f, 0.0537750684f},
std::array<float,2>{0.926236153f, 0.732424557f},
std::array<float,2>{0.0966383219f, 0.83783251f},
std::array<float,2>{0.864757597f, 0.396718889f},
std::array<float,2>{0.263153613f, 0.0882017687f},
std::array<float,2>{0.621405244f, 0.636530817f},
std::array<float,2>{0.473948717f, 0.570967793f},
std::array<float,2>{0.734066844f, 0.158313885f},
std::array<float,2>{0.13802819f, 0.348236054f},
std::array<float,2>{0.964198709f, 0.910686135f},
std::array<float,2>{0.206350893f, 0.690480053f},
std::array<float,2>{0.893719077f, 0.0224359855f},
std::array<float,2>{0.408638388f, 0.44243452f},
std::array<float,2>{0.641054153f, 0.79802537f},
std::array<float,2>{0.333300292f, 0.977590024f},
std::array<float,2>{0.55685246f, 0.259236246f},
std::array<float,2>{0.0303524137f, 0.192384765f},
std::array<float,2>{0.759495676f, 0.525093496f},
std::array<float,2>{0.126887232f, 0.859825313f},
std::array<float,2>{0.955213428f, 0.421006411f},
std::array<float,2>{0.481817365f, 0.100848958f},
std::array<float,2>{0.718906224f, 0.684035897f},
std::array<float,2>{0.254889578f, 0.614864409f},
std::array<float,2>{0.613239348f, 0.147429243f},
std::array<float,2>{0.106631741f, 0.313776106f},
std::array<float,2>{0.87182194f, 0.878351629f},
std::array<float,2>{0.02187673f, 0.724780083f},
std::array<float,2>{0.751626194f, 0.0587346926f},
std::array<float,2>{0.340527952f, 0.490666866f},
std::array<float,2>{0.550705969f, 0.77062577f},
std::array<float,2>{0.414407045f, 0.961264312f},
std::array<float,2>{0.653427005f, 0.290678054f},
std::array<float,2>{0.213554338f, 0.221112847f},
std::array<float,2>{0.902796626f, 0.560919881f},
std::array<float,2>{0.0794450343f, 0.917553663f},
std::array<float,2>{0.841099322f, 0.356383413f},
std::array<float,2>{0.290330201f, 0.171828687f},
std::array<float,2>{0.57695508f, 0.569938242f},
std::array<float,2>{0.463399351f, 0.631691456f},
std::array<float,2>{0.715004921f, 0.0833272263f},
std::array<float,2>{0.165209308f, 0.402507246f},
std::array<float,2>{0.974279344f, 0.834766626f},
std::array<float,2>{0.242138743f, 0.521149457f},
std::array<float,2>{0.930308282f, 0.196024731f},
std::array<float,2>{0.403468847f, 0.252546251f},
std::array<float,2>{0.670144737f, 0.971465409f},
std::array<float,2>{0.35826382f, 0.809445322f},
std::array<float,2>{0.515956342f, 0.448265016f},
std::array<float,2>{0.0605043024f, 0.0241710655f},
std::array<float,2>{0.78573817f, 0.702649057f},
std::array<float,2>{0.191591963f, 0.992807984f},
std::array<float,2>{0.888448596f, 0.280081451f},
std::array<float,2>{0.429504275f, 0.212081701f},
std::array<float,2>{0.639994562f, 0.500241339f},
std::array<float,2>{0.314983249f, 0.708995163f},
std::array<float,2>{0.541878581f, 0.00969289057f},
std::array<float,2>{0.0104649048f, 0.466554344f},
std::array<float,2>{0.772847474f, 0.793197274f},
std::array<float,2>{0.124210693f, 0.586107254f},
std::array<float,2>{0.854005218f, 0.183430493f},
std::array<float,2>{0.26946944f, 0.365034491f},
std::array<float,2>{0.607769787f, 0.931620717f},
std::array<float,2>{0.493031025f, 0.825181246f},
std::array<float,2>{0.738752961f, 0.386477113f},
std::array<float,2>{0.14929989f, 0.0649971813f},
std::array<float,2>{0.945886552f, 0.641105533f},
std::array<float,2>{0.0414173938f, 0.757835746f},
std::array<float,2>{0.798691869f, 0.479243904f},
std::array<float,2>{0.372815728f, 0.0374985412f},
std::array<float,2>{0.512094021f, 0.735643566f},
std::array<float,2>{0.376639068f, 0.534666359f},
std::array<float,2>{0.681152761f, 0.247107431f},
std::array<float,2>{0.228463963f, 0.307259232f},
std::array<float,2>{0.918591678f, 0.952940345f},
std::array<float,2>{0.180165708f, 0.657295048f},
std::array<float,2>{0.998758733f, 0.124398783f},
std::array<float,2>{0.451254636f, 0.424722701f},
std::array<float,2>{0.689927042f, 0.849045277f},
std::array<float,2>{0.305109948f, 0.892739475f},
std::array<float,2>{0.58236748f, 0.336499631f},
std::array<float,2>{0.0664146319f, 0.13187246f},
std::array<float,2>{0.822875798f, 0.608325541f},
std::array<float,2>{0.172756717f, 0.768267393f},
std::array<float,2>{0.98855108f, 0.485487789f},
std::array<float,2>{0.442787379f, 0.0579537638f},
std::array<float,2>{0.697647691f, 0.721254766f},
std::array<float,2>{0.298469603f, 0.556815445f},
std::array<float,2>{0.593273282f, 0.22525996f},
std::array<float,2>{0.0768682286f, 0.29364121f},
std::array<float,2>{0.819012463f, 0.968547523f},
std::array<float,2>{0.0378533266f, 0.681080401f},
std::array<float,2>{0.812173069f, 0.0943590701f},
std::array<float,2>{0.366637409f, 0.414595306f},
std::array<float,2>{0.50280565f, 0.864279807f},
std::array<float,2>{0.383830965f, 0.882721245f},
std::array<float,2>{0.674877286f, 0.317792505f},
std::array<float,2>{0.222749144f, 0.142111495f},
std::array<float,2>{0.91113627f, 0.610426366f},
std::array<float,2>{0.112548046f, 0.975041091f},
std::array<float,2>{0.845459044f, 0.255078644f},
std::array<float,2>{0.279939413f, 0.199553952f},
std::array<float,2>{0.596696496f, 0.518810391f},
std::array<float,2>{0.485091448f, 0.695828557f},
std::array<float,2>{0.748952687f, 0.0298561547f},
std::array<float,2>{0.141232327f, 0.450265348f},
std::array<float,2>{0.941946268f, 0.807766795f},
std::array<float,2>{0.199629739f, 0.562555611f},
std::array<float,2>{0.877228141f, 0.165287793f},
std::array<float,2>{0.430052906f, 0.353799373f},
std::array<float,2>{0.63164717f, 0.920353472f},
std::array<float,2>{0.325375795f, 0.831773221f},
std::array<float,2>{0.532823503f, 0.401530236f},
std::array<float,2>{0.00337474351f, 0.0790341944f},
std::array<float,2>{0.776535332f, 0.626619756f},
std::array<float,2>{0.245208234f, 0.933774352f},
std::array<float,2>{0.922770441f, 0.361403197f},
std::array<float,2>{0.393458217f, 0.184124827f},
std::array<float,2>{0.658143282f, 0.591503799f},
std::array<float,2>{0.348332614f, 0.64571625f},
std::array<float,2>{0.526523352f, 0.0681686252f},
std::array<float,2>{0.050413914f, 0.389407367f},
std::array<float,2>{0.794293821f, 0.823093116f},
std::array<float,2>{0.0912875384f, 0.505872548f},
std::array<float,2>{0.835554719f, 0.217444643f},
std::array<float,2>{0.28177312f, 0.275040388f},
std::array<float,2>{0.567686975f, 0.999764383f},
std::array<float,2>{0.454335183f, 0.790319145f},
std::array<float,2>{0.704829574f, 0.462020069f},
std::array<float,2>{0.157281235f, 0.0131774182f},
std::array<float,2>{0.978347242f, 0.704259157f},
std::array<float,2>{0.0245774835f, 0.847334087f},
std::array<float,2>{0.763480186f, 0.429156393f},
std::array<float,2>{0.32950452f, 0.118725501f},
std::array<float,2>{0.558842897f, 0.663636446f},
std::array<float,2>{0.412021428f, 0.603171647f},
std::array<float,2>{0.64784801f, 0.12566112f},
std::array<float,2>{0.210889861f, 0.34107247f},
std::array<float,2>{0.895624459f, 0.896072805f},
std::array<float,2>{0.134465858f, 0.74207598f},
std::array<float,2>{0.96562016f, 0.0336533524f},
std::array<float,2>{0.470147282f, 0.482070774f},
std::array<float,2>{0.726857662f, 0.764743149f},
std::array<float,2>{0.25940907f, 0.946554303f},
std::array<float,2>{0.618144929f, 0.312070042f},
std::array<float,2>{0.098399356f, 0.242612422f},
std::array<float,2>{0.860127807f, 0.537143052f},
std::array<float,2>{0.215838671f, 0.817411482f},
std::array<float,2>{0.899676681f, 0.3818084f},
std::array<float,2>{0.421872348f, 0.0727150962f},
std::array<float,2>{0.648942828f, 0.651627481f},
std::array<float,2>{0.338621855f, 0.581986487f},
std::array<float,2>{0.554382145f, 0.176315755f},
std::array<float,2>{0.0162424296f, 0.372854799f},
std::array<float,2>{0.755970597f, 0.924473941f},
std::array<float,2>{0.104801796f, 0.716488898f},
std::array<float,2>{0.869773507f, 0.00542410184f},
std::array<float,2>{0.25346902f, 0.458038628f},
std::array<float,2>{0.616559744f, 0.785448968f},
std::array<float,2>{0.477859229f, 0.99156487f},
std::array<float,2>{0.725963771f, 0.27211374f},
std::array<float,2>{0.13113223f, 0.209370822f},
std::array<float,2>{0.958545566f, 0.507888436f},
std::array<float,2>{0.0558527336f, 0.901330233f},
std::array<float,2>{0.784148097f, 0.332835585f},
std::array<float,2>{0.352454543f, 0.135652572f},
std::array<float,2>{0.522481859f, 0.60019666f},
std::array<float,2>{0.398914427f, 0.669377387f},
std::array<float,2>{0.664110661f, 0.116742119f},
std::array<float,2>{0.23571521f, 0.434786558f},
std::array<float,2>{0.937318206f, 0.854546845f},
std::array<float,2>{0.168313548f, 0.53991735f},
std::array<float,2>{0.970974803f, 0.234633386f},
std::array<float,2>{0.467320502f, 0.30357185f},
std::array<float,2>{0.712162077f, 0.940247059f},
std::array<float,2>{0.295167357f, 0.753902555f},
std::array<float,2>{0.572290838f, 0.469441086f},
std::array<float,2>{0.0852482915f, 0.0427978002f},
std::array<float,2>{0.837176025f, 0.747839034f},
std::array<float,2>{0.153912067f, 0.958750427f},
std::array<float,2>{0.949952245f, 0.283396095f},
std::array<float,2>{0.499619126f, 0.231029972f},
std::array<float,2>{0.734861314f, 0.551001251f},
std::array<float,2>{0.269602656f, 0.727573633f},
std::array<float,2>{0.603956759f, 0.0471317582f},
std::array<float,2>{0.117396906f, 0.494412512f},
std::array<float,2>{0.857109427f, 0.775992513f},
std::array<float,2>{0.0140245147f, 0.62121278f},
std::array<float,2>{0.766146362f, 0.151720569f},
std::array<float,2>{0.31989783f, 0.320387393f},
std::array<float,2>{0.544719994f, 0.887230277f},
std::array<float,2>{0.425498098f, 0.869561076f},
std::array<float,2>{0.636230886f, 0.406370729f},
std::array<float,2>{0.190296918f, 0.103453547f},
std::array<float,2>{0.885190189f, 0.67776382f},
std::array<float,2>{0.0631282628f, 0.802586854f},
std::array<float,2>{0.826547921f, 0.438237131f},
std::array<float,2>{0.310080647f, 0.0168146547f},
std::array<float,2>{0.579401731f, 0.694841087f},
std::array<float,2>{0.447245181f, 0.528839052f},
std::array<float,2>{0.69351542f, 0.188615963f},
std::array<float,2>{0.18525137f, 0.263205558f},
std::array<float,2>{0.993860602f, 0.981330216f},
std::array<float,2>{0.231633902f, 0.640061915f},
std::array<float,2>{0.915773511f, 0.0913401842f},
std::array<float,2>{0.378911436f, 0.394528806f},
std::array<float,2>{0.683948517f, 0.84290266f},
std::array<float,2>{0.367949426f, 0.906558931f},
std::array<float,2>{0.508930385f, 0.344161302f},
std::array<float,2>{0.0438165478f, 0.162936315f},
std::array<float,2>{0.803444743f, 0.576672256f},
std::array<float,2>{0.198085293f, 0.756538212f},
std::array<float,2>{0.882418692f, 0.473927259f},
std::array<float,2>{0.433670282f, 0.0446733944f},
std::array<float,2>{0.625428379f, 0.743235767f},
std::array<float,2>{0.321711928f, 0.545590103f},
std::array<float,2>{0.537118077f, 0.239677399f},
std::array<float,2>{0.00753608393f, 0.297137499f},
std::array<float,2>{0.778366148f, 0.943818569f},
std::array<float,2>{0.11486046f, 0.667508125f},
std::array<float,2>{0.851133406f, 0.110905819f},
std::array<float,2>{0.275390923f, 0.432763904f},
std::array<float,2>{0.599153161f, 0.858182728f},
std::array<float,2>{0.488698065f, 0.905974627f},
std::array<float,2>{0.74350065f, 0.328904182f},
std::array<float,2>{0.145463943f, 0.139963508f},
std::array<float,2>{0.940463424f, 0.594422638f},
std::array<float,2>{0.0335705243f, 0.987240791f},
std::array<float,2>{0.805558622f, 0.265780002f},
std::array<float,2>{0.361704826f, 0.204790726f},
std::array<float,2>{0.50392735f, 0.513544977f},
std::array<float,2>{0.387898743f, 0.713774204f},
std::array<float,2>{0.676841259f, 0.00373937516f},
std::array<float,2>{0.220179215f, 0.455869704f},
std::array<float,2>{0.908355534f, 0.784090459f},
std::array<float,2>{0.177341521f, 0.585368276f},
std::array<float,2>{0.985043466f, 0.175658762f},
std::array<float,2>{0.440184504f, 0.370976835f},
std::array<float,2>{0.700203538f, 0.927188456f},
std::array<float,2>{0.30448252f, 0.815975428f},
std::array<float,2>{0.586403131f, 0.378296882f},
std::array<float,2>{0.0705273077f, 0.0764204562f},
std::array<float,2>{0.813370883f, 0.65587008f},
std::array<float,2>{0.140156314f, 0.913771033f},
std::array<float,2>{0.961682379f, 0.350618392f},
std::array<float,2>{0.475378007f, 0.1573769f},
std::array<float,2>{0.731999338f, 0.573463678f},
std::array<float,2>{0.263841748f, 0.633442342f},
std::array<float,2>{0.624745607f, 0.0871144012f},
std::array<float,2>{0.0938765332f, 0.395193428f},
std::array<float,2>{0.867020726f, 0.837925017f},
std::array<float,2>{0.0280969739f, 0.526936114f},
std::array<float,2>{0.76147759f, 0.195094511f},
std::array<float,2>{0.334083617f, 0.261696398f},
std::array<float,2>{0.555312991f, 0.979191899f},
std::array<float,2>{0.407515079f, 0.799663901f},
std::array<float,2>{0.643110037f, 0.444848537f},
std::array<float,2>{0.204128996f, 0.02015399f},
std::array<float,2>{0.890923858f, 0.688946307f},
std::array<float,2>{0.0876693353f, 0.874323606f},
std::array<float,2>{0.828386009f, 0.412616521f},
std::array<float,2>{0.288592786f, 0.109296836f},
std::array<float,2>{0.566013098f, 0.672050595f},
std::array<float,2>{0.458089888f, 0.617817879f},
std::array<float,2>{0.708584905f, 0.153453812f},
std::array<float,2>{0.162674814f, 0.325489044f},
std::array<float,2>{0.984362185f, 0.885132313f},
std::array<float,2>{0.247646078f, 0.730700076f},
std::array<float,2>{0.929185152f, 0.052153904f},
std::array<float,2>{0.396783799f, 0.49678269f},
std::array<float,2>{0.660379529f, 0.779996455f},
std::array<float,2>{0.343953669f, 0.955191612f},
std::array<float,2>{0.528494179f, 0.287848979f},
std::array<float,2>{0.0537868738f, 0.230458066f},
std::array<float,2>{0.792363942f, 0.547648251f},
std::array<float,2>{0.16676572f, 0.832473516f},
std::array<float,2>{0.976325035f, 0.40483138f},
std::array<float,2>{0.461721718f, 0.0858247057f},
std::array<float,2>{0.717424929f, 0.629673541f},
std::array<float,2>{0.292159379f, 0.567892849f},
std::array<float,2>{0.574912012f, 0.169711292f},
std::array<float,2>{0.0809853896f, 0.358846307f},
std::array<float,2>{0.842653573f, 0.915999889f},
std::array<float,2>{0.0605584495f, 0.700519204f},
std::array<float,2>{0.787669361f, 0.0259614903f},
std::array<float,2>{0.356440216f, 0.446950018f},
std::array<float,2>{0.518450737f, 0.812096119f},
std::array<float,2>{0.404464483f, 0.968769789f},
std::array<float,2>{0.668194771f, 0.250797749f},
std::array<float,2>{0.239406124f, 0.197487667f},
std::array<float,2>{0.932023466f, 0.522497833f},
std::array<float,2>{0.107744925f, 0.876716256f},
std::array<float,2>{0.873105407f, 0.315371692f},
std::array<float,2>{0.256301343f, 0.146402925f},
std::array<float,2>{0.610678494f, 0.616397679f},
std::array<float,2>{0.482711494f, 0.686755836f},
std::array<float,2>{0.722093999f, 0.0983594134f},
std::array<float,2>{0.128558606f, 0.419495612f},
std::array<float,2>{0.953454852f, 0.861624718f},
std::array<float,2>{0.212299228f, 0.55998826f},
std::array<float,2>{0.905866206f, 0.219178721f},
std::array<float,2>{0.416394323f, 0.291893005f},
std::array<float,2>{0.654429436f, 0.963795185f},
std::array<float,2>{0.34370929f, 0.771532595f},
std::array<float,2>{0.546924472f, 0.489044726f},
std::array<float,2>{0.0204713065f, 0.0621981248f},
std::array<float,2>{0.752033532f, 0.723228097f},
std::array<float,2>{0.229394704f, 0.950505495f},
std::array<float,2>{0.921824276f, 0.305068582f},
std::array<float,2>{0.377444327f, 0.249882549f},
std::array<float,2>{0.681947231f, 0.53313458f},
std::array<float,2>{0.373222858f, 0.737263262f},
std::array<float,2>{0.514118671f, 0.0361924693f},
std::array<float,2>{0.0391507298f, 0.477428019f},
std::array<float,2>{0.799500525f, 0.760323048f},
std::array<float,2>{0.0684069395f, 0.607210457f},
std::array<float,2>{0.820685565f, 0.130199984f},
std::array<float,2>{0.307015061f, 0.338350415f},
std::array<float,2>{0.584069908f, 0.891224384f},
std::array<float,2>{0.449532062f, 0.850570321f},
std::array<float,2>{0.687760651f, 0.421931773f},
std::array<float,2>{0.183088318f, 0.122405395f},
std::array<float,2>{0.996324241f, 0.658891559f},
std::array<float,2>{0.00911379792f, 0.795334816f},
std::array<float,2>{0.770246804f, 0.467427462f},
std::array<float,2>{0.312592179f, 0.0103182094f},
std::array<float,2>{0.539916992f, 0.708066344f},
std::array<float,2>{0.426654577f, 0.502857268f},
std::array<float,2>{0.637615144f, 0.214081496f},
std::array<float,2>{0.193835363f, 0.277849585f},
std::array<float,2>{0.889279008f, 0.995535314f},
std::array<float,2>{0.150430411f, 0.643472433f},
std::array<float,2>{0.947959185f, 0.0637433231f},
std::array<float,2>{0.494956821f, 0.384640127f},
std::array<float,2>{0.741798759f, 0.827152312f},
std::array<float,2>{0.266379952f, 0.932413697f},
std::array<float,2>{0.606877208f, 0.36631164f},
std::array<float,2>{0.121610753f, 0.180256039f},
std::array<float,2>{0.852881193f, 0.58809793f},
std::array<float,2>{0.143581629f, 0.805044115f},
std::array<float,2>{0.943932593f, 0.452207983f},
std::array<float,2>{0.48635295f, 0.0284119733f},
std::array<float,2>{0.747669578f, 0.698411167f},
std::array<float,2>{0.278624743f, 0.515904725f},
std::array<float,2>{0.5937953f, 0.201355308f},
std::array<float,2>{0.11002107f, 0.257085174f},
std::array<float,2>{0.846620917f, 0.973891914f},
std::array<float,2>{0.000955544354f, 0.628429294f},
std::array<float,2>{0.774451613f, 0.0814432874f},
std::array<float,2>{0.327537924f, 0.400023848f},
std::array<float,2>{0.533825159f, 0.829581499f},
std::array<float,2>{0.433404356f, 0.919632375f},
std::array<float,2>{0.630144238f, 0.352751285f},
std::array<float,2>{0.203014091f, 0.167323694f},
std::array<float,2>{0.875861883f, 0.56582135f},
std::array<float,2>{0.0757563412f, 0.964991748f},
std::array<float,2>{0.817756891f, 0.295016885f},
std::array<float,2>{0.300364137f, 0.223268762f},
std::array<float,2>{0.590685129f, 0.554898381f},
std::array<float,2>{0.443967909f, 0.719778955f},
std::array<float,2>{0.69680196f, 0.0551334471f},
std::array<float,2>{0.17438966f, 0.486386836f},
std::array<float,2>{0.990970671f, 0.76671046f},
std::array<float,2>{0.225765824f, 0.611667156f},
std::array<float,2>{0.913289428f, 0.143360123f},
std::array<float,2>{0.384861499f, 0.320263088f},
std::array<float,2>{0.672296405f, 0.879435837f},
std::array<float,2>{0.364592522f, 0.865383804f},
std::array<float,2>{0.501313627f, 0.416315913f},
std::array<float,2>{0.0365421809f, 0.095859319f},
std::array<float,2>{0.810202777f, 0.68326056f},
std::array<float,2>{0.208245978f, 0.896963894f},
std::array<float,2>{0.896839082f, 0.34210673f},
std::array<float,2>{0.413333654f, 0.128367633f},
std::array<float,2>{0.645855129f, 0.604842484f},
std::array<float,2>{0.331559271f, 0.661652446f},
std::array<float,2>{0.561658382f, 0.119198762f},
std::array<float,2>{0.0267967619f, 0.426184148f},
std::array<float,2>{0.764648139f, 0.844365656f},
std::array<float,2>{0.0997722447f, 0.535564005f},
std::array<float,2>{0.86144191f, 0.245498657f},
std::array<float,2>{0.260500133f, 0.309204459f},
std::array<float,2>{0.620958626f, 0.948678136f},
std::array<float,2>{0.472507983f, 0.76197052f},
std::array<float,2>{0.730189502f, 0.483275563f},
std::array<float,2>{0.136021733f, 0.0325456932f},
std::array<float,2>{0.966802716f, 0.739870489f},
std::array<float,2>{0.0478677563f, 0.822150588f},
std::array<float,2>{0.796658039f, 0.387503028f},
std::array<float,2>{0.349776566f, 0.0689623281f},
std::array<float,2>{0.525174797f, 0.646561921f},
std::array<float,2>{0.392273158f, 0.592363715f},
std::array<float,2>{0.65973556f, 0.187023401f},
std::array<float,2>{0.242998615f, 0.360809058f},
std::array<float,2>{0.923885345f, 0.936487436f},
std::array<float,2>{0.158257902f, 0.70677501f},
std::array<float,2>{0.978709936f, 0.0154437656f},
std::array<float,2>{0.456241488f, 0.463816166f},
std::array<float,2>{0.706399858f, 0.791298151f},
std::array<float,2>{0.283644795f, 0.996416807f},
std::array<float,2>{0.57029599f, 0.275518417f},
std::array<float,2>{0.0918159038f, 0.21667093f},
std::array<float,2>{0.833882391f, 0.504446387f},
std::array<float,2>{0.236403689f, 0.851902664f},
std::array<float,2>{0.935028434f, 0.436605304f},
std::array<float,2>{0.400633991f, 0.114097334f},
std::array<float,2>{0.666803777f, 0.671171665f},
std::array<float,2>{0.354218543f, 0.598671377f},
std::array<float,2>{0.519691944f, 0.133059502f},
std::array<float,2>{0.0571744479f, 0.334138632f},
std::array<float,2>{0.782544434f, 0.899969399f},
std::array<float,2>{0.082296133f, 0.749329627f},
std::array<float,2>{0.838824272f, 0.0407693535f},
std::array<float,2>{0.293784052f, 0.471378684f},
std::array<float,2>{0.571893394f, 0.751276493f},
std::array<float,2>{0.466171771f, 0.93770802f},
std::array<float,2>{0.714213789f, 0.301551729f},
std::array<float,2>{0.171306714f, 0.236915469f},
std::array<float,2>{0.970428884f, 0.542923033f},
std::array<float,2>{0.017788047f, 0.921944916f},
std::array<float,2>{0.753942966f, 0.37385571f},
std::array<float,2>{0.336488485f, 0.178550899f},
std::array<float,2>{0.551453769f, 0.578868747f},
std::array<float,2>{0.4181692f, 0.650061846f},
std::array<float,2>{0.650635421f, 0.070612371f},
std::array<float,2>{0.217359558f, 0.379870176f},
std::array<float,2>{0.901942551f, 0.819029868f},
std::array<float,2>{0.129526556f, 0.511583328f},
std::array<float,2>{0.960417092f, 0.208419338f},
std::array<float,2>{0.480331779f, 0.270500124f},
std::array<float,2>{0.72452569f, 0.988370061f},
std::array<float,2>{0.250754863f, 0.788873553f},
std::array<float,2>{0.615224898f, 0.459872961f},
std::array<float,2>{0.102039486f, 0.00629264722f},
std::array<float,2>{0.867907763f, 0.717862964f},
std::array<float,2>{0.186749801f, 0.98404187f},
std::array<float,2>{0.994388342f, 0.26509133f},
std::array<float,2>{0.448373705f, 0.190832615f},
std::array<float,2>{0.691910505f, 0.530902922f},
std::array<float,2>{0.312412798f, 0.692141175f},
std::array<float,2>{0.580085337f, 0.0187683497f},
std::array<float,2>{0.0652580857f, 0.439632863f},
std::array<float,2>{0.82506603f, 0.802997887f},
std::array<float,2>{0.0455914959f, 0.575773537f},
std::array<float,2>{0.801732123f, 0.161037341f},
std::array<float,2>{0.369259268f, 0.346859246f},
std::array<float,2>{0.510481119f, 0.909330845f},
std::array<float,2>{0.38155356f, 0.840980947f},
std::array<float,2>{0.686919808f, 0.392252952f},
std::array<float,2>{0.234131709f, 0.091987215f},
std::array<float,2>{0.916432381f, 0.63825953f},
std::array<float,2>{0.119446374f, 0.774204731f},
std::array<float,2>{0.857674122f, 0.493356258f},
std::array<float,2>{0.272666276f, 0.0495888107f},
std::array<float,2>{0.602748573f, 0.729447305f},
std::array<float,2>{0.497052789f, 0.553936303f},
std::array<float,2>{0.737452447f, 0.233603194f},
std::array<float,2>{0.154820621f, 0.282010674f},
std::array<float,2>{0.951742947f, 0.959103405f},
std::array<float,2>{0.188238427f, 0.675831854f},
std::array<float,2>{0.88308841f, 0.104767054f},
std::array<float,2>{0.423190802f, 0.408557028f},
std::array<float,2>{0.633610189f, 0.868499339f},
std::array<float,2>{0.316411346f, 0.888683856f},
std::array<float,2>{0.545157909f, 0.323768049f},
std::array<float,2>{0.0131473532f, 0.148501292f},
std::array<float,2>{0.76898545f, 0.624347508f},
std::array<float,2>{0.193876192f, 0.793733299f},
std::array<float,2>{0.888891459f, 0.46594438f},
std::array<float,2>{0.426226795f, 0.00900435541f},
std::array<float,2>{0.636831105f, 0.709698021f},
std::array<float,2>{0.313059539f, 0.500905573f},
std::array<float,2>{0.539387822f, 0.212817952f},
std::array<float,2>{0.00939396024f, 0.279394984f},
std::array<float,2>{0.769748151f, 0.992645323f},
std::array<float,2>{0.121405445f, 0.641312242f},
std::array<float,2>{0.853360415f, 0.0647246316f},
std::array<float,2>{0.265879184f, 0.385817826f},
std::array<float,2>{0.607351363f, 0.824647129f},
std::array<float,2>{0.494519889f, 0.930806816f},
std::array<float,2>{0.741340041f, 0.364285469f},
std::array<float,2>{0.151349768f, 0.183023781f},
std::array<float,2>{0.947495878f, 0.586810768f},
std::array<float,2>{0.0398048535f, 0.952500522f},
std::array<float,2>{0.799289584f, 0.307054877f},
std::array<float,2>{0.373929113f, 0.247816741f},
std::array<float,2>{0.514356613f, 0.535039306f},
std::array<float,2>{0.377236992f, 0.735956907f},
std::array<float,2>{0.682544589f, 0.0380521044f},
std::array<float,2>{0.228760555f, 0.478769243f},
std::array<float,2>{0.921148121f, 0.758767843f},
std::array<float,2>{0.183119416f, 0.60770005f},
std::array<float,2>{0.996869266f, 0.13279672f},
std::array<float,2>{0.450062096f, 0.336324483f},
std::array<float,2>{0.688150942f, 0.89316988f},
std::array<float,2>{0.307490021f, 0.849579394f},
std::array<float,2>{0.584540308f, 0.423863471f},
std::array<float,2>{0.0692417398f, 0.124760002f},
std::array<float,2>{0.821031272f, 0.658181727f},
std::array<float,2>{0.128222376f, 0.878742337f},
std::array<float,2>{0.954045832f, 0.314023405f},
std::array<float,2>{0.483279765f, 0.146669045f},
std::array<float,2>{0.722577631f, 0.614491999f},
std::array<float,2>{0.256353438f, 0.684247196f},
std::array<float,2>{0.611313581f, 0.101562396f},
std::array<float,2>{0.107982829f, 0.421812445f},
std::array<float,2>{0.873577476f, 0.860010505f},
std::array<float,2>{0.0199223477f, 0.561145365f},
std::array<float,2>{0.75265044f, 0.221467853f},
std::array<float,2>{0.342970997f, 0.290305078f},
std::array<float,2>{0.547422647f, 0.961803555f},
std::array<float,2>{0.416982919f, 0.771411717f},
std::array<float,2>{0.654886544f, 0.49103725f},
std::array<float,2>{0.212731615f, 0.0595107451f},
std::array<float,2>{0.905381083f, 0.725286186f},
std::array<float,2>{0.0801026523f, 0.834035754f},
std::array<float,2>{0.841802537f, 0.402989715f},
std::array<float,2>{0.292615086f, 0.083791241f},
std::array<float,2>{0.574452043f, 0.630936086f},
std::array<float,2>{0.461093098f, 0.569723427f},
std::array<float,2>{0.716850638f, 0.170909166f},
std::array<float,2>{0.166343421f, 0.355513901f},
std::array<float,2>{0.975787699f, 0.917324543f},
std::array<float,2>{0.240149736f, 0.702272713f},
std::array<float,2>{0.932137191f, 0.0234742053f},
std::array<float,2>{0.405115634f, 0.448904663f},
std::array<float,2>{0.6684708f, 0.808888197f},
std::array<float,2>{0.355485469f, 0.971072853f},
std::array<float,2>{0.518007338f, 0.251988947f},
std::array<float,2>{0.0612920523f, 0.19546181f},
std::array<float,2>{0.787361324f, 0.520784974f},
std::array<float,2>{0.162412375f, 0.871763587f},
std::array<float,2>{0.983579755f, 0.411238402f},
std::array<float,2>{0.458673149f, 0.107073724f},
std::array<float,2>{0.708455741f, 0.675424457f},
std::array<float,2>{0.288491547f, 0.61997956f},
std::array<float,2>{0.565562069f, 0.154477164f},
std::array<float,2>{0.0871187374f, 0.326327026f},
std::array<float,2>{0.828783274f, 0.884642184f},
std::array<float,2>{0.0543376803f, 0.733032584f},
std::array<float,2>{0.792889953f, 0.0546190403f},
std::array<float,2>{0.344481826f, 0.499647439f},
std::array<float,2>{0.528941274f, 0.779271305f},
std::array<float,2>{0.397325277f, 0.954168558f},
std::array<float,2>{0.660684884f, 0.285338134f},
std::array<float,2>{0.247195825f, 0.227664322f},
std::array<float,2>{0.929599106f, 0.550179303f},
std::array<float,2>{0.0945658535f, 0.910644472f},
std::array<float,2>{0.866544902f, 0.348013014f},
std::array<float,2>{0.264577359f, 0.15900369f},
std::array<float,2>{0.624220252f, 0.570660233f},
std::array<float,2>{0.474960744f, 0.636070132f},
std::array<float,2>{0.731715441f, 0.0887436345f},
std::array<float,2>{0.139759526f, 0.397148252f},
std::array<float,2>{0.961343765f, 0.837279916f},
std::array<float,2>{0.204945728f, 0.524854958f},
std::array<float,2>{0.891461194f, 0.192950323f},
std::array<float,2>{0.407729268f, 0.259618878f},
std::array<float,2>{0.642828584f, 0.978081644f},
std::array<float,2>{0.334693998f, 0.798638701f},
std::array<float,2>{0.555115819f, 0.443173289f},
std::array<float,2>{0.0275661927f, 0.0217401758f},
std::array<float,2>{0.760780513f, 0.690972269f},
std::array<float,2>{0.220578253f, 0.985609233f},
std::array<float,2>{0.909165084f, 0.26882273f},
std::array<float,2>{0.388272464f, 0.205956131f},
std::array<float,2>{0.677402079f, 0.514602721f},
std::array<float,2>{0.362124056f, 0.712445855f},
std::array<float,2>{0.50476414f, 0.000605858921f},
std::array<float,2>{0.0339210182f, 0.454943568f},
std::array<float,2>{0.804837823f, 0.78127259f},
std::array<float,2>{0.0708949342f, 0.58314991f},
std::array<float,2>{0.812518716f, 0.172979325f},
std::array<float,2>{0.303902417f, 0.368919462f},
std::array<float,2>{0.586680055f, 0.928512275f},
std::array<float,2>{0.439596415f, 0.813479543f},
std::array<float,2>{0.700991988f, 0.375158012f},
std::array<float,2>{0.176990852f, 0.0755273998f},
std::array<float,2>{0.98437798f, 0.652418852f},
std::array<float,2>{0.00729124853f, 0.753986061f},
std::array<float,2>{0.778850079f, 0.476373285f},
std::array<float,2>{0.322143495f, 0.0467938446f},
std::array<float,2>{0.537706852f, 0.74456811f},
std::array<float,2>{0.434402257f, 0.544487178f},
std::array<float,2>{0.625931859f, 0.241237342f},
std::array<float,2>{0.19770281f, 0.300047576f},
std::array<float,2>{0.882027924f, 0.942516625f},
std::array<float,2>{0.144573614f, 0.666004062f},
std::array<float,2>{0.941137791f, 0.112911612f},
std::array<float,2>{0.488985866f, 0.430166155f},
std::array<float,2>{0.743904769f, 0.856553137f},
std::array<float,2>{0.276178151f, 0.903327227f},
std::array<float,2>{0.598676085f, 0.33164078f},
std::array<float,2>{0.114539951f, 0.136911839f},
std::array<float,2>{0.850723624f, 0.597435474f},
std::array<float,2>{0.154577598f, 0.775678873f},
std::array<float,2>{0.951497912f, 0.494967431f},
std::array<float,2>{0.49615398f, 0.0477999859f},
std::array<float,2>{0.738065183f, 0.728433549f},
std::array<float,2>{0.272981435f, 0.551500261f},
std::array<float,2>{0.603356004f, 0.230896696f},
std::array<float,2>{0.119685099f, 0.28372246f},
std::array<float,2>{0.858103693f, 0.958111882f},
std::array<float,2>{0.0133049162f, 0.678450406f},
std::array<float,2>{0.769384682f, 0.102809139f},
std::array<float,2>{0.317230731f, 0.406792939f},
std::array<float,2>{0.545785189f, 0.869969547f},
std::array<float,2>{0.423819929f, 0.886766672f},
std::array<float,2>{0.633283675f, 0.32109791f},
std::array<float,2>{0.187705234f, 0.151964247f},
std::array<float,2>{0.883345962f, 0.621776104f},
std::array<float,2>{0.0647474155f, 0.980917275f},
std::array<float,2>{0.824414134f, 0.263137162f},
std::array<float,2>{0.311875343f, 0.189093128f},
std::array<float,2>{0.580800235f, 0.528558791f},
std::array<float,2>{0.449106067f, 0.69453764f},
std::array<float,2>{0.691823184f, 0.0171111971f},
std::array<float,2>{0.187091082f, 0.437528789f},
std::array<float,2>{0.994641781f, 0.801820636f},
std::array<float,2>{0.233547986f, 0.576423466f},
std::array<float,2>{0.916874588f, 0.162478223f},
std::array<float,2>{0.381143063f, 0.344657212f},
std::array<float,2>{0.687186003f, 0.906921387f},
std::array<float,2>{0.370064944f, 0.843548656f},
std::array<float,2>{0.510253608f, 0.393679321f},
std::array<float,2>{0.0453903638f, 0.09096504f},
std::array<float,2>{0.80083698f, 0.640505314f},
std::array<float,2>{0.216989413f, 0.924125731f},
std::array<float,2>{0.901631057f, 0.372194648f},
std::array<float,2>{0.418894708f, 0.176054567f},
std::array<float,2>{0.651126444f, 0.581381977f},
std::array<float,2>{0.336326599f, 0.652278602f},
std::array<float,2>{0.551159143f, 0.0728433654f},
std::array<float,2>{0.0181835461f, 0.381276637f},
std::array<float,2>{0.754861891f, 0.81795764f},
std::array<float,2>{0.102431431f, 0.508585811f},
std::array<float,2>{0.867287815f, 0.209604889f},
std::array<float,2>{0.250477999f, 0.271831334f},
std::array<float,2>{0.614420891f, 0.991947949f},
std::array<float,2>{0.479579121f, 0.785751343f},
std::array<float,2>{0.723899066f, 0.458943158f},
std::array<float,2>{0.129259363f, 0.00499923015f},
std::array<float,2>{0.960679412f, 0.715894222f},
std::array<float,2>{0.0569158979f, 0.85531044f},
std::array<float,2>{0.782937706f, 0.435373276f},
std::array<float,2>{0.35358274f, 0.116418064f},
std::array<float,2>{0.520401597f, 0.669630587f},
std::array<float,2>{0.400948733f, 0.599908471f},
std::array<float,2>{0.666124701f, 0.135211378f},
std::array<float,2>{0.237280831f, 0.332169056f},
std::array<float,2>{0.935318947f, 0.900496066f},
std::array<float,2>{0.171552703f, 0.747407734f},
std::array<float,2>{0.96999675f, 0.0423260964f},
std::array<float,2>{0.466459781f, 0.468947619f},
std::array<float,2>{0.714490771f, 0.753004193f},
std::array<float,2>{0.29334873f, 0.939688802f},
std::array<float,2>{0.571678817f, 0.302819252f},
std::array<float,2>{0.0829391703f, 0.234900221f},
std::array<float,2>{0.837970495f, 0.539303422f},
std::array<float,2>{0.242661282f, 0.82265991f},
std::array<float,2>{0.924499512f, 0.388924062f},
std::array<float,2>{0.391971141f, 0.0675293654f},
std::array<float,2>{0.659400225f, 0.646159589f},
std::array<float,2>{0.350412726f, 0.59103781f},
std::array<float,2>{0.52460736f, 0.18392919f},
std::array<float,2>{0.0484524183f, 0.36218226f},
std::array<float,2>{0.796188414f, 0.934566259f},
std::array<float,2>{0.092554301f, 0.704995036f},
std::array<float,2>{0.833077133f, 0.013402313f},
std::array<float,2>{0.283760279f, 0.462715507f},
std::array<float,2>{0.56934762f, 0.79054445f},
std::array<float,2>{0.456682295f, 0.999471486f},
std::array<float,2>{0.707012594f, 0.274820894f},
std::array<float,2>{0.158735991f, 0.216968223f},
std::array<float,2>{0.979316831f, 0.506355405f},
std::array<float,2>{0.0271472055f, 0.895570099f},
std::array<float,2>{0.763864338f, 0.341336131f},
std::array<float,2>{0.331319988f, 0.125226468f},
std::array<float,2>{0.562404454f, 0.602638662f},
std::array<float,2>{0.413635254f, 0.663446069f},
std::array<float,2>{0.646466255f, 0.118642621f},
std::array<float,2>{0.20890379f, 0.429270297f},
std::array<float,2>{0.897435963f, 0.846931934f},
std::array<float,2>{0.136280969f, 0.538000226f},
std::array<float,2>{0.96761471f, 0.242915377f},
std::array<float,2>{0.47170645f, 0.311760187f},
std::array<float,2>{0.729719698f, 0.947222054f},
std::array<float,2>{0.259802788f, 0.765248656f},
std::array<float,2>{0.620420814f, 0.481927782f},
std::array<float,2>{0.100520715f, 0.0338100269f},
std::array<float,2>{0.861974597f, 0.741661549f},
std::array<float,2>{0.17426309f, 0.967915058f},
std::array<float,2>{0.990515232f, 0.293181539f},
std::array<float,2>{0.443570673f, 0.2246259f},
std::array<float,2>{0.696333289f, 0.557465494f},
std::array<float,2>{0.299965799f, 0.721137166f},
std::array<float,2>{0.590269327f, 0.0585049875f},
std::array<float,2>{0.0753872842f, 0.486309111f},
std::array<float,2>{0.818271339f, 0.767578244f},
std::array<float,2>{0.0366385542f, 0.61117053f},
std::array<float,2>{0.809942782f, 0.141699165f},
std::array<float,2>{0.365052015f, 0.31808871f},
std::array<float,2>{0.501492202f, 0.881895244f},
std::array<float,2>{0.38556686f, 0.864949524f},
std::array<float,2>{0.672618747f, 0.414213359f},
std::array<float,2>{0.226175413f, 0.0941004157f},
std::array<float,2>{0.914019346f, 0.681586742f},
std::array<float,2>{0.109609067f, 0.808138251f},
std::array<float,2>{0.845901847f, 0.450888008f},
std::array<float,2>{0.279294819f, 0.0297786389f},
std::array<float,2>{0.594394267f, 0.695659041f},
std::array<float,2>{0.487097234f, 0.519155025f},
std::array<float,2>{0.747356772f, 0.199833795f},
std::array<float,2>{0.144233093f, 0.255841345f},
std::array<float,2>{0.94366765f, 0.97549057f},
std::array<float,2>{0.202597201f, 0.626391053f},
std::array<float,2>{0.875380993f, 0.0781760514f},
std::array<float,2>{0.432784796f, 0.402000964f},
std::array<float,2>{0.630436838f, 0.83106041f},
std::array<float,2>{0.327828199f, 0.920413256f},
std::array<float,2>{0.533444047f, 0.354052186f},
std::array<float,2>{0.000376929151f, 0.165980309f},
std::array<float,2>{0.775236249f, 0.56311512f},
std::array<float,2>{0.227881521f, 0.759789824f},
std::array<float,2>{0.918274224f, 0.476843536f},
std::array<float,2>{0.376320064f, 0.0366381481f},
std::array<float,2>{0.680992603f, 0.736528277f},
std::array<float,2>{0.372464001f, 0.532400191f},
std::array<float,2>{0.512330711f, 0.249505267f},
std::array<float,2>{0.0416121781f, 0.305658937f},
std::array<float,2>{0.798321903f, 0.95102042f},
std::array<float,2>{0.067163147f, 0.65856564f},
std::array<float,2>{0.822625339f, 0.122857265f},
std::array<float,2>{0.305248767f, 0.422780067f},
std::array<float,2>{0.582962632f, 0.849861085f},
std::array<float,2>{0.451857686f, 0.890822589f},
std::array<float,2>{0.690067112f, 0.338796169f},
std::array<float,2>{0.180414036f, 0.130558714f},
std::array<float,2>{0.998522997f, 0.606717229f},
std::array<float,2>{0.00991060305f, 0.996090889f},
std::array<float,2>{0.773371398f, 0.27757293f},
std::array<float,2>{0.31490466f, 0.214756593f},
std::array<float,2>{0.541496754f, 0.502174795f},
std::array<float,2>{0.428844243f, 0.708685875f},
std::array<float,2>{0.640556991f, 0.0102200527f},
std::array<float,2>{0.192354724f, 0.467185527f},
std::array<float,2>{0.887749314f, 0.79572922f},
std::array<float,2>{0.148904026f, 0.588444829f},
std::array<float,2>{0.945725679f, 0.179898098f},
std::array<float,2>{0.492324412f, 0.36671102f},
std::array<float,2>{0.739116311f, 0.93165803f},
std::array<float,2>{0.269016176f, 0.827947855f},
std::array<float,2>{0.608110964f, 0.384043545f},
std::array<float,2>{0.124856584f, 0.0640858635f},
std::array<float,2>{0.853639126f, 0.642759025f},
std::array<float,2>{0.165760651f, 0.915127218f},
std::array<float,2>{0.97376889f, 0.358972847f},
std::array<float,2>{0.463027f, 0.169047609f},
std::array<float,2>{0.715659499f, 0.567425191f},
std::array<float,2>{0.290537f, 0.62893182f},
std::array<float,2>{0.576420069f, 0.0853932798f},
std::array<float,2>{0.0800029933f, 0.404297024f},
std::array<float,2>{0.841402173f, 0.832533717f},
std::array<float,2>{0.0599614643f, 0.52318871f},
std::array<float,2>{0.78550452f, 0.197805583f},
std::array<float,2>{0.357716113f, 0.250011027f},
std::array<float,2>{0.516455173f, 0.969647169f},
std::array<float,2>{0.403833061f, 0.81168443f},
std::array<float,2>{0.670506179f, 0.446499735f},
std::array<float,2>{0.241615191f, 0.0257146023f},
std::array<float,2>{0.929911315f, 0.701079786f},
std::array<float,2>{0.107066445f, 0.861987293f},
std::array<float,2>{0.871398091f, 0.419335604f},
std::array<float,2>{0.255574048f, 0.0979282483f},
std::array<float,2>{0.612676024f, 0.68739295f},
std::array<float,2>{0.482092232f, 0.616780221f},
std::array<float,2>{0.719377637f, 0.145949572f},
std::array<float,2>{0.125985697f, 0.314606279f},
std::array<float,2>{0.955682397f, 0.876453578f},
std::array<float,2>{0.212992087f, 0.722937465f},
std::array<float,2>{0.903143585f, 0.0615565814f},
std::array<float,2>{0.414606065f, 0.488501847f},
std::array<float,2>{0.653879583f, 0.77199918f},
std::array<float,2>{0.340088814f, 0.963075638f},
std::array<float,2>{0.549996197f, 0.291076839f},
std::array<float,2>{0.022146184f, 0.219502449f},
std::array<float,2>{0.751331985f, 0.560138941f},
std::array<float,2>{0.138341531f, 0.838832259f},
std::array<float,2>{0.964475572f, 0.394836366f},
std::array<float,2>{0.474212915f, 0.087491639f},
std::array<float,2>{0.733762622f, 0.633246481f},
std::array<float,2>{0.263550609f, 0.574213505f},
std::array<float,2>{0.621767819f, 0.158155903f},
std::array<float,2>{0.0958271101f, 0.351136237f},
std::array<float,2>{0.864657521f, 0.913480639f},
std::array<float,2>{0.0312110893f, 0.688995838f},
std::array<float,2>{0.759254098f, 0.0196185615f},
std::array<float,2>{0.333521187f, 0.444678396f},
std::array<float,2>{0.557356119f, 0.799271166f},
std::array<float,2>{0.408997744f, 0.978796542f},
std::array<float,2>{0.641432881f, 0.260935128f},
std::array<float,2>{0.206589505f, 0.194429919f},
std::array<float,2>{0.894478559f, 0.52652818f},
std::array<float,2>{0.0896562114f, 0.885489404f},
std::array<float,2>{0.831493497f, 0.325997829f},
std::array<float,2>{0.285862207f, 0.154090136f},
std::array<float,2>{0.564279377f, 0.617274165f},
std::array<float,2>{0.45970726f, 0.672689974f},
std::array<float,2>{0.709342062f, 0.108512759f},
std::array<float,2>{0.160836831f, 0.412368238f},
std::array<float,2>{0.980521083f, 0.874727845f},
std::array<float,2>{0.249660596f, 0.547260106f},
std::array<float,2>{0.92664963f, 0.229923621f},
std::array<float,2>{0.39566797f, 0.287143737f},
std::array<float,2>{0.663126171f, 0.955793619f},
std::array<float,2>{0.347102404f, 0.779517829f},
std::array<float,2>{0.529872835f, 0.496296108f},
std::array<float,2>{0.0513639115f, 0.0523234978f},
std::array<float,2>{0.790389895f, 0.731433153f},
std::array<float,2>{0.196964622f, 0.94425869f},
std::array<float,2>{0.879360497f, 0.297418445f},
std::array<float,2>{0.43725431f, 0.239796713f},
std::array<float,2>{0.627376676f, 0.54505688f},
std::array<float,2>{0.322494954f, 0.744114995f},
std::array<float,2>{0.536191702f, 0.0442469008f},
std::array<float,2>{0.00500412052f, 0.474330157f},
std::array<float,2>{0.780610144f, 0.755886674f},
std::array<float,2>{0.115472496f, 0.594047487f},
std::array<float,2>{0.849551976f, 0.140467539f},
std::array<float,2>{0.274874359f, 0.328591168f},
std::array<float,2>{0.600696504f, 0.905735016f},
std::array<float,2>{0.49148187f, 0.857723773f},
std::array<float,2>{0.744562864f, 0.433185697f},
std::array<float,2>{0.14761731f, 0.110729963f},
std::array<float,2>{0.93932569f, 0.667394042f},
std::array<float,2>{0.0323644355f, 0.783449173f},
std::array<float,2>{0.807955921f, 0.455387473f},
std::array<float,2>{0.360257357f, 0.00329343532f},
std::array<float,2>{0.506423295f, 0.713219821f},
std::array<float,2>{0.38873291f, 0.512807965f},
std::array<float,2>{0.679332495f, 0.204552472f},
std::array<float,2>{0.222429544f, 0.266192555f},
std::array<float,2>{0.907335579f, 0.986709297f},
std::array<float,2>{0.17855826f, 0.655549347f},
std::array<float,2>{0.987015247f, 0.0766682252f},
std::array<float,2>{0.438108414f, 0.378620088f},
std::array<float,2>{0.701922417f, 0.815600216f},
std::array<float,2>{0.301618546f, 0.927379727f},
std::array<float,2>{0.588773131f, 0.370155305f},
std::array<float,2>{0.0724233314f, 0.1751142f},
std::array<float,2>{0.815866292f, 0.585591972f},
std::array<float,2>{0.184911802f, 0.803252816f},
std::array<float,2>{0.99346292f, 0.440194935f},
std::array<float,2>{0.446695685f, 0.0192786865f},
std::array<float,2>{0.694178581f, 0.691893756f},
std::array<float,2>{0.30974406f, 0.530413032f},
std::array<float,2>{0.579833746f, 0.19102779f},
std::array<float,2>{0.0629395396f, 0.265540183f},
std::array<float,2>{0.82713151f, 0.983776689f},
std::array<float,2>{0.0431945883f, 0.638051331f},
std::array<float,2>{0.802782714f, 0.0925808623f},
std::array<float,2>{0.367380321f, 0.392030895f},
std::array<float,2>{0.50937742f, 0.841729641f},
std::array<float,2>{0.379645228f, 0.909917891f},
std::array<float,2>{0.684170783f, 0.34765321f},
std::array<float,2>{0.232014582f, 0.160389751f},
std::array<float,2>{0.915404677f, 0.575208426f},
std::array<float,2>{0.117983431f, 0.959944844f},
std::array<float,2>{0.856530666f, 0.28140381f},
std::array<float,2>{0.270292491f, 0.234354213f},
std::array<float,2>{0.604166329f, 0.554214358f},
std::array<float,2>{0.49925527f, 0.728869021f},
std::array<float,2>{0.734891713f, 0.0492770635f},
std::array<float,2>{0.153454408f, 0.494023263f},
std::array<float,2>{0.949320853f, 0.773839533f},
std::array<float,2>{0.189813212f, 0.624940097f},
std::array<float,2>{0.885411322f, 0.149022326f},
std::array<float,2>{0.425008416f, 0.323255539f},
std::array<float,2>{0.636006892f, 0.889504254f},
std::array<float,2>{0.31934163f, 0.869053543f},
std::array<float,2>{0.544278562f, 0.408753425f},
std::array<float,2>{0.0145764565f, 0.105263121f},
std::array<float,2>{0.766019642f, 0.676366806f},
std::array<float,2>{0.236050069f, 0.899818778f},
std::array<float,2>{0.936668754f, 0.334527969f},
std::array<float,2>{0.399135053f, 0.133463442f},
std::array<float,2>{0.664862037f, 0.599460483f},
std::array<float,2>{0.351944983f, 0.671424091f},
std::array<float,2>{0.523366451f, 0.11355307f},
std::array<float,2>{0.056509126f, 0.437188566f},
std::array<float,2>{0.783458054f, 0.852261841f},
std::array<float,2>{0.0855650306f, 0.542283833f},
std::array<float,2>{0.837702096f, 0.23666963f},
std::array<float,2>{0.295751572f, 0.300975204f},
std::array<float,2>{0.573104978f, 0.938076556f},
std::array<float,2>{0.467152327f, 0.751573503f},
std::array<float,2>{0.712750793f, 0.471155375f},
std::array<float,2>{0.16879116f, 0.0402186215f},
std::array<float,2>{0.971312404f, 0.749661624f},
std::array<float,2>{0.0156727713f, 0.818840683f},
std::array<float,2>{0.756411672f, 0.379143983f},
std::array<float,2>{0.338341326f, 0.0711675659f},
std::array<float,2>{0.554027438f, 0.649871469f},
std::array<float,2>{0.421035081f, 0.578233957f},
std::array<float,2>{0.648568213f, 0.178154677f},
std::array<float,2>{0.216664344f, 0.373188704f},
std::array<float,2>{0.900206804f, 0.922367632f},
std::array<float,2>{0.131672591f, 0.718710184f},
std::array<float,2>{0.958184004f, 0.00657128356f},
std::array<float,2>{0.478508025f, 0.459185362f},
std::array<float,2>{0.726419389f, 0.78831625f},
std::array<float,2>{0.253068864f, 0.988770962f},
std::array<float,2>{0.617015958f, 0.269741118f},
std::array<float,2>{0.105073318f, 0.208584294f},
std::array<float,2>{0.869330049f, 0.510859072f},
std::array<float,2>{0.210120395f, 0.843809247f},
std::array<float,2>{0.89645499f, 0.426306814f},
std::array<float,2>{0.411405832f, 0.120091446f},
std::array<float,2>{0.647992074f, 0.661553562f},
std::array<float,2>{0.329817504f, 0.605156779f},
std::array<float,2>{0.559414864f, 0.128597751f},
std::array<float,2>{0.0252570119f, 0.342597306f},
std::array<float,2>{0.762976885f, 0.897453308f},
std::array<float,2>{0.097756356f, 0.739280403f},
std::array<float,2>{0.859456658f, 0.0331247188f},
std::array<float,2>{0.258841366f, 0.48274526f},
std::array<float,2>{0.617478788f, 0.76232785f},
std::array<float,2>{0.470526248f, 0.948742092f},
std::array<float,2>{0.727294326f, 0.308940202f},
std::array<float,2>{0.133851305f, 0.245671779f},
std::array<float,2>{0.964892447f, 0.535723805f},
std::array<float,2>{0.0499227867f, 0.936019063f},
std::array<float,2>{0.794885099f, 0.361152202f},
std::array<float,2>{0.347722203f, 0.186948478f},
std::array<float,2>{0.526883364f, 0.591894567f},
std::array<float,2>{0.392700821f, 0.647200286f},
std::array<float,2>{0.657599449f, 0.0684053749f},
std::array<float,2>{0.245855421f, 0.386834979f},
std::array<float,2>{0.922236919f, 0.821403086f},
std::array<float,2>{0.158052504f, 0.50399226f},
std::array<float,2>{0.977568209f, 0.215821847f},
std::array<float,2>{0.454617709f, 0.275915861f},
std::array<float,2>{0.704427361f, 0.996747732f},
std::array<float,2>{0.281513065f, 0.791921258f},
std::array<float,2>{0.568285346f, 0.462916523f},
std::array<float,2>{0.0917224735f, 0.0147998715f},
std::array<float,2>{0.835232913f, 0.706527233f},
std::array<float,2>{0.140711278f, 0.974261045f},
std::array<float,2>{0.941686392f, 0.257350087f},
std::array<float,2>{0.484668136f, 0.201774657f},
std::array<float,2>{0.748530149f, 0.516312957f},
std::array<float,2>{0.279417127f, 0.698750854f},
std::array<float,2>{0.597590923f, 0.0291647092f},
std::array<float,2>{0.112850338f, 0.4529351f},
std::array<float,2>{0.845205426f, 0.805510104f},
std::array<float,2>{0.00368790841f, 0.565969944f},
std::array<float,2>{0.776915193f, 0.167806342f},
std::array<float,2>{0.325725585f, 0.353336602f},
std::array<float,2>{0.532446384f, 0.918960631f},
std::array<float,2>{0.430433095f, 0.829773188f},
std::array<float,2>{0.63105315f, 0.399665922f},
std::array<float,2>{0.200183764f, 0.0818059295f},
std::array<float,2>{0.877744734f, 0.628014147f},
std::array<float,2>{0.0764749199f, 0.767232656f},
std::array<float,2>{0.818381488f, 0.486913323f},
std::array<float,2>{0.298164189f, 0.0555786528f},
std::array<float,2>{0.593041897f, 0.720437944f},
std::array<float,2>{0.443206459f, 0.555588901f},
std::array<float,2>{0.698174596f, 0.22298941f},
std::array<float,2>{0.172179163f, 0.295679986f},
std::array<float,2>{0.988832831f, 0.965656519f},
std::array<float,2>{0.223226324f, 0.682786763f},
std::array<float,2>{0.911905587f, 0.0962341055f},
std::array<float,2>{0.38447696f, 0.416754246f},
std::array<float,2>{0.675470591f, 0.866177022f},
std::array<float,2>{0.366903633f, 0.878908157f},
std::array<float,2>{0.502308011f, 0.319647491f},
std::array<float,2>{0.037124265f, 0.14279215f},
std::array<float,2>{0.811706007f, 0.611832023f},
std::array<float,2>{0.240641579f, 0.809793234f},
std::array<float,2>{0.931264579f, 0.44739601f},
std::array<float,2>{0.403025299f, 0.0245484896f},
std::array<float,2>{0.67133373f, 0.701502264f},
std::array<float,2>{0.359350711f, 0.520310342f},
std::array<float,2>{0.516673088f, 0.196663395f},
std::array<float,2>{0.0589207262f, 0.253174692f},
std::array<float,2>{0.786800504f, 0.971714318f},
std::array<float,2>{0.0783040076f, 0.632469177f},
std::array<float,2>{0.839925587f, 0.082628794f},
std::array<float,2>{0.289600164f, 0.403374672f},
std::array<float,2>{0.577366292f, 0.835545838f},
std::array<float,2>{0.464521021f, 0.916869462f},
std::array<float,2>{0.71655941f, 0.356865793f},
std::array<float,2>{0.164729387f, 0.170690954f},
std::array<float,2>{0.973276854f, 0.569293857f},
std::array<float,2>{0.0231426097f, 0.961957037f},
std::array<float,2>{0.750668049f, 0.289650708f},
std::array<float,2>{0.341789782f, 0.222114399f},
std::array<float,2>{0.54885608f, 0.561679602f},
std::array<float,2>{0.415909946f, 0.725611329f},
std::array<float,2>{0.653281748f, 0.0596159585f},
std::array<float,2>{0.214378148f, 0.491939306f},
std::array<float,2>{0.903800726f, 0.769969761f},
std::array<float,2>{0.125403211f, 0.613407433f},
std::array<float,2>{0.956181645f, 0.147614375f},
std::array<float,2>{0.480602205f, 0.312593609f},
std::array<float,2>{0.720520377f, 0.877896667f},
std::array<float,2>{0.254385144f, 0.86085844f},
std::array<float,2>{0.612155974f, 0.42049104f},
std::array<float,2>{0.105739675f, 0.10049779f},
std::array<float,2>{0.872929633f, 0.684656441f},
std::array<float,2>{0.180992603f, 0.894444585f},
std::array<float,2>{0.999548435f, 0.337450773f},
std::array<float,2>{0.452355325f, 0.131647691f},
std::array<float,2>{0.69050163f, 0.608713865f},
std::array<float,2>{0.305966526f, 0.657061219f},
std::array<float,2>{0.583694994f, 0.123895288f},
std::array<float,2>{0.0677891523f, 0.425293118f},
std::array<float,2>{0.82392174f, 0.848426402f},
std::array<float,2>{0.0420050621f, 0.533284247f},
std::array<float,2>{0.796878755f, 0.246499911f},
std::array<float,2>{0.371524841f, 0.307967186f},
std::array<float,2>{0.513064563f, 0.951839387f},
std::array<float,2>{0.375178993f, 0.759677172f},
std::array<float,2>{0.679905057f, 0.480299294f},
std::array<float,2>{0.226850063f, 0.0383921862f},
std::array<float,2>{0.919485807f, 0.734747231f},
std::array<float,2>{0.12337999f, 0.826167047f},
std::array<float,2>{0.855279028f, 0.385355622f},
std::array<float,2>{0.268217862f, 0.0661529303f},
std::array<float,2>{0.60851419f, 0.642559707f},
std::array<float,2>{0.493726611f, 0.5869506f},
std::array<float,2>{0.739782512f, 0.181991383f},
std::array<float,2>{0.15024446f, 0.363690764f},
std::array<float,2>{0.946626425f, 0.929992378f},
std::array<float,2>{0.193022028f, 0.710760295f},
std::array<float,2>{0.887099445f, 0.00786954816f},
std::array<float,2>{0.428574562f, 0.465407014f},
std::array<float,2>{0.639402509f, 0.794702828f},
std::array<float,2>{0.316263258f, 0.994116783f},
std::array<float,2>{0.542673886f, 0.281194329f},
std::array<float,2>{0.0110826129f, 0.211815178f},
std::array<float,2>{0.771648228f, 0.500988901f},
std::array<float,2>{0.146738946f, 0.855993211f},
std::array<float,2>{0.938350379f, 0.430826634f},
std::array<float,2>{0.490392655f, 0.111540884f},
std::array<float,2>{0.746065617f, 0.664402843f},
std::array<float,2>{0.273748785f, 0.596149325f},
std::array<float,2>{0.599641502f, 0.137927666f},
std::array<float,2>{0.11652986f, 0.330943853f},
std::array<float,2>{0.848187983f, 0.902893722f},
std::array<float,2>{0.00469818944f, 0.745710611f},
std::array<float,2>{0.779632866f, 0.0452859364f},
std::array<float,2>{0.323880404f, 0.474830508f},
std::array<float,2>{0.53608644f, 0.754903615f},
std::array<float,2>{0.436102867f, 0.942238927f},
std::array<float,2>{0.628070951f, 0.299292594f},
std::array<float,2>{0.195598736f, 0.240598157f},
std::array<float,2>{0.880601764f, 0.5434286f},
std::array<float,2>{0.073383972f, 0.929084897f},
std::array<float,2>{0.815163016f, 0.368156999f},
std::array<float,2>{0.302269936f, 0.172832251f},
std::array<float,2>{0.589161873f, 0.582171202f},
std::array<float,2>{0.438999236f, 0.653896749f},
std::array<float,2>{0.702527106f, 0.074224323f},
std::array<float,2>{0.178865746f, 0.375997573f},
std::array<float,2>{0.988064587f, 0.813403428f},
std::array<float,2>{0.221196383f, 0.514673471f},
std::array<float,2>{0.906998515f, 0.206707522f},
std::array<float,2>{0.38994965f, 0.267714769f},
std::array<float,2>{0.678293943f, 0.985200167f},
std::array<float,2>{0.360861599f, 0.782669187f},
std::array<float,2>{0.507257044f, 0.453746825f},
std::array<float,2>{0.0322253667f, 0.00101371226f},
std::array<float,2>{0.807505786f, 0.711348593f},
std::array<float,2>{0.205278322f, 0.977348089f},
std::array<float,2>{0.893518329f, 0.258553028f},
std::array<float,2>{0.409319103f, 0.19141376f},
std::array<float,2>{0.642011523f, 0.523550093f},
std::array<float,2>{0.33233875f, 0.689702153f},
std::array<float,2>{0.558572471f, 0.022830721f},
std::array<float,2>{0.029916957f, 0.441909194f},
std::array<float,2>{0.758084655f, 0.797785878f},
std::array<float,2>{0.0973238274f, 0.571801424f},
std::array<float,2>{0.863761902f, 0.160051525f},
std::array<float,2>{0.261966407f, 0.349047035f},
std::array<float,2>{0.622867048f, 0.9114272f},
std::array<float,2>{0.473111153f, 0.836203754f},
std::array<float,2>{0.732458115f, 0.39827168f},
std::array<float,2>{0.13741836f, 0.0892907083f},
std::array<float,2>{0.963568449f, 0.635692537f},
std::array<float,2>{0.0517729521f, 0.777561784f},
std::array<float,2>{0.789672315f, 0.498106062f},
std::array<float,2>{0.345836848f, 0.0535606071f},
std::array<float,2>{0.530918539f, 0.733825266f},
std::array<float,2>{0.395442516f, 0.549240947f},
std::array<float,2>{0.662347913f, 0.226808801f},
std::array<float,2>{0.248189896f, 0.286452144f},
std::array<float,2>{0.92711693f, 0.953949809f},
std::array<float,2>{0.161552414f, 0.674768031f},
std::array<float,2>{0.981820107f, 0.106131673f},
std::array<float,2>{0.460205793f, 0.410622746f},
std::array<float,2>{0.710124314f, 0.872472942f},
std::array<float,2>{0.286407501f, 0.883129358f},
std::array<float,2>{0.563010991f, 0.32810086f},
std::array<float,2>{0.0883403867f, 0.155494705f},
std::array<float,2>{0.830185533f, 0.620808661f},
std::array<float,2>{0.169805974f, 0.752243161f},
std::array<float,2>{0.97179395f, 0.470131248f},
std::array<float,2>{0.468682855f, 0.0415786132f},
std::array<float,2>{0.711220503f, 0.7461496f},
std::array<float,2>{0.296274036f, 0.540100694f},
std::array<float,2>{0.574041307f, 0.235525429f},
std::array<float,2>{0.0849124268f, 0.30376935f},
std::array<float,2>{0.836100519f, 0.940455675f},
std::array<float,2>{0.0552835055f, 0.668311954f},
std::array<float,2>{0.785104096f, 0.115836985f},
std::array<float,2>{0.353469729f, 0.434566498f},
std::array<float,2>{0.521995604f, 0.854311585f},
std::array<float,2>{0.400383025f, 0.901731372f},
std::array<float,2>{0.665436149f, 0.333700478f},
std::array<float,2>{0.235213205f, 0.136508837f},
std::array<float,2>{0.935841978f, 0.601279378f},
std::array<float,2>{0.103863023f, 0.991179526f},
std::array<float,2>{0.870720983f, 0.272999763f},
std::array<float,2>{0.252442628f, 0.21050787f},
std::array<float,2>{0.616050005f, 0.509270608f},
std::array<float,2>{0.476667315f, 0.715512574f},
std::array<float,2>{0.725494683f, 0.00461556064f},
std::array<float,2>{0.13261503f, 0.457573086f},
std::array<float,2>{0.957393706f, 0.786871612f},
std::array<float,2>{0.215552956f, 0.580597579f},
std::array<float,2>{0.899408102f, 0.177215993f},
std::array<float,2>{0.420563281f, 0.372028351f},
std::array<float,2>{0.6495713f, 0.925445735f},
std::array<float,2>{0.339522183f, 0.817122936f},
std::array<float,2>{0.553320706f, 0.382106215f},
std::array<float,2>{0.0166560542f, 0.0734979287f},
std::array<float,2>{0.756915569f, 0.650951028f},
std::array<float,2>{0.23067078f, 0.907403111f},
std::array<float,2>{0.914525688f, 0.345341831f},
std::array<float,2>{0.380089313f, 0.163121879f},
std::array<float,2>{0.685316265f, 0.577495456f},
std::array<float,2>{0.368598193f, 0.639084637f},
std::array<float,2>{0.508466959f, 0.0902097449f},
std::array<float,2>{0.0448734649f, 0.393018037f},
std::array<float,2>{0.804383814f, 0.841996789f},
std::array<float,2>{0.0636655167f, 0.527633667f},
std::array<float,2>{0.827624023f, 0.188234195f},
std::array<float,2>{0.309030324f, 0.262393117f},
std::array<float,2>{0.578723788f, 0.981924772f},
std::array<float,2>{0.445860833f, 0.80141896f},
std::array<float,2>{0.694345176f, 0.439419419f},
std::array<float,2>{0.184494764f, 0.0165457204f},
std::array<float,2>{0.993095458f, 0.694274068f},
std::array<float,2>{0.0148480479f, 0.870171368f},
std::array<float,2>{0.76665169f, 0.407626867f},
std::array<float,2>{0.318981022f, 0.101745695f},
std::array<float,2>{0.54363817f, 0.679663539f},
std::array<float,2>{0.424366593f, 0.622493684f},
std::array<float,2>{0.635427892f, 0.151125193f},
std::array<float,2>{0.19114314f, 0.321357936f},
std::array<float,2>{0.886210442f, 0.888199866f},
std::array<float,2>{0.15316157f, 0.726923823f},
std::array<float,2>{0.950818181f, 0.0485106818f},
std::array<float,2>{0.498404771f, 0.495204389f},
std::array<float,2>{0.735690296f, 0.776587963f},
std::array<float,2>{0.27054283f, 0.957275629f},
std::array<float,2>{0.604764283f, 0.284639597f},
std::array<float,2>{0.118338324f, 0.232277617f},
std::array<float,2>{0.855526924f, 0.552156329f},
std::array<float,2>{0.200692967f, 0.83011961f},
std::array<float,2>{0.877984405f, 0.40079245f},
std::array<float,2>{0.430882633f, 0.0795666873f},
std::array<float,2>{0.632275283f, 0.625694752f},
std::array<float,2>{0.325017482f, 0.564442217f},
std::array<float,2>{0.531391025f, 0.164374888f},
std::array<float,2>{0.00197543926f, 0.355146229f},
std::array<float,2>{0.775573075f, 0.921011031f},
std::array<float,2>{0.112080924f, 0.69713974f},
std::array<float,2>{0.844211698f, 0.0307768825f},
std::array<float,2>{0.280362785f, 0.449251831f},
std::array<float,2>{0.59575808f, 0.806981742f},
std::array<float,2>{0.485986918f, 0.976181328f},
std::array<float,2>{0.749642372f, 0.25458014f},
std::array<float,2>{0.141719937f, 0.201073334f},
std::array<float,2>{0.943216026f, 0.517610371f},
std::array<float,2>{0.0382073671f, 0.881597221f},
std::array<float,2>{0.811051011f, 0.316688478f},
std::array<float,2>{0.365404338f, 0.141156331f},
std::array<float,2>{0.5033288f, 0.609907627f},
std::array<float,2>{0.383364975f, 0.680611372f},
std::array<float,2>{0.674149871f, 0.0949114189f},
std::array<float,2>{0.223790482f, 0.415293574f},
std::array<float,2>{0.910849631f, 0.863312244f},
std::array<float,2>{0.173373267f, 0.558438659f},
std::array<float,2>{0.98969394f, 0.225907847f},
std::array<float,2>{0.441833824f, 0.294135243f},
std::array<float,2>{0.698475957f, 0.966888607f},
std::array<float,2>{0.297098637f, 0.768569589f},
std::array<float,2>{0.592452347f, 0.484593272f},
std::array<float,2>{0.0778232068f, 0.0572759621f},
std::array<float,2>{0.820269644f, 0.722450435f},
std::array<float,2>{0.132820651f, 0.946110845f},
std::array<float,2>{0.966088891f, 0.311492711f},
std::array<float,2>{0.469428152f, 0.243400618f},
std::array<float,2>{0.727820992f, 0.53863281f},
std::array<float,2>{0.258482218f, 0.740576327f},
std::array<float,2>{0.618749797f, 0.0345345102f},
std::array<float,2>{0.0988549665f, 0.480906725f},
std::array<float,2>{0.860934615f, 0.764040709f},
std::array<float,2>{0.023695644f, 0.602535784f},
std::array<float,2>{0.76248014f, 0.126750857f},
std::array<float,2>{0.32827419f, 0.34072572f},
std::array<float,2>{0.560460746f, 0.894725263f},
std::array<float,2>{0.411059201f, 0.845879316f},
std::array<float,2>{0.646963298f, 0.428375542f},
std::array<float,2>{0.209696949f, 0.117394879f},
std::array<float,2>{0.894637764f, 0.663002849f},
std::array<float,2>{0.0906210467f, 0.789230585f},
std::array<float,2>{0.834040761f, 0.460962623f},
std::array<float,2>{0.282233387f, 0.012625332f},
std::array<float,2>{0.566918015f, 0.704079986f},
std::array<float,2>{0.453184903f, 0.507650614f},
std::array<float,2>{0.703879833f, 0.218270361f},
std::array<float,2>{0.156437844f, 0.27360025f},
std::array<float,2>{0.976863444f, 0.99844116f},
std::array<float,2>{0.244811475f, 0.645059288f},
std::array<float,2>{0.922867596f, 0.0671371445f},
std::array<float,2>{0.394352347f, 0.390465021f},
std::array<float,2>{0.65708673f, 0.823381901f},
std::array<float,2>{0.349582881f, 0.935057104f},
std::array<float,2>{0.526218832f, 0.362778008f},
std::array<float,2>{0.0492217205f, 0.184617549f},
std::array<float,2>{0.793338001f, 0.590605617f},
std::array<float,2>{0.211466864f, 0.772728562f},
std::array<float,2>{0.905258656f, 0.489352614f},
std::array<float,2>{0.41796574f, 0.0615026914f},
std::array<float,2>{0.655935168f, 0.724091589f},
std::array<float,2>{0.341829032f, 0.558945119f},
std::array<float,2>{0.548224747f, 0.219788775f},
std::array<float,2>{0.0211918782f, 0.292386621f},
std::array<float,2>{0.75293833f, 0.964719415f},
std::array<float,2>{0.109219193f, 0.686456501f},
std::array<float,2>{0.874105453f, 0.098945342f},
std::array<float,2>{0.256841928f, 0.418683946f},
std::array<float,2>{0.609545708f, 0.863007903f},
std::array<float,2>{0.484199584f, 0.875185907f},
std::array<float,2>{0.721595287f, 0.316005707f},
std::array<float,2>{0.127404362f, 0.145225897f},
std::array<float,2>{0.954763114f, 0.61600554f},
std::array<float,2>{0.0618358739f, 0.970248818f},
std::array<float,2>{0.788322389f, 0.251689225f},
std::array<float,2>{0.356466353f, 0.19901216f},
std::array<float,2>{0.519016266f, 0.522034228f},
std::array<float,2>{0.405290812f, 0.699938297f},
std::array<float,2>{0.669505596f, 0.027185427f},
std::array<float,2>{0.23918806f, 0.445991665f},
std::array<float,2>{0.93342793f, 0.81143564f},
std::array<float,2>{0.167699769f, 0.566467941f},
std::array<float,2>{0.975548804f, 0.168923557f},
std::array<float,2>{0.462753654f, 0.357492268f},
std::array<float,2>{0.718746722f, 0.91416657f},
std::array<float,2>{0.29137814f, 0.8333143f},
std::array<float,2>{0.575730264f, 0.405629605f},
std::array<float,2>{0.08198452f, 0.0848938599f},
std::array<float,2>{0.843150675f, 0.630272269f},
std::array<float,2>{0.151530892f, 0.932957113f},
std::array<float,2>{0.948388278f, 0.365501314f},
std::array<float,2>{0.495464951f, 0.181577146f},
std::array<float,2>{0.740323186f, 0.589782953f},
std::array<float,2>{0.267290324f, 0.644490302f},
std::array<float,2>{0.605716348f, 0.0627727136f},
std::array<float,2>{0.122736074f, 0.383762956f},
std::array<float,2>{0.851707816f, 0.826232851f},
std::array<float,2>{0.00823877007f, 0.503691316f},
std::array<float,2>{0.771194875f, 0.213030487f},
std::array<float,2>{0.31365788f, 0.27835831f},
std::array<float,2>{0.540261626f, 0.994343877f},
std::array<float,2>{0.427160501f, 0.796471357f},
std::array<float,2>{0.637922108f, 0.468377829f},
std::array<float,2>{0.195197254f, 0.0109302672f},
std::array<float,2>{0.890137553f, 0.707086682f},
std::array<float,2>{0.0701698288f, 0.851014912f},
std::array<float,2>{0.821829617f, 0.423273087f},
std::array<float,2>{0.307997018f, 0.121857241f},
std::array<float,2>{0.585465133f, 0.659884691f},
std::array<float,2>{0.450420946f, 0.60567522f},
std::array<float,2>{0.68938148f, 0.129091173f},
std::array<float,2>{0.182296261f, 0.339833587f},
std::array<float,2>{0.997557878f, 0.892029643f},
std::array<float,2>{0.229640335f, 0.737559259f},
std::array<float,2>{0.920480669f, 0.0354132019f},
std::array<float,2>{0.378059238f, 0.477804333f},
std::array<float,2>{0.683489919f, 0.761459827f},
std::array<float,2>{0.374350429f, 0.949733377f},
std::array<float,2>{0.51544112f, 0.305993199f},
std::array<float,2>{0.040195588f, 0.248998567f},
std::array<float,2>{0.80033958f, 0.531849265f},
std::array<float,2>{0.176569209f, 0.81523782f},
std::array<float,2>{0.985838592f, 0.377913713f},
std::array<float,2>{0.440619439f, 0.0772066265f},
std::array<float,2>{0.699667633f, 0.655226886f},
std::array<float,2>{0.302997708f, 0.584937572f},
std::array<float,2>{0.587458193f, 0.174409449f},
std::array<float,2>{0.0713999122f, 0.369430512f},
std::array<float,2>{0.813504994f, 0.925884724f},
std::array<float,2>{0.0349682942f, 0.714733899f},
std::array<float,2>{0.805859506f, 0.00224312348f},
std::array<float,2>{0.363243312f, 0.456467092f},
std::array<float,2>{0.505550027f, 0.784709513f},
std::array<float,2>{0.387561917f, 0.987935662f},
std::array<float,2>{0.67632091f, 0.267270654f},
std::array<float,2>{0.219124779f, 0.20335497f},
std::array<float,2>{0.909228027f, 0.512616992f},
std::array<float,2>{0.114120826f, 0.90475297f},
std::array<float,2>{0.850161731f, 0.329934597f},
std::array<float,2>{0.276508659f, 0.138677493f},
std::array<float,2>{0.598319232f, 0.595380425f},
std::array<float,2>{0.489974648f, 0.666274607f},
std::array<float,2>{0.742915988f, 0.109680228f},
std::array<float,2>{0.146293536f, 0.431867182f},
std::array<float,2>{0.93963021f, 0.859234691f},
std::array<float,2>{0.199028462f, 0.546117961f},
std::array<float,2>{0.88122201f, 0.238429859f},
std::array<float,2>{0.434889674f, 0.298716068f},
std::array<float,2>{0.626067519f, 0.944477081f},
std::array<float,2>{0.32067135f, 0.757735133f},
std::array<float,2>{0.538875163f, 0.473602891f},
std::array<float,2>{0.00633597886f, 0.0434567332f},
std::array<float,2>{0.778102875f, 0.742522001f},
std::array<float,2>{0.246857867f, 0.956202149f},
std::array<float,2>{0.927817345f, 0.28813079f},
std::array<float,2>{0.398365319f, 0.229002208f},
std::array<float,2>{0.662038743f, 0.547961533f},
std::array<float,2>{0.34531936f, 0.732149422f},
std::array<float,2>{0.527572095f, 0.0513515025f},
std::array<float,2>{0.0527788326f, 0.497758031f},
std::array<float,2>{0.791486323f, 0.780670643f},
std::array<float,2>{0.0863562897f, 0.618998766f},
std::array<float,2>{0.829279661f, 0.152750939f},
std::array<float,2>{0.287680775f, 0.324957341f},
std::array<float,2>{0.564840317f, 0.886600256f},
std::array<float,2>{0.45738095f, 0.873138964f},
std::array<float,2>{0.707698107f, 0.413353473f},
std::array<float,2>{0.163412884f, 0.107760072f},
std::array<float,2>{0.982851803f, 0.673541486f},
std::array<float,2>{0.0285746586f, 0.800063193f},
std::array<float,2>{0.76039201f, 0.443786114f},
std::array<float,2>{0.335463822f, 0.0206380393f},
std::array<float,2>{0.556488395f, 0.687723577f},
std::array<float,2>{0.406594723f, 0.526275039f},
std::array<float,2>{0.644129515f, 0.19422704f},
std::array<float,2>{0.203341067f, 0.259828836f},
std::array<float,2>{0.892026663f, 0.979752481f},
std::array<float,2>{0.139460668f, 0.634164274f},
std::array<float,2>{0.962619543f, 0.0861406103f},
std::array<float,2>{0.476132661f, 0.395813733f},
std::array<float,2>{0.730914831f, 0.839049399f},
std::array<float,2>{0.264798254f, 0.912446141f},
std::array<float,2>{0.623862982f, 0.350512773f},
std::array<float,2>{0.0953070149f, 0.156411529f},
std::array<float,2>{0.866200328f, 0.572267056f},
std::array<float,2>{0.130336046f, 0.787503898f},
std::array<float,2>{0.95943898f, 0.460858256f},
std::array<float,2>{0.479145378f, 0.007487786f},
std::array<float,2>{0.722816706f, 0.716914058f},
std::array<float,2>{0.251077771f, 0.510277033f},
std::array<float,2>{0.613559544f, 0.207580626f},
std::array<float,2>{0.103300817f, 0.270536691f},
std::array<float,2>{0.868800521f, 0.989923537f},
std::array<float,2>{0.0188573562f, 0.648864985f},
std::array<float,2>{0.755384088f, 0.071871832f},
std::array<float,2>{0.337712884f, 0.380218416f},
std::array<float,2>{0.551927209f, 0.820254743f},
std::array<float,2>{0.419016033f, 0.923066378f},
std::array<float,2>{0.651402116f, 0.374606878f},
std::array<float,2>{0.218603671f, 0.178793848f},
std::array<float,2>{0.900688112f, 0.579151213f},
std::array<float,2>{0.0835833773f, 0.938608825f},
std::array<float,2>{0.83905381f, 0.30224967f},
std::array<float,2>{0.294256657f, 0.237942025f},
std::array<float,2>{0.570612788f, 0.541602969f},
std::array<float,2>{0.465610355f, 0.748419344f},
std::array<float,2>{0.713173211f, 0.0394549258f},
std::array<float,2>{0.17047438f, 0.472537726f},
std::array<float,2>{0.968806744f, 0.750677049f},
std::array<float,2>{0.237368956f, 0.597798645f},
std::array<float,2>{0.934085429f, 0.134650588f},
std::array<float,2>{0.401470244f, 0.335825711f},
std::array<float,2>{0.667439222f, 0.899129033f},
std::array<float,2>{0.355177999f, 0.852946639f},
std::array<float,2>{0.520979762f, 0.43585214f},
std::array<float,2>{0.0582925603f, 0.114964284f},
std::array<float,2>{0.781707704f, 0.67003566f},
std::array<float,2>{0.188696936f, 0.890376806f},
std::array<float,2>{0.884213269f, 0.322504222f},
std::array<float,2>{0.422738343f, 0.149960741f},
std::array<float,2>{0.634216726f, 0.623859048f},
std::array<float,2>{0.317608714f, 0.676915228f},
std::array<float,2>{0.546080053f, 0.103700951f},
std::array<float,2>{0.0123244477f, 0.409668088f},
std::array<float,2>{0.767697752f, 0.867342234f},
std::array<float,2>{0.120900869f, 0.553528488f},
std::array<float,2>{0.858572364f, 0.232510164f},
std::array<float,2>{0.271953851f, 0.282316387f},
std::array<float,2>{0.601997972f, 0.960759938f},
std::array<float,2>{0.497470975f, 0.77458179f},
std::array<float,2>{0.736754537f, 0.492318541f},
std::array<float,2>{0.156177893f, 0.0501169637f},
std::array<float,2>{0.952486873f, 0.729779959f},
std::array<float,2>{0.0460309125f, 0.840634584f},
std::array<float,2>{0.802384973f, 0.391270041f},
std::array<float,2>{0.370354712f, 0.0932622403f},
std::array<float,2>{0.510899901f, 0.637658536f},
std::array<float,2>{0.382543474f, 0.575179517f},
std::array<float,2>{0.686444879f, 0.161146164f},
std::array<float,2>{0.233164355f, 0.346677005f},
std::array<float,2>{0.917602599f, 0.908458471f},
std::array<float,2>{0.185734197f, 0.692793608f},
std::array<float,2>{0.995799363f, 0.0178076141f},
std::array<float,2>{0.447990835f, 0.440817147f},
std::array<float,2>{0.692781627f, 0.804085135f},
std::array<float,2>{0.311248004f, 0.983248532f},
std::array<float,2>{0.581117153f, 0.264187574f},
std::array<float,2>{0.0659196153f, 0.189938262f},
std::array<float,2>{0.82567668f, 0.529447436f},
std::array<float,2>{0.224816218f, 0.866901398f},
std::array<float,2>{0.912604809f, 0.417095572f},
std::array<float,2>{0.386030227f, 0.0972590074f},
std::array<float,2>{0.673340023f, 0.682242215f},
std::array<float,2>{0.363325387f, 0.612704337f},
std::array<float,2>{0.500228286f, 0.144032404f},
std::array<float,2>{0.0359098092f, 0.319183558f},
std::array<float,2>{0.809287488f, 0.880652487f},
std::array<float,2>{0.0746157616f, 0.718900859f},
std::array<float,2>{0.81683749f, 0.0558771528f},
std::array<float,2>{0.299020857f, 0.487733632f},
std::array<float,2>{0.591326416f, 0.766181827f},
std::array<float,2>{0.445161819f, 0.9658885f},
std::array<float,2>{0.69556731f, 0.296341598f},
std::array<float,2>{0.175740659f, 0.223884568f},
std::array<float,2>{0.991645277f, 0.556629121f},
std::array<float,2>{0.00123933249f, 0.918489516f},
std::array<float,2>{0.773777783f, 0.352316231f},
std::array<float,2>{0.3269701f, 0.16616872f},
std::array<float,2>{0.534724772f, 0.56482935f},
std::array<float,2>{0.43225646f, 0.627796292f},
std::array<float,2>{0.62926501f, 0.0807569921f},
std::array<float,2>{0.201379135f, 0.398759514f},
std::array<float,2>{0.876635432f, 0.82870388f},
std::array<float,2>{0.143183291f, 0.517057121f},
std::array<float,2>{0.944436908f, 0.203079656f},
std::array<float,2>{0.487696052f, 0.256095588f},
std::array<float,2>{0.746556342f, 0.972745478f},
std::array<float,2>{0.278112918f, 0.805888355f},
std::array<float,2>{0.595137715f, 0.451213092f},
std::array<float,2>{0.110866055f, 0.0273751654f},
std::array<float,2>{0.847077131f, 0.697508752f},
std::array<float,2>{0.159261718f, 0.997467995f},
std::array<float,2>{0.980134487f, 0.277023166f},
std::array<float,2>{0.45591256f, 0.215436354f},
std::array<float,2>{0.705891609f, 0.505144298f},
std::array<float,2>{0.284711033f, 0.705736876f},
std::array<float,2>{0.568779886f, 0.0144285252f},
std::array<float,2>{0.0927935094f, 0.464074403f},
std::array<float,2>{0.832830012f, 0.792045474f},
std::array<float,2>{0.0475424491f, 0.593249083f},
std::array<float,2>{0.795222998f, 0.186104238f},
std::array<float,2>{0.350618631f, 0.359484941f},
std::array<float,2>{0.524369955f, 0.937100053f},
std::array<float,2>{0.39093861f, 0.82032752f},
std::array<float,2>{0.658430755f, 0.388031334f},
std::array<float,2>{0.243331149f, 0.0694004297f},
std::array<float,2>{0.925266325f, 0.64795053f},
std::array<float,2>{0.100839287f, 0.762892723f},
std::array<float,2>{0.862466991f, 0.483488083f},
std::array<float,2>{0.261632234f, 0.0319928043f},
std::array<float,2>{0.619822085f, 0.738822401f},
std::array<float,2>{0.471511245f, 0.536851168f},
std::array<float,2>{0.728639185f, 0.244978517f},
std::array<float,2>{0.135227129f, 0.309699476f},
std::array<float,2>{0.968728244f, 0.947400331f},
std::array<float,2>{0.207773983f, 0.661109865f},
std::array<float,2>{0.897573233f, 0.120811813f},
std::array<float,2>{0.41303134f, 0.427310944f},
std::array<float,2>{0.644923151f, 0.844896197f},
std::array<float,2>{0.33089149f, 0.898173988f},
std::array<float,2>{0.561120033f, 0.34341836f},
std::array<float,2>{0.0258881506f, 0.127818406f},
std::array<float,2>{0.764968216f, 0.603860497f},
std::array<float,2>{0.218424916f, 0.785360754f},
std::array<float,2>{0.900399446f, 0.458355665f},
std::array<float,2>{0.419314981f, 0.00568833062f},
std::array<float,2>{0.651842117f, 0.716752887f},
std::array<float,2>{0.337514848f, 0.508131027f},
std::array<float,2>{0.552112162f, 0.209003583f},
std::array<float,2>{0.0186849777f, 0.272294074f},
std::array<float,2>{0.755812049f, 0.991322756f},
std::array<float,2>{0.103122339f, 0.651600361f},
std::array<float,2>{0.869053364f, 0.072266914f},
std::array<float,2>{0.251337707f, 0.381560147f},
std::array<float,2>{0.613504827f, 0.817827821f},
std::array<float,2>{0.479324371f, 0.924804509f},
std::array<float,2>{0.723086059f, 0.37277469f},
std::array<float,2>{0.130109712f, 0.176682666f},
std::array<float,2>{0.958986402f, 0.581563175f},
std::array<float,2>{0.0583917238f, 0.939978957f},
std::array<float,2>{0.781431854f, 0.303261489f},
std::array<float,2>{0.355455458f, 0.234440491f},
std::array<float,2>{0.520695686f, 0.539695799f},
std::array<float,2>{0.401758552f, 0.747591257f},
std::array<float,2>{0.66704005f, 0.0426057912f},
std::array<float,2>{0.23774147f, 0.46961242f},
std::array<float,2>{0.934530854f, 0.753537655f},
std::array<float,2>{0.170804992f, 0.60050559f},
std::array<float,2>{0.969056368f, 0.135493025f},
std::array<float,2>{0.465443879f, 0.332647324f},
std::array<float,2>{0.713101506f, 0.901103854f},
std::array<float,2>{0.294125021f, 0.854957402f},
std::array<float,2>{0.570439517f, 0.434885323f},
std::array<float,2>{0.0839557797f, 0.1170903f},
std::array<float,2>{0.839148641f, 0.669045389f},
std::array<float,2>{0.155871034f, 0.887690246f},
std::array<float,2>{0.952391207f, 0.320739657f},
std::array<float,2>{0.497166753f, 0.151554897f},
std::array<float,2>{0.736416698f, 0.621473372f},
std::array<float,2>{0.271712959f, 0.678005338f},
std::array<float,2>{0.601796448f, 0.103264369f},
std::array<float,2>{0.12071678f, 0.406732947f},
std::array<float,2>{0.858682334f, 0.869254887f},
std::array<float,2>{0.012541132f, 0.551147759f},
std::array<float,2>{0.767938197f, 0.231301248f},
std::array<float,2>{0.317807078f, 0.283591002f},
std::array<float,2>{0.546171367f, 0.958680451f},
std::array<float,2>{0.422469318f, 0.776263118f},
std::array<float,2>{0.633911133f, 0.494365692f},
std::array<float,2>{0.188895628f, 0.0469235405f},
std::array<float,2>{0.883930862f, 0.727785826f},
std::array<float,2>{0.0662493855f, 0.843240321f},
std::array<float,2>{0.8253842f, 0.39425385f},
std::array<float,2>{0.311457485f, 0.0917331874f},
std::array<float,2>{0.581449687f, 0.639851153f},
std::array<float,2>{0.448053539f, 0.577078104f},
std::array<float,2>{0.692619324f, 0.162770286f},
std::array<float,2>{0.185831562f, 0.343957007f},
std::array<float,2>{0.996040046f, 0.906294048f},
std::array<float,2>{0.233013779f, 0.695191741f},
std::array<float,2>{0.917730927f, 0.017067235f},
std::array<float,2>{0.382661641f, 0.438042194f},
std::array<float,2>{0.686203897f, 0.802269816f},
std::array<float,2>{0.370587587f, 0.980970621f},
std::array<float,2>{0.511085689f, 0.263567328f},
std::array<float,2>{0.0462989546f, 0.18891719f},
std::array<float,2>{0.802695215f, 0.52914685f},
std::array<float,2>{0.1753387f, 0.864549696f},
std::array<float,2>{0.991333544f, 0.414850026f},
std::array<float,2>{0.444873601f, 0.0945707038f},
std::array<float,2>{0.695351779f, 0.680685341f},
std::array<float,2>{0.2991032f, 0.610693514f},
std::array<float,2>{0.591581643f, 0.142393842f},
std::array<float,2>{0.0744163767f, 0.317550629f},
std::array<float,2>{0.816478252f, 0.88245064f},
std::array<float,2>{0.0357850194f, 0.721520901f},
std::array<float,2>{0.809494078f, 0.0577313192f},
std::array<float,2>{0.363550812f, 0.485721052f},
std::array<float,2>{0.500363827f, 0.768531203f},
std::array<float,2>{0.385824233f, 0.968429744f},
std::array<float,2>{0.673588336f, 0.293836802f},
std::array<float,2>{0.224990472f, 0.225479141f},
std::array<float,2>{0.912842274f, 0.556917727f},
std::array<float,2>{0.111190759f, 0.920133948f},
std::array<float,2>{0.846820354f, 0.353751391f},
std::array<float,2>{0.277835518f, 0.165220678f},
std::array<float,2>{0.594917476f, 0.562817335f},
std::array<float,2>{0.487324178f, 0.626747966f},
std::array<float,2>{0.746326804f, 0.0786756352f},
std::array<float,2>{0.143455163f, 0.401748925f},
std::array<float,2>{0.944711983f, 0.831862748f},
std::array<float,2>{0.201433748f, 0.518574834f},
std::array<float,2>{0.876721978f, 0.199390471f},
std::array<float,2>{0.432380468f, 0.255311728f},
std::array<float,2>{0.629146457f, 0.974654019f},
std::array<float,2>{0.32689622f, 0.808035851f},
std::array<float,2>{0.535093904f, 0.450597137f},
std::array<float,2>{0.0011689458f, 0.0302061159f},
std::array<float,2>{0.773661613f, 0.696288407f},
std::array<float,2>{0.243506089f, 0.999672771f},
std::array<float,2>{0.924963415f, 0.275283009f},
std::array<float,2>{0.390815675f, 0.217751354f},
std::array<float,2>{0.658470035f, 0.50631547f},
std::array<float,2>{0.35088262f, 0.704389215f},
std::array<float,2>{0.524084151f, 0.0127369836f},
std::array<float,2>{0.047789555f, 0.462254405f},
std::array<float,2>{0.795051038f, 0.790054739f},
std::array<float,2>{0.0931023955f, 0.591591179f},
std::array<float,2>{0.832744956f, 0.184361562f},
std::array<float,2>{0.284992039f, 0.361612171f},
std::array<float,2>{0.568572044f, 0.934033215f},
std::array<float,2>{0.455570728f, 0.822967887f},
std::array<float,2>{0.705575287f, 0.389233261f},
std::array<float,2>{0.159656256f, 0.0679875538f},
std::array<float,2>{0.980239332f, 0.64599365f},
std::array<float,2>{0.0261865668f, 0.764962733f},
std::array<float,2>{0.764720142f, 0.482234448f},
std::array<float,2>{0.330797464f, 0.0332213156f},
std::array<float,2>{0.561394572f, 0.74187988f},
std::array<float,2>{0.412770241f, 0.537396908f},
std::array<float,2>{0.644721746f, 0.242193222f},
std::array<float,2>{0.207653552f, 0.312404305f},
std::array<float,2>{0.897901237f, 0.946399152f},
std::array<float,2>{0.134924501f, 0.663862765f},
std::array<float,2>{0.968503058f, 0.119012795f},
std::array<float,2>{0.471405804f, 0.428747863f},
std::array<float,2>{0.728815496f, 0.847608387f},
std::array<float,2>{0.261270881f, 0.896432042f},
std::array<float,2>{0.619998336f, 0.340888619f},
std::array<float,2>{0.100798704f, 0.125812545f},
std::array<float,2>{0.862770796f, 0.603427351f},
std::array<float,2>{0.127163917f, 0.770906329f},
std::array<float,2>{0.954996526f, 0.490427673f},
std::array<float,2>{0.483968645f, 0.0589164235f},
std::array<float,2>{0.721328318f, 0.72486335f},
std::array<float,2>{0.257308304f, 0.560632527f},
std::array<float,2>{0.609841228f, 0.220917165f},
std::array<float,2>{0.109127238f, 0.290820718f},
std::array<float,2>{0.874309778f, 0.961029649f},
std::array<float,2>{0.0214543957f, 0.683760822f},
std::array<float,2>{0.753208518f, 0.100589707f},
std::array<float,2>{0.342085838f, 0.421160638f},
std::array<float,2>{0.548039734f, 0.859426796f},
std::array<float,2>{0.417484224f, 0.878079772f},
std::array<float,2>{0.656217456f, 0.31356737f},
std::array<float,2>{0.211757064f, 0.147102669f},
std::array<float,2>{0.904993474f, 0.615046799f},
std::array<float,2>{0.0817446262f, 0.971426129f},
std::array<float,2>{0.842965007f, 0.252813935f},
std::array<float,2>{0.291191876f, 0.19621785f},
std::array<float,2>{0.576062024f, 0.521424413f},
std::array<float,2>{0.462555259f, 0.703070462f},
std::array<float,2>{0.718325436f, 0.0241183266f},
std::array<float,2>{0.167784661f, 0.44860509f},
std::array<float,2>{0.975101769f, 0.809151351f},
std::array<float,2>{0.238888964f, 0.570154548f},
std::array<float,2>{0.933226883f, 0.171523616f},
std::array<float,2>{0.405553609f, 0.356122077f},
std::array<float,2>{0.669889271f, 0.917841434f},
std::array<float,2>{0.356734067f, 0.834526658f},
std::array<float,2>{0.518795311f, 0.402753949f},
std::array<float,2>{0.0617056303f, 0.0830152929f},
std::array<float,2>{0.788386285f, 0.631423771f},
std::array<float,2>{0.195059225f, 0.931332052f},
std::array<float,2>{0.890551984f, 0.364962459f},
std::array<float,2>{0.426792085f, 0.183151662f},
std::array<float,2>{0.638159335f, 0.586313963f},
std::array<float,2>{0.313808262f, 0.640775919f},
std::array<float,2>{0.54030019f, 0.0654048175f},
std::array<float,2>{0.00791673642f, 0.386358798f},
std::array<float,2>{0.771357f, 0.824736953f},
std::array<float,2>{0.123000562f, 0.500353396f},
std::array<float,2>{0.851901114f, 0.212393746f},
std::array<float,2>{0.267361164f, 0.279937297f},
std::array<float,2>{0.605529308f, 0.992955863f},
std::array<float,2>{0.495230079f, 0.793431699f},
std::array<float,2>{0.740711868f, 0.466410041f},
std::array<float,2>{0.151818454f, 0.0093714539f},
std::array<float,2>{0.948718905f, 0.709423602f},
std::array<float,2>{0.0404296815f, 0.848806739f},
std::array<float,2>{0.800597668f, 0.424492985f},
std::array<float,2>{0.37417084f, 0.124259397f},
std::array<float,2>{0.515361845f, 0.657484531f},
std::array<float,2>{0.378179222f, 0.607998729f},
std::array<float,2>{0.683269858f, 0.132305637f},
std::array<float,2>{0.229947209f, 0.336880863f},
std::array<float,2>{0.920730233f, 0.892986298f},
std::array<float,2>{0.18248567f, 0.735585034f},
std::array<float,2>{0.99715662f, 0.0372946002f},
std::array<float,2>{0.450523555f, 0.479469568f},
std::array<float,2>{0.689107656f, 0.758178353f},
std::array<float,2>{0.30781284f, 0.952701926f},
std::array<float,2>{0.585918427f, 0.307598799f},
std::array<float,2>{0.0700029135f, 0.247498631f},
std::array<float,2>{0.822149396f, 0.534395635f},
std::array<float,2>{0.218757987f, 0.81440562f},
std::array<float,2>{0.909662247f, 0.375852615f},
std::array<float,2>{0.38727209f, 0.0757289305f},
std::array<float,2>{0.676533401f, 0.653000057f},
std::array<float,2>{0.36301288f, 0.58351016f},
std::array<float,2>{0.505786896f, 0.1735847f},
std::array<float,2>{0.0348790698f, 0.368338585f},
std::array<float,2>{0.806131303f, 0.928182602f},
std::array<float,2>{0.0715731829f, 0.712112844f},
std::array<float,2>{0.813780129f, 0.000303678709f},
std::array<float,2>{0.302969277f, 0.454122514f},
std::array<float,2>{0.587656856f, 0.781874716f},
std::array<float,2>{0.440862298f, 0.986167431f},
std::array<float,2>{0.699368894f, 0.269176185f},
std::array<float,2>{0.176367432f, 0.205160722f},
std::array<float,2>{0.985478044f, 0.513792872f},
std::array<float,2>{0.00600676239f, 0.904064953f},
std::array<float,2>{0.778038561f, 0.331386864f},
std::array<float,2>{0.320394129f, 0.137316197f},
std::array<float,2>{0.538674593f, 0.596786916f},
std::array<float,2>{0.434664577f, 0.665186107f},
std::array<float,2>{0.626325071f, 0.112319425f},
std::array<float,2>{0.198883325f, 0.430381119f},
std::array<float,2>{0.880990326f, 0.857130408f},
std::array<float,2>{0.14605552f, 0.54408437f},
std::array<float,2>{0.939754426f, 0.242046684f},
std::array<float,2>{0.490092397f, 0.300562054f},
std::array<float,2>{0.742961943f, 0.942871153f},
std::array<float,2>{0.276622683f, 0.75462842f},
std::array<float,2>{0.598442733f, 0.475751102f},
std::array<float,2>{0.113852262f, 0.0462597683f},
std::array<float,2>{0.850454926f, 0.745068252f},
std::array<float,2>{0.163233876f, 0.954688072f},
std::array<float,2>{0.982487977f, 0.285716176f},
std::array<float,2>{0.45704779f, 0.228225082f},
std::array<float,2>{0.707780242f, 0.550369561f},
std::array<float,2>{0.287992001f, 0.732874334f},
std::array<float,2>{0.564480901f, 0.0541036613f},
std::array<float,2>{0.0860743523f, 0.499214143f},
std::array<float,2>{0.829373956f, 0.778755844f},
std::array<float,2>{0.0532110333f, 0.619442284f},
std::array<float,2>{0.791150093f, 0.155264899f},
std::array<float,2>{0.345700204f, 0.326752067f},
std::array<float,2>{0.527745605f, 0.883982301f},
std::array<float,2>{0.397968978f, 0.871408463f},
std::array<float,2>{0.66168201f, 0.41203776f},
std::array<float,2>{0.246591762f, 0.106532075f},
std::array<float,2>{0.927978814f, 0.674982488f},
std::array<float,2>{0.0956040025f, 0.798246562f},
std::array<float,2>{0.865786672f, 0.442862034f},
std::array<float,2>{0.265062749f, 0.0221287161f},
std::array<float,2>{0.623688877f, 0.690815032f},
std::array<float,2>{0.476418793f, 0.525331318f},
std::array<float,2>{0.730581999f, 0.19284223f},
std::array<float,2>{0.139388546f, 0.258822203f},
std::array<float,2>{0.962797463f, 0.977784336f},
std::array<float,2>{0.203480452f, 0.63640213f},
std::array<float,2>{0.891755998f, 0.0880759358f},
std::array<float,2>{0.406289548f, 0.396889836f},
std::array<float,2>{0.644413948f, 0.837596476f},
std::array<float,2>{0.335722744f, 0.911130369f},
std::array<float,2>{0.55627358f, 0.348420143f},
std::array<float,2>{0.0285030007f, 0.158680975f},
std::array<float,2>{0.760524154f, 0.571078658f},
std::array<float,2>{0.234908327f, 0.751120329f},
std::array<float,2>{0.935552657f, 0.471454322f},
std::array<float,2>{0.400108308f, 0.0408109836f},
std::array<float,2>{0.665114105f, 0.749224246f},
std::array<float,2>{0.353271127f, 0.542706013f},
std::array<float,2>{0.522396028f, 0.237282902f},
std::array<float,2>{0.0555886775f, 0.301423103f},
std::array<float,2>{0.784856319f, 0.937972963f},
std::array<float,2>{0.084592618f, 0.670914054f},
std::array<float,2>{0.836322904f, 0.113938682f},
std::array<float,2>{0.296009779f, 0.436962873f},
std::array<float,2>{0.573930085f, 0.851805091f},
std::array<float,2>{0.468431562f, 0.900262475f},
std::array<float,2>{0.711034417f, 0.334435165f},
std::array<float,2>{0.169568315f, 0.132909968f},
std::array<float,2>{0.97208035f, 0.598944962f},
std::array<float,2>{0.0169178266f, 0.98875159f},
std::array<float,2>{0.757302999f, 0.270052582f},
std::array<float,2>{0.33964175f, 0.208235338f},
std::array<float,2>{0.553664207f, 0.511409402f},
std::array<float,2>{0.420762867f, 0.718025625f},
std::array<float,2>{0.649746299f, 0.00591156492f},
std::array<float,2>{0.215666696f, 0.459690481f},
std::array<float,2>{0.898947895f, 0.788757384f},
std::array<float,2>{0.132531762f, 0.578700662f},
std::array<float,2>{0.957158864f, 0.178386495f},
std::array<float,2>{0.477048159f, 0.37371698f},
std::array<float,2>{0.725120306f, 0.922210991f},
std::array<float,2>{0.252829075f, 0.819188476f},
std::array<float,2>{0.61578989f, 0.379530519f},
std::array<float,2>{0.103609674f, 0.07054203f},
std::array<float,2>{0.871021986f, 0.650195897f},
std::array<float,2>{0.184257179f, 0.909497559f},
std::array<float,2>{0.992805243f, 0.347114682f},
std::array<float,2>{0.44606638f, 0.160718784f},
std::array<float,2>{0.694600403f, 0.576070905f},
std::array<float,2>{0.308603436f, 0.638453245f},
std::array<float,2>{0.579061508f, 0.0922232345f},
std::array<float,2>{0.063771382f, 0.392373145f},
std::array<float,2>{0.827340066f, 0.841231525f},
std::array<float,2>{0.0444573723f, 0.53114152f},
std::array<float,2>{0.804672003f, 0.190474555f},
std::array<float,2>{0.368406951f, 0.264696449f},
std::array<float,2>{0.508706927f, 0.984292805f},
std::array<float,2>{0.38025254f, 0.802936912f},
std::array<float,2>{0.685115874f, 0.439713776f},
std::array<float,2>{0.230759695f, 0.0188919231f},
std::array<float,2>{0.914189398f, 0.691901863f},
std::array<float,2>{0.118518166f, 0.868227661f},
std::array<float,2>{0.855889857f, 0.408231527f},
std::array<float,2>{0.270963609f, 0.104573831f},
std::array<float,2>{0.604572773f, 0.67605412f},
std::array<float,2>{0.498253018f, 0.624109745f},
std::array<float,2>{0.735352457f, 0.148769766f},
std::array<float,2>{0.152839124f, 0.324209929f},
std::array<float,2>{0.951067388f, 0.889108479f},
std::array<float,2>{0.191335917f, 0.729121208f},
std::array<float,2>{0.885868967f, 0.0493468754f},
std::array<float,2>{0.424681604f, 0.493622839f},
std::array<float,2>{0.635644615f, 0.774039328f},
std::array<float,2>{0.319146425f, 0.959427476f},
std::array<float,2>{0.543765664f, 0.281932831f},
std::array<float,2>{0.0151000619f, 0.233862862f},
std::array<float,2>{0.766946077f, 0.5541628f},
std::array<float,2>{0.142003477f, 0.829143584f},
std::array<float,2>{0.942927361f, 0.400348544f},
std::array<float,2>{0.486084789f, 0.0811205879f},
std::array<float,2>{0.749762654f, 0.628721118f},
std::array<float,2>{0.280760586f, 0.565483034f},
std::array<float,2>{0.596147835f, 0.167191565f},
std::array<float,2>{0.111886203f, 0.352859885f},
std::array<float,2>{0.843931854f, 0.919840932f},
std::array<float,2>{0.00227869139f, 0.698651135f},
std::array<float,2>{0.775857925f, 0.0287080873f},
std::array<float,2>{0.324801058f, 0.45257777f},
std::array<float,2>{0.531499803f, 0.804861367f},
std::array<float,2>{0.431080371f, 0.973821342f},
std::array<float,2>{0.631961107f, 0.256870031f},
std::array<float,2>{0.201096997f, 0.201586679f},
std::array<float,2>{0.878183305f, 0.515669465f},
std::array<float,2>{0.0781089813f, 0.879740059f},
std::array<float,2>{0.819858491f, 0.319998384f},
std::array<float,2>{0.297267526f, 0.143238887f},
std::array<float,2>{0.59273535f, 0.611395299f},
std::array<float,2>{0.441558659f, 0.683542311f},
std::array<float,2>{0.698699534f, 0.0961169824f},
std::array<float,2>{0.173633277f, 0.416044474f},
std::array<float,2>{0.989348292f, 0.865531266f},
std::array<float,2>{0.224012345f, 0.555109441f},
std::array<float,2>{0.910979331f, 0.223514155f},
std::array<float,2>{0.383570164f, 0.2953448f},
std::array<float,2>{0.673889399f, 0.965309083f},
std::array<float,2>{0.365689129f, 0.766872108f},
std::array<float,2>{0.503128946f, 0.486752868f},
std::array<float,2>{0.0383614898f, 0.0547310002f},
std::array<float,2>{0.811434448f, 0.720089614f},
std::array<float,2>{0.209913f, 0.948410213f},
std::array<float,2>{0.894890428f, 0.309389174f},
std::array<float,2>{0.410872966f, 0.245137081f},
std::array<float,2>{0.646642983f, 0.535399914f},
std::array<float,2>{0.32850948f, 0.740133405f},
std::array<float,2>{0.560077846f, 0.0323752463f},
std::array<float,2>{0.0235259943f, 0.483058959f},
std::array<float,2>{0.762319326f, 0.761727393f},
std::array<float,2>{0.0990549698f, 0.604572833f},
std::array<float,2>{0.86127913f, 0.127960786f},
std::array<float,2>{0.258753598f, 0.341958731f},
std::array<float,2>{0.618955135f, 0.896529019f},
std::array<float,2>{0.469497055f, 0.844672561f},
std::array<float,2>{0.727662802f, 0.42582041f},
std::array<float,2>{0.13311331f, 0.119452856f},
std::array<float,2>{0.96604085f, 0.661896706f},
std::array<float,2>{0.0489085913f, 0.791224003f},
std::array<float,2>{0.793096542f, 0.46357581f},
std::array<float,2>{0.349316031f, 0.0151770329f},
std::array<float,2>{0.525989473f, 0.707003474f},
std::array<float,2>{0.394161433f, 0.504687905f},
std::array<float,2>{0.656954229f, 0.21637693f},
std::array<float,2>{0.245115519f, 0.275658399f},
std::array<float,2>{0.923309982f, 0.996282101f},
std::array<float,2>{0.156569347f, 0.646742582f},
std::array<float,2>{0.976795614f, 0.0691091865f},
std::array<float,2>{0.453599602f, 0.387359053f},
std::array<float,2>{0.703649104f, 0.821942329f},
std::array<float,2>{0.282511771f, 0.936255038f},
std::array<float,2>{0.567183793f, 0.360440642f},
std::array<float,2>{0.0904046372f, 0.187432602f},
std::array<float,2>{0.834376872f, 0.592698097f},
std::array<float,2>{0.164879888f, 0.812338054f},
std::array<float,2>{0.973524749f, 0.447037846f},
std::array<float,2>{0.464836985f, 0.0261358581f},
std::array<float,2>{0.716546953f, 0.700433493f},
std::array<float,2>{0.289916575f, 0.522773802f},
std::array<float,2>{0.577536702f, 0.197723165f},
std::array<float,2>{0.0785796344f, 0.250561029f},
std::array<float,2>{0.840322673f, 0.968998373f},
std::array<float,2>{0.0586336367f, 0.62963438f},
std::array<float,2>{0.78709954f, 0.0855806544f},
std::array<float,2>{0.358944684f, 0.405143708f},
std::array<float,2>{0.51691699f, 0.832205415f},
std::array<float,2>{0.40315491f, 0.915632248f},
std::array<float,2>{0.671117902f, 0.358524293f},
std::array<float,2>{0.240345344f, 0.169445127f},
std::array<float,2>{0.931450903f, 0.568282187f},
std::array<float,2>{0.105495535f, 0.9633798f},
std::array<float,2>{0.872643769f, 0.291662008f},
std::array<float,2>{0.254128069f, 0.218810052f},
std::array<float,2>{0.6120013f, 0.559713364f},
std::array<float,2>{0.480921447f, 0.723564208f},
std::array<float,2>{0.720327199f, 0.0622769967f},
std::array<float,2>{0.12503241f, 0.488961488f},
std::array<float,2>{0.956307232f, 0.7718063f},
std::array<float,2>{0.214645073f, 0.616463006f},
std::array<float,2>{0.903440237f, 0.14617011f},
std::array<float,2>{0.41569224f, 0.314997166f},
std::array<float,2>{0.652966917f, 0.876482069f},
std::array<float,2>{0.341352314f, 0.861369848f},
std::array<float,2>{0.549163043f, 0.419903219f},
std::array<float,2>{0.0233754721f, 0.0986253098f},
std::array<float,2>{0.750820577f, 0.686784148f},
std::array<float,2>{0.226695105f, 0.891404688f},
std::array<float,2>{0.919707716f, 0.338125944f},
std::array<float,2>{0.375301868f, 0.129940778f},
std::array<float,2>{0.679997861f, 0.606967509f},
std::array<float,2>{0.371324122f, 0.65912801f},
std::array<float,2>{0.512857139f, 0.122118689f},
std::array<float,2>{0.0422897525f, 0.422334522f},
std::array<float,2>{0.79715395f, 0.850129843f},
std::array<float,2>{0.067623958f, 0.532896936f},
std::array<float,2>{0.824104071f, 0.249626696f},
std::array<float,2>{0.305778801f, 0.304909796f},
std::array<float,2>{0.583851457f, 0.950200975f},
std::array<float,2>{0.452537984f, 0.760585308f},
std::array<float,2>{0.690818369f, 0.477172434f},
std::array<float,2>{0.180737972f, 0.0365235247f},
std::array<float,2>{0.999772489f, 0.736875892f},
std::array<float,2>{0.0108025894f, 0.827633262f},
std::array<float,2>{0.771946847f, 0.384512752f},
std::array<float,2>{0.316128492f, 0.0635120645f},
std::array<float,2>{0.542756021f, 0.643206358f},
std::array<float,2>{0.428341389f, 0.588223934f},
std::array<float,2>{0.639604688f, 0.180634037f},
std::array<float,2>{0.193203896f, 0.366462737f},
std::array<float,2>{0.886897683f, 0.932316244f},
std::array<float,2>{0.150111601f, 0.708384871f},
std::array<float,2>{0.946467876f, 0.010533276f},
std::array<float,2>{0.493943274f, 0.467771888f},
std::array<float,2>{0.739994586f, 0.795019448f},
std::array<float,2>{0.268477917f, 0.995237887f},
std::array<float,2>{0.608776808f, 0.278268486f},
std::array<float,2>{0.123174369f, 0.214140549f},
std::array<float,2>{0.855200231f, 0.502519667f},
std::array<float,2>{0.195358321f, 0.858115792f},
std::array<float,2>{0.880679667f, 0.433078289f},
std::array<float,2>{0.436496437f, 0.11123509f},
std::array<float,2>{0.628413737f, 0.667812645f},
std::array<float,2>{0.324048907f, 0.594608545f},
std::array<float,2>{0.535690248f, 0.139827624f},
std::array<float,2>{0.00451153703f, 0.328733981f},
std::array<float,2>{0.779364407f, 0.906154513f},
std::array<float,2>{0.116309568f, 0.743589342f},
std::array<float,2>{0.848546565f, 0.0448674858f},
std::array<float,2>{0.273675621f, 0.473717839f},
std::array<float,2>{0.599917054f, 0.756722569f},
std::array<float,2>{0.490591079f, 0.943540692f},
std::array<float,2>{0.745720506f, 0.297095567f},
std::array<float,2>{0.146727324f, 0.239378363f},
std::array<float,2>{0.93818599f, 0.545778692f},
std::array<float,2>{0.0318413228f, 0.926908255f},
std::array<float,2>{0.807176054f, 0.370643735f},
std::array<float,2>{0.361304164f, 0.17535916f},
std::array<float,2>{0.507063389f, 0.585132658f},
std::array<float,2>{0.389740825f, 0.656147063f},
std::array<float,2>{0.67851299f, 0.076243192f},
std::array<float,2>{0.22166343f, 0.378009409f},
std::array<float,2>{0.906745493f, 0.816325307f},
std::array<float,2>{0.17896089f, 0.513294935f},
std::array<float,2>{0.987926543f, 0.204873443f},
std::array<float,2>{0.439346313f, 0.266065896f},
std::array<float,2>{0.702366173f, 0.986878812f},
std::array<float,2>{0.302521825f, 0.783863008f},
std::array<float,2>{0.588916957f, 0.455739111f},
std::array<float,2>{0.0735706761f, 0.00365060708f},
std::array<float,2>{0.815260649f, 0.713534057f},
std::array<float,2>{0.137657553f, 0.979426563f},
std::array<float,2>{0.963630199f, 0.261401534f},
std::array<float,2>{0.472850382f, 0.19494994f},
std::array<float,2>{0.732864678f, 0.527160645f},
std::array<float,2>{0.261861891f, 0.688647687f},
std::array<float,2>{0.622653246f, 0.0202703122f},
std::array<float,2>{0.0976530537f, 0.445276916f},
std::array<float,2>{0.863368213f, 0.799550831f},
std::array<float,2>{0.0302517284f, 0.573728263f},
std::array<float,2>{0.757926762f, 0.157642543f},
std::array<float,2>{0.332077801f, 0.35105744f},
std::array<float,2>{0.558185279f, 0.914043605f},
std::array<float,2>{0.409549356f, 0.838223934f},
std::array<float,2>{0.64170742f, 0.395437479f},
std::array<float,2>{0.205369517f, 0.0873685032f},
std::array<float,2>{0.893103242f, 0.633756578f},
std::array<float,2>{0.0878948197f, 0.780147612f},
std::array<float,2>{0.830458105f, 0.496850997f},
std::array<float,2>{0.286294013f, 0.0519168936f},
std::array<float,2>{0.56342715f, 0.730894983f},
std::array<float,2>{0.459992319f, 0.547565818f},
std::array<float,2>{0.710375726f, 0.230012268f},
std::array<float,2>{0.161221027f, 0.287659615f},
std::array<float,2>{0.981570125f, 0.95554626f},
std::array<float,2>{0.248395368f, 0.672196567f},
std::array<float,2>{0.926933587f, 0.108983159f},
std::array<float,2>{0.395077705f, 0.412956387f},
std::array<float,2>{0.662440479f, 0.874228835f},
std::array<float,2>{0.345978647f, 0.884994447f},
std::array<float,2>{0.531017125f, 0.325234205f},
std::array<float,2>{0.0522076935f, 0.153697357f},
std::array<float,2>{0.789927661f, 0.617971063f},
std::array<float,2>{0.23233667f, 0.801243901f},
std::array<float,2>{0.915117741f, 0.438722342f},
std::array<float,2>{0.379520446f, 0.0158905908f},
std::array<float,2>{0.684403121f, 0.693789423f},
std::array<float,2>{0.367473304f, 0.528247058f},
std::array<float,2>{0.509542048f, 0.187554255f},
std::array<float,2>{0.043456398f, 0.262201667f},
std::array<float,2>{0.803133368f, 0.982185423f},
std::array<float,2>{0.0627082214f, 0.639628232f},
std::array<float,2>{0.82683593f, 0.0903612077f},
std::array<float,2>{0.309899122f, 0.3935121f},
std::array<float,2>{0.579952836f, 0.84234786f},
std::array<float,2>{0.446463048f, 0.907941222f},
std::array<float,2>{0.694003522f, 0.344814122f},
std::array<float,2>{0.18470785f, 0.163732231f},
std::array<float,2>{0.99330467f, 0.577903271f},
std::array<float,2>{0.0143148322f, 0.957950354f},
std::array<float,2>{0.765666068f, 0.284997255f},
std::array<float,2>{0.3197864f, 0.231846631f},
std::array<float,2>{0.544032574f, 0.552376866f},
std::array<float,2>{0.425208509f, 0.727236569f},
std::array<float,2>{0.635838628f, 0.0479429513f},
std::array<float,2>{0.18950294f, 0.495629042f},
std::array<float,2>{0.885741889f, 0.777249992f},
std::array<float,2>{0.153735355f, 0.622869015f},
std::array<float,2>{0.949515522f, 0.150700852f},
std::array<float,2>{0.499352217f, 0.322206259f},
std::array<float,2>{0.735184968f, 0.887860179f},
std::array<float,2>{0.270231336f, 0.870943487f},
std::array<float,2>{0.604400277f, 0.408173352f},
std::array<float,2>{0.117692411f, 0.102166273f},
std::array<float,2>{0.856742203f, 0.678897321f},
std::array<float,2>{0.168601424f, 0.902110159f},
std::array<float,2>{0.971585333f, 0.333443671f},
std::array<float,2>{0.466823459f, 0.136204019f},
std::array<float,2>{0.712549984f, 0.601068258f},
std::array<float,2>{0.295439512f, 0.668680489f},
std::array<float,2>{0.572973669f, 0.115603417f},
std::array<float,2>{0.0857601911f, 0.433724552f},
std::array<float,2>{0.837506711f, 0.853641629f},
std::array<float,2>{0.0561677106f, 0.540712833f},
std::array<float,2>{0.783389747f, 0.23591198f},
std::array<float,2>{0.351746231f, 0.30449453f},
std::array<float,2>{0.523087144f, 0.941325068f},
std::array<float,2>{0.399234265f, 0.752752006f},
std::array<float,2>{0.664748728f, 0.470367163f},
std::array<float,2>{0.236301407f, 0.0411449298f},
std::array<float,2>{0.936975121f, 0.746664703f},
std::array<float,2>{0.105359577f, 0.816654205f},
std::array<float,2>{0.869443655f, 0.382732153f},
std::array<float,2>{0.25333485f, 0.073865734f},
std::array<float,2>{0.616925657f, 0.650852859f},
std::array<float,2>{0.478110164f, 0.580277741f},
std::array<float,2>{0.7262851f, 0.177576378f},
std::array<float,2>{0.131442577f, 0.371098995f},
std::array<float,2>{0.958288193f, 0.924906135f},
std::array<float,2>{0.216351733f, 0.715097368f},
std::array<float,2>{0.900121033f, 0.00433985889f},
std::array<float,2>{0.421166748f, 0.457095742f},
std::array<float,2>{0.648803532f, 0.786430359f},
std::array<float,2>{0.338026375f, 0.990239859f},
std::array<float,2>{0.55386436f, 0.272550911f},
std::array<float,2>{0.0160058215f, 0.210416764f},
std::array<float,2>{0.756624103f, 0.509293437f},
std::array<float,2>{0.134184599f, 0.846292019f},
std::array<float,2>{0.965141356f, 0.428196669f},
std::array<float,2>{0.47022596f, 0.117738426f},
std::array<float,2>{0.727500439f, 0.662192225f},
std::array<float,2>{0.259179533f, 0.601970673f},
std::array<float,2>{0.617353499f, 0.126295477f},
std::array<float,2>{0.0979861394f, 0.339879036f},
std::array<float,2>{0.859693944f, 0.895237744f},
std::array<float,2>{0.0250183959f, 0.740925133f},
std::array<float,2>{0.762911439f, 0.0347744934f},
std::array<float,2>{0.330008954f, 0.481027722f},
std::array<float,2>{0.559107721f, 0.764537334f},
std::array<float,2>{0.411254466f, 0.945493519f},
std::array<float,2>{0.648284674f, 0.310758799f},
std::array<float,2>{0.210324824f, 0.243948847f},
std::array<float,2>{0.896050632f, 0.538235068f},
std::array<float,2>{0.0914668143f, 0.935432017f},
std::array<float,2>{0.834998906f, 0.363085359f},
std::array<float,2>{0.281301647f, 0.185286462f},
std::array<float,2>{0.568059146f, 0.590177536f},
std::array<float,2>{0.454834938f, 0.644689977f},
std::array<float,2>{0.704197645f, 0.0668486729f},
std::array<float,2>{0.157773718f, 0.389975578f},
std::array<float,2>{0.977882206f, 0.823752642f},
std::array<float,2>{0.245801345f, 0.506918371f},
std::array<float,2>{0.921948552f, 0.218092889f},
std::array<float,2>{0.393051803f, 0.274198562f},
std::array<float,2>{0.657245815f, 0.998855293f},
std::array<float,2>{0.348082334f, 0.790001869f},
std::array<float,2>{0.527182996f, 0.46157372f},
std::array<float,2>{0.0501149632f, 0.0119180372f},
std::array<float,2>{0.794535518f, 0.703347623f},
std::array<float,2>{0.199734092f, 0.975948274f},
std::array<float,2>{0.877661943f, 0.254156619f},
std::array<float,2>{0.430308878f, 0.200443715f},
std::array<float,2>{0.631293774f, 0.518545151f},
std::array<float,2>{0.32595861f, 0.696505964f},
std::array<float,2>{0.532531261f, 0.0304213446f},
std::array<float,2>{0.00345627521f, 0.449877769f},
std::array<float,2>{0.777115285f, 0.807145f},
std::array<float,2>{0.113086373f, 0.56377095f},
std::array<float,2>{0.844737887f, 0.164570823f},
std::array<float,2>{0.279708534f, 0.354699492f},
std::array<float,2>{0.597363353f, 0.921717763f},
std::array<float,2>{0.484445184f, 0.830750406f},
std::array<float,2>{0.74805057f, 0.401068211f},
std::array<float,2>{0.141001597f, 0.0798057765f},
std::array<float,2>{0.941648781f, 0.625454426f},
std::array<float,2>{0.0373573713f, 0.769412875f},
std::array<float,2>{0.811803699f, 0.485339522f},
std::array<float,2>{0.367084414f, 0.0569155812f},
std::array<float,2>{0.501960158f, 0.722031891f},
std::array<float,2>{0.384650171f, 0.557860136f},
std::array<float,2>{0.675665557f, 0.226463363f},
std::array<float,2>{0.223571122f, 0.29486993f},
std::array<float,2>{0.911699295f, 0.967707217f},
std::array<float,2>{0.171976209f, 0.679791987f},
std::array<float,2>{0.989198387f, 0.0952407569f},
std::array<float,2>{0.442943484f, 0.415586025f},
std::array<float,2>{0.697995543f, 0.863814592f},
std::array<float,2>{0.297960162f, 0.881110787f},
std::array<float,2>{0.59290725f, 0.317238837f},
std::array<float,2>{0.0763185024f, 0.140744224f},
std::array<float,2>{0.818715036f, 0.609514296f},
std::array<float,2>{0.180467427f, 0.759076059f},
std::array<float,2>{0.998161554f, 0.47968322f},
std::array<float,2>{0.452119559f, 0.0385806598f},
std::array<float,2>{0.690229774f, 0.735007524f},
std::array<float,2>{0.30564028f, 0.533718228f},
std::array<float,2>{0.582608998f, 0.246819183f},
std::array<float,2>{0.0669282079f, 0.30828923f},
std::array<float,2>{0.822343171f, 0.951418936f},
std::array<float,2>{0.0419753976f, 0.656335771f},
std::array<float,2>{0.798094213f, 0.123373814f},
std::array<float,2>{0.372110873f, 0.424900323f},
std::array<float,2>{0.512629509f, 0.847956657f},
std::array<float,2>{0.376135439f, 0.893802166f},
std::array<float,2>{0.68070662f, 0.337030113f},
std::array<float,2>{0.227601588f, 0.131313533f},
std::array<float,2>{0.91800642f, 0.608942568f},
std::array<float,2>{0.124539137f, 0.993371248f},
std::array<float,2>{0.853871644f, 0.280626655f},
std::array<float,2>{0.268605798f, 0.211060837f},
std::array<float,2>{0.608301699f, 0.501471817f},
std::array<float,2>{0.492659152f, 0.71035558f},
std::array<float,2>{0.738996208f, 0.00846207887f},
std::array<float,2>{0.148643091f, 0.465146452f},
std::array<float,2>{0.945423126f, 0.794364333f},
std::array<float,2>{0.191947475f, 0.58770299f},
std::array<float,2>{0.888017893f, 0.18217738f},
std::array<float,2>{0.428974628f, 0.364100516f},
std::array<float,2>{0.640318632f, 0.930448055f},
std::array<float,2>{0.314467818f, 0.825581551f},
std::array<float,2>{0.541127205f, 0.384961367f},
std::array<float,2>{0.0102295922f, 0.0654952526f},
std::array<float,2>{0.772969902f, 0.641920805f},
std::array<float,2>{0.241429001f, 0.916240036f},
std::array<float,2>{0.930104434f, 0.357387424f},
std::array<float,2>{0.404115111f, 0.170296207f},
std::array<float,2>{0.670697033f, 0.568393528f},
std::array<float,2>{0.357512385f, 0.631979644f},
std::array<float,2>{0.516313791f, 0.082178846f},
std::array<float,2>{0.0596861951f, 0.404105812f},
std::array<float,2>{0.785350502f, 0.835051f},
std::array<float,2>{0.0796381235f, 0.519767582f},
std::array<float,2>{0.841788352f, 0.196915433f},
std::array<float,2>{0.290862262f, 0.253662586f},
std::array<float,2>{0.576366782f, 0.972631752f},
std::array<float,2>{0.463344425f, 0.810099125f},
std::array<float,2>{0.715383291f, 0.448042631f},
std::array<float,2>{0.165916875f, 0.0250745229f},
std::array<float,2>{0.974094987f, 0.701884449f},
std::array<float,2>{0.0223884024f, 0.860445917f},
std::array<float,2>{0.75119102f, 0.420175672f},
std::array<float,2>{0.339999229f, 0.0998238847f},
std::array<float,2>{0.550050735f, 0.685417354f},
std::array<float,2>{0.414817154f, 0.613944411f},
std::array<float,2>{0.654140532f, 0.148294896f},
std::array<float,2>{0.21324648f, 0.313058823f},
std::array<float,2>{0.903069854f, 0.877218783f},
std::array<float,2>{0.1262234f, 0.726389349f},
std::array<float,2>{0.956027806f, 0.0605329052f},
std::array<float,2>{0.482282877f, 0.491536915f},
std::array<float,2>{0.719524562f, 0.770224094f},
std::array<float,2>{0.255815268f, 0.962534428f},
std::array<float,2>{0.612471581f, 0.289496124f},
std::array<float,2>{0.107187666f, 0.222388908f},
std::array<float,2>{0.871123254f, 0.56224227f},
std::array<float,2>{0.206836984f, 0.836603165f},
std::array<float,2>{0.894101918f, 0.397853166f},
std::array<float,2>{0.40870446f, 0.0893680081f},
std::array<float,2>{0.64123857f, 0.634975314f},
std::array<float,2>{0.333971858f, 0.571533144f},
std::array<float,2>{0.557413995f, 0.159625754f},
std::array<float,2>{0.0310011115f, 0.349369556f},
std::array<float,2>{0.758892715f, 0.911841512f},
std::array<float,2>{0.0961768404f, 0.690143645f},
std::array<float,2>{0.864458203f, 0.0230678171f},
std::array<float,2>{0.263319969f, 0.441767156f},
std::array<float,2>{0.621943593f, 0.797284007f},
std::array<float,2>{0.474548757f, 0.976763964f},
std::array<float,2>{0.733529985f, 0.257832795f},
std::array<float,2>{0.138580784f, 0.192104727f},
std::array<float,2>{0.964674294f, 0.524062872f},
std::array<float,2>{0.0516683049f, 0.88371855f},
std::array<float,2>{0.790265203f, 0.327378213f},
std::array<float,2>{0.346860677f, 0.155971363f},
std::array<float,2>{0.530141413f, 0.620561779f},
std::array<float,2>{0.395779699f, 0.674003422f},
std::array<float,2>{0.663514197f, 0.105766781f},
std::array<float,2>{0.249846116f, 0.410975635f},
std::array<float,2>{0.926274419f, 0.872598231f},
std::array<float,2>{0.160991535f, 0.549381077f},
std::array<float,2>{0.98091346f, 0.227251157f},
std::array<float,2>{0.459887296f, 0.286639392f},
std::array<float,2>{0.708987176f, 0.953486264f},
std::array<float,2>{0.286094487f, 0.778091848f},
std::array<float,2>{0.564098597f, 0.498711437f},
std::array<float,2>{0.0893905759f, 0.0532074496f},
std::array<float,2>{0.831168473f, 0.734242618f},
std::array<float,2>{0.147744462f, 0.941460729f},
std::array<float,2>{0.939071774f, 0.299584985f},
std::array<float,2>{0.491232842f, 0.240901306f},
std::array<float,2>{0.744258285f, 0.543691576f},
std::array<float,2>{0.274476737f, 0.745246828f},
std::array<float,2>{0.601036549f, 0.0455419309f},
std::array<float,2>{0.115524031f, 0.475506186f},
std::array<float,2>{0.849138677f, 0.755599499f},
std::array<float,2>{0.00531673338f, 0.596653938f},
std::array<float,2>{0.780353785f, 0.138344571f},
std::array<float,2>{0.322630763f, 0.330136567f},
std::array<float,2>{0.536405563f, 0.902561545f},
std::array<float,2>{0.437389046f, 0.855737925f},
std::array<float,2>{0.627164125f, 0.431218535f},
std::array<float,2>{0.197090313f, 0.111891404f},
std::array<float,2>{0.879145861f, 0.664680958f},
std::array<float,2>{0.0725719929f, 0.783131242f},
std::array<float,2>{0.8155424f, 0.453418106f},
std::array<float,2>{0.301414549f, 0.00171893183f},
std::array<float,2>{0.588534057f, 0.711771727f},
std::array<float,2>{0.438383996f, 0.515249133f},
std::array<float,2>{0.701875389f, 0.206387028f},
std::array<float,2>{0.178426236f, 0.268337905f},
std::array<float,2>{0.987213552f, 0.984660268f},
std::array<float,2>{0.222260594f, 0.653570175f},
std::array<float,2>{0.907571673f, 0.0749733374f},
std::array<float,2>{0.388939172f, 0.376575768f},
std::array<float,2>{0.679676175f, 0.812602758f},
std::array<float,2>{0.360035688f, 0.929391026f},
std::array<float,2>{0.506799459f, 0.36749807f},
std::array<float,2>{0.0326586962f, 0.172004774f},
std::array<float,2>{0.807810605f, 0.582750142f},
std::array<float,2>{0.187756017f, 0.775085092f},
std::array<float,2>{0.883660972f, 0.493019462f},
std::array<float,2>{0.423430651f, 0.050351128f},
std::array<float,2>{0.632812798f, 0.730339766f},
std::array<float,2>{0.317110151f, 0.55304563f},
std::array<float,2>{0.545434833f, 0.233392656f},
std::array<float,2>{0.0136191212f, 0.282776326f},
std::array<float,2>{0.769136786f, 0.960243046f},
std::array<float,2>{0.119936801f, 0.677326977f},
std::array<float,2>{0.858160138f, 0.104275741f},
std::array<float,2>{0.273298502f, 0.409192741f},
std::array<float,2>{0.603263617f, 0.867887795f},
std::array<float,2>{0.496416152f, 0.890092909f},
std::array<float,2>{0.737884879f, 0.323071092f},
std::array<float,2>{0.154435337f, 0.149701566f},
std::array<float,2>{0.95134747f, 0.623264849f},
std::array<float,2>{0.0449969508f, 0.982820749f},
std::array<float,2>{0.801252961f, 0.264154762f},
std::array<float,2>{0.369704694f, 0.190391719f},
std::array<float,2>{0.509817123f, 0.529907703f},
std::array<float,2>{0.380943626f, 0.693028092f},
std::array<float,2>{0.687479019f, 0.0184407309f},
std::array<float,2>{0.233867735f, 0.441173345f},
std::array<float,2>{0.916684985f, 0.804258525f},
std::array<float,2>{0.187397599f, 0.574657559f},
std::array<float,2>{0.995101929f, 0.161781326f},
std::array<float,2>{0.44885236f, 0.345903099f},
std::array<float,2>{0.691515148f, 0.909159243f},
std::array<float,2>{0.311681896f, 0.839876056f},
std::array<float,2>{0.580975413f, 0.390798897f},
std::array<float,2>{0.0645264313f, 0.0928096399f},
std::array<float,2>{0.824698985f, 0.637119532f},
std::array<float,2>{0.129063264f, 0.92345649f},
std::array<float,2>{0.960849345f, 0.374097884f},
std::array<float,2>{0.479886115f, 0.179398492f},
std::array<float,2>{0.723813295f, 0.579779565f},
std::array<float,2>{0.250037283f, 0.649346173f},
std::array<float,2>{0.614505231f, 0.0716425553f},
std::array<float,2>{0.102247804f, 0.380668789f},
std::array<float,2>{0.867652535f, 0.819805086f},
std::array<float,2>{0.0185239185f, 0.509833097f},
std::array<float,2>{0.754538834f, 0.207519412f},
std::array<float,2>{0.336018026f, 0.271118104f},
std::array<float,2>{0.550792575f, 0.989611089f},
std::array<float,2>{0.418616146f, 0.787782907f},
std::array<float,2>{0.651088774f, 0.460289478f},
std::array<float,2>{0.217156917f, 0.00721885404f},
std::array<float,2>{0.901588261f, 0.717712164f},
std::array<float,2>{0.0826683193f, 0.853119493f},
std::array<float,2>{0.838364065f, 0.436412007f},
std::array<float,2>{0.29309535f, 0.114703052f},
std::array<float,2>{0.571420789f, 0.670762777f},
std::array<float,2>{0.466568112f, 0.598472118f},
std::array<float,2>{0.714607775f, 0.134101599f},
std::array<float,2>{0.171711877f, 0.335232437f},
std::array<float,2>{0.969849885f, 0.898718357f},
std::array<float,2>{0.236944556f, 0.748837829f},
std::array<float,2>{0.935197949f, 0.0398418941f},
std::array<float,2>{0.401146382f, 0.471991122f},
std::array<float,2>{0.666342974f, 0.750241399f},
std::array<float,2>{0.353824615f, 0.939228475f},
std::array<float,2>{0.520117819f, 0.302023649f},
std::array<float,2>{0.0567914695f, 0.237642691f},
std::array<float,2>{0.783038497f, 0.541258872f},
std::array<float,2>{0.158994943f, 0.82099539f},
std::array<float,2>{0.979100287f, 0.388633162f},
std::array<float,2>{0.456850797f, 0.0700179935f},
std::array<float,2>{0.70656836f, 0.647471428f},
std::array<float,2>{0.284144819f, 0.593512058f},
std::array<float,2>{0.56965071f, 0.185957119f},
std::array<float,2>{0.0922963023f, 0.360321701f},
std::array<float,2>{0.833494604f, 0.936560392f},
std::array<float,2>{0.0487395525f, 0.705243111f},
std::array<float,2>{0.795898974f, 0.0138926972f},
std::array<float,2>{0.350218564f, 0.464602202f},
std::array<float,2>{0.524747133f, 0.792774379f},
std::array<float,2>{0.39177835f, 0.99769634f},
std::array<float,2>{0.659667194f, 0.276614785f},
std::array<float,2>{0.242258102f, 0.215282023f},
std::array<float,2>{0.924574792f, 0.505599856f},
std::array<float,2>{0.100214116f, 0.897584796f},
std::array<float,2>{0.862066686f, 0.342833161f},
std::array<float,2>{0.260049582f, 0.127367899f},
std::array<float,2>{0.620194495f, 0.604367435f},
std::array<float,2>{0.471958935f, 0.660609365f},
std::array<float,2>{0.729823828f, 0.120598644f},
std::array<float,2>{0.136622995f, 0.426809996f},
std::array<float,2>{0.967526376f, 0.84557426f},
std::array<float,2>{0.208519146f, 0.536487758f},
std::array<float,2>{0.897124469f, 0.244215578f},
std::array<float,2>{0.413982153f, 0.310088217f},
std::array<float,2>{0.646144867f, 0.948078573f},
std::array<float,2>{0.331186175f, 0.763644814f},
std::array<float,2>{0.562195778f, 0.483970016f},
std::array<float,2>{0.0269142445f, 0.0316966251f},
std::array<float,2>{0.764056444f, 0.73848784f},
std::array<float,2>{0.226354867f, 0.966584444f},
std::array<float,2>{0.913680315f, 0.296410054f},
std::array<float,2>{0.385331035f, 0.224276751f},
std::array<float,2>{0.672564149f, 0.556008101f},
std::array<float,2>{0.364749581f, 0.71925211f},
std::array<float,2>{0.50172627f, 0.0565312468f},
std::array<float,2>{0.0369561799f, 0.488197744f},
std::array<float,2>{0.809661567f, 0.765997231f},
std::array<float,2>{0.0755228251f, 0.613092721f},
std::array<float,2>{0.81809485f, 0.144180387f},
std::array<float,2>{0.300163388f, 0.318393767f},
std::array<float,2>{0.589959919f, 0.880032301f},
std::array<float,2>{0.443667442f, 0.866606772f},
std::array<float,2>{0.696626425f, 0.417728871f},
std::array<float,2>{0.173952058f, 0.0970933288f},
std::array<float,2>{0.990362585f, 0.681909084f},
std::array<float,2>{0.000119961136f, 0.806406558f},
std::array<float,2>{0.775136411f, 0.451868773f},
std::array<float,2>{0.328067511f, 0.028195139f},
std::array<float,2>{0.533643603f, 0.697888911f},
std::array<float,2>{0.433056921f, 0.517277181f},
std::array<float,2>{0.630671799f, 0.20223175f},
std::array<float,2>{0.202372268f, 0.25647077f},
std::array<float,2>{0.875130177f, 0.973255515f},
std::array<float,2>{0.144394115f, 0.62706089f},
std::array<float,2>{0.943459213f, 0.0800983757f},
std::array<float,2>{0.486830115f, 0.399093926f},
std::array<float,2>{0.747284472f, 0.82832849f},
std::array<float,2>{0.278929949f, 0.918453336f},
std::array<float,2>{0.594547391f, 0.35181123f},
std::array<float,2>{0.109843493f, 0.166838437f},
std::array<float,2>{0.84616673f, 0.56540519f},
std::array<float,2>{0.151008621f, 0.796348333f},
std::array<float,2>{0.947673798f, 0.467784107f},
std::array<float,2>{0.494215995f, 0.0113184685f},
std::array<float,2>{0.741514325f, 0.70790118f},
std::array<float,2>{0.265769958f, 0.50328517f},
std::array<float,2>{0.606965482f, 0.213817254f},
std::array<float,2>{0.121234827f, 0.279260814f},
std::array<float,2>{0.853054643f, 0.994752944f},
std::array<float,2>{0.00971466582f, 0.643995821f},
std::array<float,2>{0.769950509f, 0.0633269772f},
std::array<float,2>{0.313381195f, 0.383012563f},
std::array<float,2>{0.539066911f, 0.826812744f},
std::array<float,2>{0.425787687f, 0.933417737f},
std::array<float,2>{0.637045026f, 0.365991473f},
std::array<float,2>{0.194194362f, 0.180897519f},
std::array<float,2>{0.888955712f, 0.589077652f},
std::array<float,2>{0.0689213201f, 0.949430764f},
std::array<float,2>{0.82125479f, 0.306499422f},
std::array<float,2>{0.307272345f, 0.248053044f},
std::array<float,2>{0.584934235f, 0.531504333f},
std::array<float,2>{0.449740916f, 0.738105953f},
std::array<float,2>{0.688378632f, 0.0360980369f},
std::array<float,2>{0.183515921f, 0.478196949f},
std::array<float,2>{0.996592283f, 0.761073709f},
std::array<float,2>{0.228632659f, 0.606323719f},
std::array<float,2>{0.921117961f, 0.129876122f},
std::array<float,2>{0.37703678f, 0.339112699f},
std::array<float,2>{0.68232137f, 0.892510712f},
std::array<float,2>{0.373773396f, 0.851107895f},
std::array<float,2>{0.514530838f, 0.423558772f},
std::array<float,2>{0.0397770405f, 0.121345401f},
std::array<float,2>{0.798965037f, 0.659440935f},
std::array<float,2>{0.212573469f, 0.875793695f},
std::array<float,2>{0.905712247f, 0.315863222f},
std::array<float,2>{0.416531831f, 0.144672066f},
std::array<float,2>{0.655121028f, 0.615451872f},
std::array<float,2>{0.34322086f, 0.685628772f},
std::array<float,2>{0.547670305f, 0.0993725136f},
std::array<float,2>{0.0196310934f, 0.418128073f},
std::array<float,2>{0.752917588f, 0.862766147f},
std::array<float,2>{0.108268261f, 0.559289455f},
std::array<float,2>{0.873795033f, 0.220269978f},
std::array<float,2>{0.25682658f, 0.292663664f},
std::array<float,2>{0.61104095f, 0.964230418f},
std::array<float,2>{0.483120739f, 0.773287475f},
std::array<float,2>{0.722221673f, 0.489831775f},
std::array<float,2>{0.128000021f, 0.060638763f},
std::array<float,2>{0.953785956f, 0.724146307f},
std::array<float,2>{0.0612729304f, 0.833626091f},
std::array<float,2>{0.787231624f, 0.406198621f},
std::array<float,2>{0.355855107f, 0.0840633288f},
std::array<float,2>{0.517721891f, 0.630659163f},
std::array<float,2>{0.405002832f, 0.567234695f},
std::array<float,2>{0.668823838f, 0.167979747f},
std::array<float,2>{0.239890531f, 0.358015031f},
std::array<float,2>{0.932470024f, 0.914618015f},
std::array<float,2>{0.166015729f, 0.699222147f},
std::array<float,2>{0.975974739f, 0.0266500823f},
std::array<float,2>{0.461319238f, 0.445637405f},
std::array<float,2>{0.717069626f, 0.81074971f},
std::array<float,2>{0.292812496f, 0.969961524f},
std::array<float,2>{0.574557781f, 0.25101307f},
std::array<float,2>{0.0804026276f, 0.198535115f},
std::array<float,2>{0.842132092f, 0.521530092f},
std::array<float,2>{0.247524723f, 0.873877048f},
std::array<float,2>{0.929420471f, 0.413864225f},
std::array<float,2>{0.396981418f, 0.107931986f},
std::array<float,2>{0.661090016f, 0.672893167f},
std::array<float,2>{0.34449634f, 0.618605196f},
std::array<float,2>{0.529078662f, 0.153235808f},
std::array<float,2>{0.0545826629f, 0.324695915f},
std::array<float,2>{0.792563617f, 0.885748923f},
std::array<float,2>{0.0871651471f, 0.731489599f},
std::array<float,2>{0.829030991f, 0.0509520806f},
std::array<float,2>{0.288240254f, 0.497308105f},
std::array<float,2>{0.565713584f, 0.78116256f},
std::array<float,2>{0.458819062f, 0.956662834f},
std::array<float,2>{0.708193183f, 0.288710296f},
std::array<float,2>{0.162120357f, 0.229065463f},
std::array<float,2>{0.983771682f, 0.54851073f},
std::array<float,2>{0.0278251525f, 0.912898302f},
std::array<float,2>{0.761021733f, 0.349633336f},
std::array<float,2>{0.334769368f, 0.157069564f},
std::array<float,2>{0.554774404f, 0.573083818f},
std::array<float,2>{0.408073246f, 0.634348452f},
std::array<float,2>{0.642723501f, 0.0865033716f},
std::array<float,2>{0.204805836f, 0.396301597f},
std::array<float,2>{0.891214192f, 0.839434266f},
std::array<float,2>{0.140007377f, 0.525615156f},
std::array<float,2>{0.961031139f, 0.193501294f},
std::array<float,2>{0.474629998f, 0.260734499f},
std::array<float,2>{0.73157078f, 0.980206788f},
std::array<float,2>{0.264243066f, 0.80078119f},
std::array<float,2>{0.624276519f, 0.444326788f},
std::array<float,2>{0.0942670181f, 0.0211116709f},
std::array<float,2>{0.866323888f, 0.688053906f},
std::array<float,2>{0.177188635f, 0.98762399f},
std::array<float,2>{0.984624505f, 0.266998887f},
std::array<float,2>{0.43973434f, 0.203994662f},
std::array<float,2>{0.700829029f, 0.511908472f},
std::array<float,2>{0.304188102f, 0.714036167f},
std::array<float,2>{0.586633801f, 0.00244760537f},
std::array<float,2>{0.0712448582f, 0.45702675f},
std::array<float,2>{0.812878191f, 0.78444761f},
std::array<float,2>{0.0339648202f, 0.584429502f},
std::array<float,2>{0.804973543f, 0.173902526f},
std::array<float,2>{0.361871719f, 0.370012373f},
std::array<float,2>{0.504545331f, 0.926701486f},
std::array<float,2>{0.388620585f, 0.814841151f},
std::array<float,2>{0.677714109f, 0.377261609f},
std::array<float,2>{0.220231369f, 0.0778067037f},
std::array<float,2>{0.908785701f, 0.654679835f},
std::array<float,2>{0.11433576f, 0.756972075f},
std::array<float,2>{0.85100472f, 0.472658306f},
std::array<float,2>{0.275925994f, 0.0438815653f},
std::array<float,2>{0.598937869f, 0.743133008f},
std::array<float,2>{0.489174396f, 0.546672642f},
std::array<float,2>{0.74367249f, 0.238781288f},
std::array<float,2>{0.144934252f, 0.298198074f},
std::array<float,2>{0.941171288f, 0.945215285f},
std::array<float,2>{0.197373897f, 0.666737139f},
std::array<float,2>{0.882230043f, 0.110171869f},
std::array<float,2>{0.434105814f, 0.432346404f},
std::array<float,2>{0.625558019f, 0.85882324f},
std::array<float,2>{0.322007805f, 0.904994488f},
std::array<float,2>{0.537917137f, 0.329365641f},
std::array<float,2>{0.00703278882f, 0.139429241f},
std::array<float,2>{0.779097557f, 0.595123172f},
std::array<float,2>{0.202679485f, 0.806861341f},
std::array<float,2>{0.875575721f, 0.449466407f},
std::array<float,2>{0.433226854f, 0.0312012881f},
std::array<float,2>{0.630122662f, 0.697021186f},
std::array<float,2>{0.32732299f, 0.517986834f},
std::array<float,2>{0.534029603f, 0.200718239f},
std::array<float,2>{0.00059757242f, 0.254833013f},
std::array<float,2>{0.774675846f, 0.976445794f},
std::array<float,2>{0.110128291f, 0.62583077f},
std::array<float,2>{0.84639889f, 0.0791409239f},
std::array<float,2>{0.278453708f, 0.400495231f},
std::array<float,2>{0.594230056f, 0.830402553f},
std::array<float,2>{0.48676157f, 0.921289504f},
std::array<float,2>{0.747830033f, 0.355301231f},
std::array<float,2>{0.143883213f, 0.164263055f},
std::array<float,2>{0.944173813f, 0.564043939f},
std::array<float,2>{0.0363175981f, 0.967068195f},
std::array<float,2>{0.810343981f, 0.294283599f},
std::array<float,2>{0.364304453f, 0.225658685f},
std::array<float,2>{0.500987232f, 0.558313191f},
std::array<float,2>{0.385048568f, 0.722194731f},
std::array<float,2>{0.671976507f, 0.0575258397f},
std::array<float,2>{0.226052746f, 0.48481828f},
std::array<float,2>{0.913511634f, 0.768950164f},
std::array<float,2>{0.174632713f, 0.610239565f},
std::array<float,2>{0.990804195f, 0.141407058f},
std::array<float,2>{0.444306821f, 0.316408515f},
std::array<float,2>{0.697093308f, 0.881577134f},
std::array<float,2>{0.300608993f, 0.863687396f},
std::array<float,2>{0.590347528f, 0.415127248f},
std::array<float,2>{0.0760277659f, 0.0952063799f},
std::array<float,2>{0.817449212f, 0.680187762f},
std::array<float,2>{0.135970011f, 0.895003796f},
std::array<float,2>{0.967240036f, 0.340363204f},
std::array<float,2>{0.472293556f, 0.126656219f},
std::array<float,2>{0.73028338f, 0.602082372f},
std::array<float,2>{0.2604056f, 0.662709355f},
std::array<float,2>{0.620745122f, 0.117587127f},
std::array<float,2>{0.099981159f, 0.428537339f},
std::array<float,2>{0.861577153f, 0.846052229f},
std::array<float,2>{0.0264928844f, 0.538823545f},
std::array<float,2>{0.764186025f, 0.243474647f},
std::array<float,2>{0.331942528f, 0.311207145f},
std::array<float,2>{0.561805069f, 0.945891798f},
std::array<float,2>{0.41328913f, 0.763688147f},
std::array<float,2>{0.645643294f, 0.48052451f},
std::array<float,2>{0.208277777f, 0.0342755504f},
std::array<float,2>{0.896630883f, 0.740355849f},
std::array<float,2>{0.0921689123f, 0.823713422f},
std::array<float,2>{0.833705783f, 0.39032349f},
std::array<float,2>{0.283361793f, 0.0673080608f},
std::array<float,2>{0.569911778f, 0.645290256f},
std::array<float,2>{0.45640713f, 0.590383708f},
std::array<float,2>{0.706145942f, 0.1849408f},
std::array<float,2>{0.158468083f, 0.362377882f},
std::array<float,2>{0.97887671f, 0.93457371f},
std::array<float,2>{0.24268809f, 0.703742564f},
std::array<float,2>{0.924195707f, 0.0122880181f},
std::array<float,2>{0.39236325f, 0.461187869f},
std::array<float,2>{0.66013509f, 0.789491117f},
std::array<float,2>{0.350052088f, 0.998138905f},
std::array<float,2>{0.525076389f, 0.273769319f},
std::array<float,2>{0.0482068583f, 0.218654737f},
std::array<float,2>{0.796467245f, 0.507498682f},
std::array<float,2>{0.170960754f, 0.854004145f},
std::array<float,2>{0.970469534f, 0.434161454f},
std::array<float,2>{0.465973139f, 0.115969434f},
std::array<float,2>{0.713913083f, 0.667972624f},
std::array<float,2>{0.293654561f, 0.601514816f},
std::array<float,2>{0.57203877f, 0.136407986f},
std::array<float,2>{0.0820500404f, 0.333749294f},
std::array<float,2>{0.838531554f, 0.901541352f},
std::array<float,2>{0.057464689f, 0.746515334f},
std::array<float,2>{0.782395124f, 0.041900035f},
std::array<float,2>{0.354303628f, 0.469731271f},
std::array<float,2>{0.519890249f, 0.752069056f},
std::array<float,2>{0.400638849f, 0.940679491f},
std::array<float,2>{0.666670501f, 0.303990573f},
std::array<float,2>{0.236602917f, 0.235679165f},
std::array<float,2>{0.934594631f, 0.540303826f},
std::array<float,2>{0.101731338f, 0.925614238f},
std::array<float,2>{0.86792922f, 0.371708542f},
std::array<float,2>{0.250547677f, 0.176843017f},
std::array<float,2>{0.614974856f, 0.580993354f},
std::array<float,2>{0.480043203f, 0.651322842f},
std::array<float,2>{0.724281967f, 0.0733602718f},
std::array<float,2>{0.129871652f, 0.381995469f},
std::array<float,2>{0.960114717f, 0.81720072f},
std::array<float,2>{0.217538953f, 0.508848011f},
std::array<float,2>{0.902227938f, 0.210696578f},
std::array<float,2>{0.418240458f, 0.273422599f},
std::array<float,2>{0.650618911f, 0.990935206f},
std::array<float,2>{0.33676064f, 0.786747098f},
std::array<float,2>{0.551556587f, 0.457792908f},
std::array<float,2>{0.0178881139f, 0.0048177084f},
std::array<float,2>{0.754289627f, 0.715735674f},
std::array<float,2>{0.234060392f, 0.981502414f},
std::array<float,2>{0.916052043f, 0.262507021f},
std::array<float,2>{0.381646395f, 0.188194796f},
std::array<float,2>{0.686662197f, 0.527542114f},
std::array<float,2>{0.369415581f, 0.693995416f},
std::array<float,2>{0.510529637f, 0.016356796f},
std::array<float,2>{0.0457143299f, 0.438979328f},
std::array<float,2>{0.801491439f, 0.801740408f},
std::array<float,2>{0.0650583431f, 0.577275515f},
std::array<float,2>{0.824779034f, 0.163488209f},
std::array<float,2>{0.312124699f, 0.345696121f},
std::array<float,2>{0.580345452f, 0.907664061f},
std::array<float,2>{0.448564053f, 0.842284024f},
std::array<float,2>{0.692368925f, 0.39261815f},
std::array<float,2>{0.186878577f, 0.0898581892f},
std::array<float,2>{0.994320929f, 0.638876975f},
std::array<float,2>{0.0128196673f, 0.776757777f},
std::array<float,2>{0.768740237f, 0.495517731f},
std::array<float,2>{0.316873491f, 0.0487690978f},
std::array<float,2>{0.545250237f, 0.726661503f},
std::array<float,2>{0.423032463f, 0.551962554f},
std::array<float,2>{0.633410215f, 0.232170656f},
std::array<float,2>{0.188114703f, 0.284243077f},
std::array<float,2>{0.882984579f, 0.957076609f},
std::array<float,2>{0.155156672f, 0.679272294f},
std::array<float,2>{0.952054501f, 0.102027178f},
std::array<float,2>{0.496799469f, 0.407342017f},
std::array<float,2>{0.73763448f, 0.870379627f},
std::array<float,2>{0.272712439f, 0.888561189f},
std::array<float,2>{0.602837563f, 0.321644187f},
std::array<float,2>{0.119197555f, 0.151040077f},
std::array<float,2>{0.857610703f, 0.622162819f},
std::array<float,2>{0.145066276f, 0.755320311f},
std::array<float,2>{0.940790653f, 0.474879563f},
std::array<float,2>{0.488450557f, 0.0449333787f},
std::array<float,2>{0.743245125f, 0.745856762f},
std::array<float,2>{0.275665015f, 0.543109655f},
std::array<float,2>{0.599547505f, 0.240445957f},
std::array<float,2>{0.115092829f, 0.299009055f},
std::array<float,2>{0.851423204f, 0.942106187f},
std::array<float,2>{0.00774603197f, 0.664142966f},
std::array<float,2>{0.778641403f, 0.111609511f},
std::array<float,2>{0.321504474f, 0.430919766f},
std::array<float,2>{0.537555635f, 0.856293261f},
std::array<float,2>{0.433969855f, 0.903129101f},
std::array<float,2>{0.625137985f, 0.330700904f},
std::array<float,2>{0.197779477f, 0.138105735f},
std::array<float,2>{0.882699847f, 0.595793188f},
std::array<float,2>{0.0706957206f, 0.985031664f},
std::array<float,2>{0.813221812f, 0.26782468f},
std::array<float,2>{0.304222912f, 0.206950322f},
std::array<float,2>{0.586127877f, 0.515117347f},
std::array<float,2>{0.440307409f, 0.711167991f},
std::array<float,2>{0.700451016f, 0.00135771954f},
std::array<float,2>{0.177694991f, 0.454097509f},
std::array<float,2>{0.985258698f, 0.782241821f},
std::array<float,2>{0.219847828f, 0.582316458f},
std::array<float,2>{0.908469319f, 0.172495127f},
std::array<float,2>{0.388154685f, 0.36787796f},
std::array<float,2>{0.677145362f, 0.928923965f},
std::array<float,2>{0.361430317f, 0.813153088f},
std::array<float,2>{0.504368305f, 0.376421481f},
std::array<float,2>{0.0332960486f, 0.0746149123f},
std::array<float,2>{0.805345058f, 0.654124975f},
std::array<float,2>{0.204392344f, 0.911150873f},
std::array<float,2>{0.890633523f, 0.348641962f},
std::array<float,2>{0.407382667f, 0.159679428f},
std::array<float,2>{0.643383622f, 0.57219249f},
std::array<float,2>{0.334420055f, 0.635273397f},
std::array<float,2>{0.555570722f, 0.0890640318f},
std::array<float,2>{0.0280196518f, 0.397951156f},
std::array<float,2>{0.761292398f, 0.836000979f},
std::array<float,2>{0.0941400602f, 0.523861349f},
std::array<float,2>{0.866928339f, 0.191753119f},
std::array<float,2>{0.264118165f, 0.258416712f},
std::array<float,2>{0.624790251f, 0.977210641f},
std::array<float,2>{0.47525847f, 0.797384918f},
std::array<float,2>{0.732306004f, 0.442364007f},
std::array<float,2>{0.140567571f, 0.0226317458f},
std::array<float,2>{0.961627662f, 0.689462364f},
std::array<float,2>{0.0541102104f, 0.872129083f},
std::array<float,2>{0.792051077f, 0.410269797f},
std::array<float,2>{0.344006717f, 0.106424965f},
std::array<float,2>{0.528653979f, 0.674503684f},
std::array<float,2>{0.396677643f, 0.621069372f},
std::array<float,2>{0.660478234f, 0.155708402f},
std::array<float,2>{0.247838363f, 0.327873409f},
std::array<float,2>{0.928921938f, 0.882918894f},
std::array<float,2>{0.162852839f, 0.733488262f},
std::array<float,2>{0.984055817f, 0.0534229316f},
std::array<float,2>{0.458384782f, 0.498519123f},
std::array<float,2>{0.708850563f, 0.777723789f},
std::array<float,2>{0.288873523f, 0.953657389f},
std::array<float,2>{0.566405714f, 0.286327899f},
std::array<float,2>{0.0874621645f, 0.22663337f},
std::array<float,2>{0.828359425f, 0.549036443f},
std::array<float,2>{0.239522517f, 0.835849762f},
std::array<float,2>{0.931795955f, 0.403694063f},
std::array<float,2>{0.404656172f, 0.0829691738f},
std::array<float,2>{0.668250561f, 0.632707477f},
std::array<float,2>{0.356171936f, 0.568878055f},
std::array<float,2>{0.518286407f, 0.170584083f},
std::array<float,2>{0.0609156303f, 0.356642157f},
std::array<float,2>{0.787905455f, 0.916646302f},
std::array<float,2>{0.0807189494f, 0.701388955f},
std::array<float,2>{0.842459381f, 0.0247801095f},
std::array<float,2>{0.292287856f, 0.447559953f},
std::array<float,2>{0.575037777f, 0.809929967f},
std::array<float,2>{0.461484581f, 0.971924126f},
std::array<float,2>{0.71774435f, 0.252963632f},
std::array<float,2>{0.166587025f, 0.196371675f},
std::array<float,2>{0.976262093f, 0.520110548f},
std::array<float,2>{0.020229714f, 0.877540708f},
std::array<float,2>{0.752291441f, 0.312975943f},
std::array<float,2>{0.343454421f, 0.147874445f},
std::array<float,2>{0.547245026f, 0.613651693f},
std::array<float,2>{0.416153669f, 0.685004056f},
std::array<float,2>{0.654724002f, 0.100140132f},
std::array<float,2>{0.211920246f, 0.420832515f},
std::array<float,2>{0.906162024f, 0.861273408f},
std::array<float,2>{0.128878653f, 0.561799765f},
std::array<float,2>{0.95328778f, 0.221778378f},
std::array<float,2>{0.482552856f, 0.29001087f},
std::array<float,2>{0.721908987f, 0.962167442f},
std::array<float,2>{0.255968302f, 0.769597411f},
std::array<float,2>{0.610391378f, 0.492177069f},
std::array<float,2>{0.107475057f, 0.0599753745f},
std::array<float,2>{0.87348032f, 0.725892723f},
std::array<float,2>{0.182735935f, 0.951959133f},
std::array<float,2>{0.996578991f, 0.307730526f},
std::array<float,2>{0.449228227f, 0.24616982f},
std::array<float,2>{0.687557518f, 0.533631384f},
std::array<float,2>{0.306703418f, 0.734487712f},
std::array<float,2>{0.58441335f, 0.0381217152f},
std::array<float,2>{0.0687801465f, 0.480084777f},
std::array<float,2>{0.820459127f, 0.759450793f},
std::array<float,2>{0.0394242816f, 0.608513832f},
std::array<float,2>{0.79974407f, 0.131470785f},
std::array<float,2>{0.373463541f, 0.337890178f},
std::array<float,2>{0.513842225f, 0.894093037f},
std::array<float,2>{0.377806813f, 0.848305285f},
std::array<float,2>{0.681821704f, 0.425770462f},
std::array<float,2>{0.229014069f, 0.123743892f},
std::array<float,2>{0.92152077f, 0.656880081f},
std::array<float,2>{0.121979974f, 0.794592261f},
std::array<float,2>{0.852664173f, 0.465634495f},
std::array<float,2>{0.266262412f, 0.00820448343f},
std::array<float,2>{0.606661081f, 0.710463345f},
std::array<float,2>{0.49471432f, 0.501403391f},
std::array<float,2>{0.742134213f, 0.211652473f},
std::array<float,2>{0.150751621f, 0.28095305f},
std::array<float,2>{0.948106885f, 0.993879378f},
std::array<float,2>{0.193377167f, 0.642221868f},
std::array<float,2>{0.88963753f, 0.0662093833f},
std::array<float,2>{0.426277727f, 0.38555038f},
std::array<float,2>{0.637256086f, 0.825794339f},
std::array<float,2>{0.31285271f, 0.929924488f},
std::array<float,2>{0.539618194f, 0.363496214f},
std::array<float,2>{0.00880754273f, 0.181838214f},
std::array<float,2>{0.770417094f, 0.587266803f},
std::array<float,2>{0.223134428f, 0.766503811f},
std::array<float,2>{0.911547363f, 0.487366706f},
std::array<float,2>{0.384046048f, 0.0559265539f},
std::array<float,2>{0.675191879f, 0.719031274f},
std::array<float,2>{0.366276801f, 0.556231916f},
std::array<float,2>{0.502609432f, 0.223760396f},
std::array<float,2>{0.0377707779f, 0.295954019f},
std::array<float,2>{0.812451184f, 0.966258824f},
std::array<float,2>{0.0770428032f, 0.682538509f},
std::array<float,2>{0.819213212f, 0.0974562764f},
std::array<float,2>{0.298777431f, 0.417443961f},
std::array<float,2>{0.593560278f, 0.867174983f},
std::array<float,2>{0.442609251f, 0.880479276f},
std::array<float,2>{0.697420239f, 0.319039464f},
std::array<float,2>{0.172542378f, 0.143604413f},
std::array<float,2>{0.988324225f, 0.612501025f},
std::array<float,2>{0.00298053771f, 0.972959816f},
std::array<float,2>{0.776791215f, 0.256206632f},
std::array<float,2>{0.325489819f, 0.20281592f},
std::array<float,2>{0.533073127f, 0.516618729f},
std::array<float,2>{0.429921329f, 0.697554886f},
std::array<float,2>{0.63136977f, 0.0277226642f},
std::array<float,2>{0.199444935f, 0.451642126f},
std::array<float,2>{0.876955152f, 0.806008816f},
std::array<float,2>{0.141569883f, 0.564504862f},
std::array<float,2>{0.942170382f, 0.166301817f},
std::array<float,2>{0.485250443f, 0.352184027f},
std::array<float,2>{0.748640716f, 0.918861449f},
std::array<float,2>{0.280235857f, 0.828924298f},
std::array<float,2>{0.596963227f, 0.398584783f},
std::array<float,2>{0.112747967f, 0.0810412094f},
std::array<float,2>{0.845345855f, 0.62764746f},
std::array<float,2>{0.157539159f, 0.937461853f},
std::array<float,2>{0.978064418f, 0.359821618f},
std::array<float,2>{0.454420239f, 0.186413839f},
std::array<float,2>{0.70491004f, 0.592856467f},
std::array<float,2>{0.28199771f, 0.648309529f},
std::array<float,2>{0.567566216f, 0.0695998371f},
std::array<float,2>{0.0909926146f, 0.38770467f},
std::array<float,2>{0.835735917f, 0.820787549f},
std::array<float,2>{0.0507421568f, 0.505112886f},
std::array<float,2>{0.79411155f, 0.215759486f},
std::array<float,2>{0.348520547f, 0.277341932f},
std::array<float,2>{0.526705027f, 0.997133255f},
std::array<float,2>{0.39327386f, 0.79246223f},
std::array<float,2>{0.657789111f, 0.464119524f},
std::array<float,2>{0.245516941f, 0.0142087052f},
std::array<float,2>{0.922397614f, 0.705926597f},
std::array<float,2>{0.0983605161f, 0.845115662f},
std::array<float,2>{0.859941065f, 0.427716881f},
std::array<float,2>{0.25973466f, 0.121031933f},
std::array<float,2>{0.617760003f, 0.660704851f},
std::array<float,2>{0.469832122f, 0.603597105f},
std::array<float,2>{0.726564467f, 0.127469733f},
std::array<float,2>{0.134691983f, 0.343558967f},
std::array<float,2>{0.96536231f, 0.898241162f},
std::array<float,2>{0.21061869f, 0.73908478f},
std::array<float,2>{0.89577347f, 0.0318447687f},
std::array<float,2>{0.411733836f, 0.483834267f},
std::array<float,2>{0.647595763f, 0.762981892f},
std::array<float,2>{0.329158008f, 0.947752237f},
std::array<float,2>{0.558678031f, 0.310040534f},
std::array<float,2>{0.0247832388f, 0.244761795f},
std::array<float,2>{0.763283491f, 0.536985815f},
std::array<float,2>{0.131003186f, 0.820013165f},
std::array<float,2>{0.958791375f, 0.379933029f},
std::array<float,2>{0.477772117f, 0.0721022561f},
std::array<float,2>{0.725761175f, 0.648460567f},
std::array<float,2>{0.253802359f, 0.579393983f},
std::array<float,2>{0.616227686f, 0.179094166f},
std::array<float,2>{0.104621485f, 0.374800414f},
std::array<float,2>{0.869916797f, 0.923104405f},
std::array<float,2>{0.0164372437f, 0.717200279f},
std::array<float,2>{0.756333888f, 0.00775466161f},
std::array<float,2>{0.338665277f, 0.460522771f},
std::array<float,2>{0.55452466f, 0.787351608f},
std::array<float,2>{0.421504557f, 0.990158021f},
std::array<float,2>{0.649276972f, 0.270763218f},
std::array<float,2>{0.21615766f, 0.207985744f},
std::array<float,2>{0.899415553f, 0.510621011f},
std::array<float,2>{0.0849904567f, 0.899250865f},
std::array<float,2>{0.837127388f, 0.335565984f},
std::array<float,2>{0.295085788f, 0.13440153f},
std::array<float,2>{0.572642624f, 0.598115504f},
std::array<float,2>{0.467656046f, 0.670253456f},
std::array<float,2>{0.712075412f, 0.115091324f},
std::array<float,2>{0.168099046f, 0.435613841f},
std::array<float,2>{0.970852673f, 0.852572024f},
std::array<float,2>{0.235408455f, 0.541968644f},
std::array<float,2>{0.937042475f, 0.238246232f},
std::array<float,2>{0.398479193f, 0.302555531f},
std::array<float,2>{0.664539874f, 0.938923895f},
std::array<float,2>{0.352072388f, 0.750891745f},
std::array<float,2>{0.522714436f, 0.472231746f},
std::array<float,2>{0.0559801832f, 0.0392467454f},
std::array<float,2>{0.783771634f, 0.74810195f},
std::array<float,2>{0.190052956f, 0.960671782f},
std::array<float,2>{0.884957671f, 0.282474041f},
std::array<float,2>{0.425564378f, 0.232821822f},
std::array<float,2>{0.636684239f, 0.553361177f},
std::array<float,2>{0.320291936f, 0.729611456f},
std::array<float,2>{0.544472158f, 0.0498114862f},
std::array<float,2>{0.0137195764f, 0.492665797f},
std::array<float,2>{0.766591191f, 0.774771154f},
std::array<float,2>{0.11753089f, 0.62364018f},
std::array<float,2>{0.857410789f, 0.150312707f},
std::array<float,2>{0.26978907f, 0.322707295f},
std::array<float,2>{0.603550017f, 0.890535533f},
std::array<float,2>{0.499896735f, 0.867486119f},
std::array<float,2>{0.734485924f, 0.409912229f},
std::array<float,2>{0.154267624f, 0.104003705f},
std::array<float,2>{0.949763834f, 0.677213669f},
std::array<float,2>{0.0434918739f, 0.803904891f},
std::array<float,2>{0.803522229f, 0.440646142f},
std::array<float,2>{0.367847472f, 0.0180227607f},
std::array<float,2>{0.50908196f, 0.692543149f},
std::array<float,2>{0.379155576f, 0.529652953f},
std::array<float,2>{0.683695018f, 0.189615101f},
std::array<float,2>{0.231887057f, 0.264471322f},
std::array<float,2>{0.915603459f, 0.982957184f},
std::array<float,2>{0.185486779f, 0.637214601f},
std::array<float,2>{0.993927062f, 0.0936525241f},
std::array<float,2>{0.446838826f, 0.391436279f},
std::array<float,2>{0.69378531f, 0.840453625f},
std::array<float,2>{0.3103818f, 0.908322453f},
std::array<float,2>{0.579284966f, 0.346271038f},
std::array<float,2>{0.0633041486f, 0.161476955f},
std::array<float,2>{0.826340854f, 0.574823558f},
std::array<float,2>{0.177817822f, 0.785015166f},
std::array<float,2>{0.986370325f, 0.456098437f},
std::array<float,2>{0.437687635f, 0.00210276828f},
std::array<float,2>{0.70165962f, 0.714357674f},
std::array<float,2>{0.300895542f, 0.512420595f},
std::array<float,2>{0.588096619f, 0.203522205f},
std::array<float,2>{0.0731793493f, 0.267445654f},
std::array<float,2>{0.816396236f, 0.988257229f},
std::array<float,2>{0.0330714062f, 0.654950261f},
std::array<float,2>{0.80856967f, 0.0774469376f},
std::array<float,2>{0.359795779f, 0.377540112f},
std::array<float,2>{0.505913734f, 0.815156519f},
std::array<float,2>{0.389441162f, 0.926029682f},
std::array<float,2>{0.678975403f, 0.369361997f},
std::array<float,2>{0.222166702f, 0.174592242f},
std::array<float,2>{0.907728434f, 0.584706962f},
std::array<float,2>{0.116158798f, 0.944658935f},
std::array<float,2>{0.848670781f, 0.298359334f},
std::array<float,2>{0.274980515f, 0.238647312f},
std::array<float,2>{0.601552069f, 0.546181619f},
std::array<float,2>{0.491933852f, 0.742387295f},
std::array<float,2>{0.744950414f, 0.0431281962f},
std::array<float,2>{0.148017824f, 0.473161161f},
std::array<float,2>{0.938854933f, 0.75732708f},
std::array<float,2>{0.196358413f, 0.595569253f},
std::array<float,2>{0.879805148f, 0.138923809f},
std::array<float,2>{0.436626166f, 0.329751819f},
std::array<float,2>{0.627647817f, 0.904459417f},
std::array<float,2>{0.323184073f, 0.858956158f},
std::array<float,2>{0.536979973f, 0.432014912f},
std::array<float,2>{0.00574332988f, 0.109480485f},
std::array<float,2>{0.781032979f, 0.666259229f},
std::array<float,2>{0.249504074f, 0.886256635f},
std::array<float,2>{0.925979853f, 0.324786782f},
std::array<float,2>{0.396294713f, 0.152483031f},
std::array<float,2>{0.663841248f, 0.618851423f},
std::array<float,2>{0.347551376f, 0.673750997f},
std::array<float,2>{0.529328763f, 0.107572496f},
std::array<float,2>{0.0511487611f, 0.413297087f},
std::array<float,2>{0.790895283f, 0.873439789f},
std::array<float,2>{0.0888842791f, 0.548213303f},
std::array<float,2>{0.831692994f, 0.228674382f},
std::array<float,2>{0.285475671f, 0.288553596f},
std::array<float,2>{0.563930929f, 0.956428409f},
std::array<float,2>{0.459262073f, 0.780321658f},
std::array<float,2>{0.709882677f, 0.497819602f},
std::array<float,2>{0.160277054f, 0.0515633859f},
std::array<float,2>{0.980986416f, 0.73241806f},
std::array<float,2>{0.0305581428f, 0.839355409f},
std::array<float,2>{0.759672225f, 0.395601183f},
std::array<float,2>{0.333011478f, 0.0862899497f},
std::array<float,2>{0.557036757f, 0.634006977f},
std::array<float,2>{0.40840143f, 0.572619796f},
std::array<float,2>{0.640644789f, 0.156668335f},
std::array<float,2>{0.206295311f, 0.350239694f},
std::array<float,2>{0.893915176f, 0.912163198f},
std::array<float,2>{0.137773916f, 0.687777996f},
std::array<float,2>{0.963909924f, 0.0208017938f},
std::array<float,2>{0.473715305f, 0.443400592f},
std::array<float,2>{0.73429358f, 0.799999118f},
std::array<float,2>{0.26288715f, 0.979604959f},
std::array<float,2>{0.621186078f, 0.260237545f},
std::array<float,2>{0.09626811f, 0.194002375f},
std::array<float,2>{0.865163565f, 0.526000798f},
std::array<float,2>{0.213748753f, 0.863197684f},
std::array<float,2>{0.902366459f, 0.418930233f},
std::array<float,2>{0.414209127f, 0.0987773612f},
std::array<float,2>{0.653636336f, 0.686255813f},
std::array<float,2>{0.340685815f, 0.615935922f},
std::array<float,2>{0.550462902f, 0.145400271f},
std::array<float,2>{0.021613773f, 0.316241175f},
std::array<float,2>{0.751857638f, 0.875388265f},
std::array<float,2>{0.106897101f, 0.723749161f},
std::array<float,2>{0.871965408f, 0.0611979999f},
std::array<float,2>{0.255305171f, 0.489567846f},
std::array<float,2>{0.612870336f, 0.772470117f},
std::array<float,2>{0.481629461f, 0.964573085f},
std::array<float,2>{0.719119608f, 0.292063683f},
std::array<float,2>{0.1266976f, 0.220188335f},
std::array<float,2>{0.95549947f, 0.558769166f},
std::array<float,2>{0.0601066798f, 0.914486527f},
std::array<float,2>{0.785989225f, 0.357688278f},
std::array<float,2>{0.358131438f, 0.168628007f},
std::array<float,2>{0.515702128f, 0.566818416f},
std::array<float,2>{0.40363121f, 0.62994653f},
std::array<float,2>{0.670352697f, 0.0846907198f},
std::array<float,2>{0.241784766f, 0.405492455f},
std::array<float,2>{0.930478275f, 0.833061457f},
std::array<float,2>{0.165296197f, 0.522349596f},
std::array<float,2>{0.974467039f, 0.198926002f},
std::array<float,2>{0.463847339f, 0.251862943f},
std::array<float,2>{0.715129733f, 0.970655978f},
std::array<float,2>{0.290237159f, 0.811172068f},
std::array<float,2>{0.576874375f, 0.446089506f},
std::array<float,2>{0.0791279525f, 0.026907919f},
std::array<float,2>{0.840908647f, 0.699965715f},
std::array<float,2>{0.149049774f, 0.994614482f},
std::array<float,2>{0.946236372f, 0.278651804f},
std::array<float,2>{0.492708921f, 0.213375241f},
std::array<float,2>{0.738320231f, 0.503548682f},
std::array<float,2>{0.269198924f, 0.707402229f},
std::array<float,2>{0.60747844f, 0.0111016389f},
std::array<float,2>{0.124437258f, 0.468715817f},
std::array<float,2>{0.854457021f, 0.796643734f},
std::array<float,2>{0.0106673902f, 0.589558423f},
std::array<float,2>{0.772653222f, 0.18128565f},
std::array<float,2>{0.315283209f, 0.365244895f},
std::array<float,2>{0.541746259f, 0.932846725f},
std::array<float,2>{0.429310143f, 0.826559007f},
std::array<float,2>{0.639841378f, 0.383536339f},
std::array<float,2>{0.191876575f, 0.0626637936f},
std::array<float,2>{0.88827908f, 0.644284487f},
std::array<float,2>{0.066816628f, 0.761556506f},
std::array<float,2>{0.823207855f, 0.477588624f},
std::array<float,2>{0.304787636f, 0.0353983007f},
std::array<float,2>{0.582152009f, 0.737504184f},
std::array<float,2>{0.451616526f, 0.532044709f},
std::array<float,2>{0.689678013f, 0.248594359f},
std::array<float,2>{0.179717764f, 0.30578652f},
std::array<float,2>{0.99893105f, 0.950005233f},
std::array<float,2>{0.2280467f, 0.660135925f},
std::array<float,2>{0.918871462f, 0.121588677f},
std::array<float,2>{0.376716763f, 0.422900766f},
std::array<float,2>{0.681602478f, 0.850607634f},
std::array<float,2>{0.372656345f, 0.891694784f},
std::array<float,2>{0.511719167f, 0.339514881f},
std::array<float,2>{0.0411529914f, 0.129382297f},
std::array<float,2>{0.798539102f, 0.605762422f},
std::array<float,2>{0.24415417f, 0.790911853f},
std::array<float,2>{0.923768997f, 0.462571979f},
std::array<float,2>{0.393703192f, 0.0135479895f},
std::array<float,2>{0.656395853f, 0.704690695f},
std::array<float,2>{0.348691434f, 0.506830692f},
std::array<float,2>{0.525560379f, 0.217189521f},
std::array<float,2>{0.049730327f, 0.274588466f},
std::array<float,2>{0.793924332f, 0.99920857f},
std::array<float,2>{0.0900958478f, 0.646298468f},
std::array<float,2>{0.834506094f, 0.0676521659f},
std::array<float,2>{0.283156186f, 0.388777137f},
std::array<float,2>{0.566526413f, 0.822380364f},
std::array<float,2>{0.453623891f, 0.934166968f},
std::array<float,2>{0.703460574f, 0.361824632f},
std::array<float,2>{0.156966195f, 0.183717445f},
std::array<float,2>{0.977455676f, 0.591079414f},
std::array<float,2>{0.0240157899f, 0.946996331f},
std::array<float,2>{0.761881351f, 0.311942965f},
std::array<float,2>{0.329083502f, 0.243094727f},
std::array<float,2>{0.559633732f, 0.537775755f},
std::array<float,2>{0.410577178f, 0.741278112f},
std::array<float,2>{0.647192717f, 0.0341331027f},
std::array<float,2>{0.209455356f, 0.481589556f},
std::array<float,2>{0.895080864f, 0.765519381f},
std::array<float,2>{0.133393317f, 0.602903724f},
std::array<float,2>{0.966545463f, 0.125375673f},
std::array<float,2>{0.46891433f, 0.341671497f},
std::array<float,2>{0.728232503f, 0.895792782f},
std::array<float,2>{0.258210272f, 0.846737564f},
std::array<float,2>{0.618228436f, 0.429499149f},
std::array<float,2>{0.0994983986f, 0.118324317f},
std::array<float,2>{0.860508025f, 0.663159311f},
std::array<float,2>{0.172956556f, 0.882143736f},
std::array<float,2>{0.9897542f, 0.318220973f},
std::array<float,2>{0.442355424f, 0.141956553f},
std::array<float,2>{0.698967099f, 0.611018717f},
std::array<float,2>{0.297682852f, 0.681242764f},
std::array<float,2>{0.592017233f, 0.0938040316f},
std::array<float,2>{0.0773189664f, 0.414396882f},
std::array<float,2>{0.819572806f, 0.865136623f},
std::array<float,2>{0.0388461277f, 0.557267368f},
std::array<float,2>{0.811024785f, 0.224933505f},
std::array<float,2>{0.366194755f, 0.293393284f},
std::array<float,2>{0.503851354f, 0.968198836f},
std::array<float,2>{0.382909715f, 0.76788038f},
std::array<float,2>{0.674614906f, 0.485964119f},
std::array<float,2>{0.224313453f, 0.0583372749f},
std::array<float,2>{0.910631061f, 0.720720708f},
std::array<float,2>{0.111525938f, 0.831539035f},
std::array<float,2>{0.844446182f, 0.402164549f},
std::array<float,2>{0.280980349f, 0.0784317926f},
std::array<float,2>{0.596395314f, 0.626024365f},
std::array<float,2>{0.485649318f, 0.56328851f},
std::array<float,2>{0.749282777f, 0.165743262f},
std::array<float,2>{0.14224124f, 0.35427475f},
std::array<float,2>{0.942675114f, 0.920891702f},
std::array<float,2>{0.200520724f, 0.69534111f},
std::array<float,2>{0.87861383f, 0.0294818487f},
std::array<float,2>{0.431405723f, 0.451017678f},
std::array<float,2>{0.632674158f, 0.808463812f},
std::array<float,2>{0.324291259f, 0.975340784f},
std::array<float,2>{0.532118559f, 0.255490631f},
std::array<float,2>{0.00272490131f, 0.200134918f},
std::array<float,2>{0.776358306f, 0.519314647f},
std::array<float,2>{0.152689844f, 0.869639933f},
std::array<float,2>{0.95064187f, 0.407031f},
std::array<float,2>{0.498640627f, 0.102659307f},
std::array<float,2>{0.736133337f, 0.678500772f},
std::array<float,2>{0.271423817f, 0.621875644f},
std::array<float,2>{0.60538137f, 0.152165085f},
std::array<float,2>{0.11868988f, 0.321008414f},
std::array<float,2>{0.856392384f, 0.887137473f},
std::array<float,2>{0.0151725635f, 0.728122234f},
std::array<float,2>{0.767281115f, 0.0473925658f},
std::array<float,2>{0.31853494f, 0.494816095f},
std::array<float,2>{0.543216109f, 0.775592268f},
std::array<float,2>{0.424252391f, 0.958442926f},
std::array<float,2>{0.635236323f, 0.284131885f},
std::array<float,2>{0.190862656f, 0.230710164f},
std::array<float,2>{0.8865242f, 0.551534534f},
std::array<float,2>{0.0643180832f, 0.907120764f},
std::array<float,2>{0.827783167f, 0.344456494f},
std::array<float,2>{0.309214503f, 0.162259832f},
std::array<float,2>{0.578501761f, 0.576363623f},
std::array<float,2>{0.445364714f, 0.640192151f},
std::array<float,2>{0.695006669f, 0.0911177844f},
std::array<float,2>{0.183863461f, 0.394039869f},
std::array<float,2>{0.992227077f, 0.843371212f},
std::array<float,2>{0.231223732f, 0.528737545f},
std::array<float,2>{0.914931715f, 0.189446017f},
std::array<float,2>{0.380813569f, 0.26276356f},
std::array<float,2>{0.685030878f, 0.980692387f},
std::array<float,2>{0.369056195f, 0.802013993f},
std::array<float,2>{0.50818181f, 0.437959909f},
std::array<float,2>{0.0444101058f, 0.0175074656f},
std::array<float,2>{0.804020703f, 0.69461745f},
std::array<float,2>{0.215218201f, 0.991787612f},
std::array<float,2>{0.898881257f, 0.271714598f},
std::array<float,2>{0.42001605f, 0.209953055f},
std::array<float,2>{0.6502918f, 0.508359969f},
std::array<float,2>{0.339254588f, 0.716095328f},
std::array<float,2>{0.55306077f, 0.00532352319f},
std::array<float,2>{0.0172413029f, 0.458659649f},
std::array<float,2>{0.75778389f, 0.786059141f},
std::array<float,2>{0.104473464f, 0.581099629f},
std::array<float,2>{0.870201886f, 0.175957039f},
std::array<float,2>{0.252229691f, 0.372369796f},
std::array<float,2>{0.615653276f, 0.924016476f},
std::array<float,2>{0.477056175f, 0.818195879f},
std::array<float,2>{0.724725008f, 0.381030709f},
std::array<float,2>{0.132152051f, 0.0730941892f},
std::array<float,2>{0.95752281f, 0.651942432f},
std::array<float,2>{0.0550715216f, 0.753356218f},
std::array<float,2>{0.784355402f, 0.469186038f},
std::array<float,2>{0.352870822f, 0.0420002639f},
std::array<float,2>{0.521721363f, 0.747179925f},
std::array<float,2>{0.399498165f, 0.539354026f},
std::array<float,2>{0.66581136f, 0.235171765f},
std::array<float,2>{0.234739795f, 0.303067386f},
std::array<float,2>{0.93616575f, 0.939801455f},
std::array<float,2>{0.169117227f, 0.669825554f},
std::array<float,2>{0.97219193f, 0.116471641f},
std::array<float,2>{0.467951357f, 0.435081035f},
std::array<float,2>{0.711472988f, 0.855147123f},
std::array<float,2>{0.29672721f, 0.900824189f},
std::array<float,2>{0.573600709f, 0.332315713f},
std::array<float,2>{0.084035553f, 0.135000363f},
std::array<float,2>{0.836489737f, 0.599684775f},
std::array<float,2>{0.161928907f, 0.778990269f},
std::array<float,2>{0.982205033f, 0.499980062f},
std::array<float,2>{0.460684001f, 0.0542725176f},
std::array<float,2>{0.710768342f, 0.733355701f},
std::array<float,2>{0.287064016f, 0.550006807f},
std::array<float,2>{0.562582493f, 0.227891877f},
std::array<float,2>{0.0886208564f, 0.285446793f},
std::array<float,2>{0.830722868f, 0.954555273f},
std::array<float,2>{0.0523296371f, 0.675775766f},
std::array<float,2>{0.789232492f, 0.107334062f},
std::array<float,2>{0.346635371f, 0.41159445f},
std::array<float,2>{0.530412674f, 0.871922433f},
std::array<float,2>{0.394860029f, 0.88448137f},
std::array<float,2>{0.663043082f, 0.326598138f},
std::array<float,2>{0.248666048f, 0.154580995f},
std::array<float,2>{0.927322626f, 0.619810283f},
std::array<float,2>{0.0970687792f, 0.978505433f},
std::array<float,2>{0.864219606f, 0.259297967f},
std::array<float,2>{0.26225546f, 0.193208128f},
std::array<float,2>{0.622070789f, 0.524487793f},
std::array<float,2>{0.473598331f, 0.691336334f},
std::array<float,2>{0.733374834f, 0.0216291081f},
std::array<float,2>{0.13691701f, 0.443093836f},
std::array<float,2>{0.963003039f, 0.798561275f},
std::array<float,2>{0.205614448f, 0.570455313f},
std::array<float,2>{0.892860293f, 0.158862188f},
std::array<float,2>{0.409968048f, 0.347862452f},
std::array<float,2>{0.642394006f, 0.910274327f},
std::array<float,2>{0.332776845f, 0.83691895f},
std::array<float,2>{0.557809234f, 0.397421479f},
std::array<float,2>{0.0296114571f, 0.0883975253f},
std::array<float,2>{0.758356988f, 0.635776937f},
std::array<float,2>{0.221086517f, 0.928235769f},
std::array<float,2>{0.906606615f, 0.368681729f},
std::array<float,2>{0.390363663f, 0.173313856f},
std::array<float,2>{0.678156197f, 0.583384514f},
std::array<float,2>{0.360453486f, 0.652796626f},
std::array<float,2>{0.507573426f, 0.0752740502f},
std::array<float,2>{0.0317248739f, 0.375261903f},
std::array<float,2>{0.806997895f, 0.813834667f},
std::array<float,2>{0.0738085881f, 0.514160931f},
std::array<float,2>{0.814465225f, 0.205723912f},
std::array<float,2>{0.301790535f, 0.268640608f},
std::array<float,2>{0.58953917f, 0.985503793f},
std::array<float,2>{0.438507259f, 0.781686544f},
std::array<float,2>{0.702883303f, 0.45459038f},
std::array<float,2>{0.179259285f, 0.000870031945f},
std::array<float,2>{0.987568796f, 0.712751687f},
std::array<float,2>{0.00410259748f, 0.856801689f},
std::array<float,2>{0.78005141f, 0.429727465f},
std::array<float,2>{0.323372513f, 0.113139458f},
std::array<float,2>{0.535292864f, 0.665761411f},
std::array<float,2>{0.435594261f, 0.59739852f},
std::array<float,2>{0.628604233f, 0.137187004f},
std::array<float,2>{0.196259782f, 0.331878513f},
std::array<float,2>{0.880283594f, 0.90366292f},
std::array<float,2>{0.147415727f, 0.744174659f},
std::array<float,2>{0.937660694f, 0.0464154668f},
std::array<float,2>{0.491115063f, 0.476312578f},
std::array<float,2>{0.745308459f, 0.754279256f},
std::array<float,2>{0.274298459f, 0.942866623f},
std::array<float,2>{0.600551367f, 0.300203502f},
std::array<float,2>{0.117024787f, 0.241502494f},
std::array<float,2>{0.84794575f, 0.544733822f},
std::array<float,2>{0.192596555f, 0.824309528f},
std::array<float,2>{0.887383103f, 0.38610667f},
std::array<float,2>{0.428049445f, 0.0646702871f},
std::array<float,2>{0.638770342f, 0.641588748f},
std::array<float,2>{0.315824747f, 0.586591423f},
std::array<float,2>{0.542393982f, 0.182671353f},
std::array<float,2>{0.0115738288f, 0.36473015f},
std::array<float,2>{0.77232641f, 0.931043029f},
std::array<float,2>{0.123733997f, 0.709917307f},
std::array<float,2>{0.854699492f, 0.00917866267f},
std::array<float,2>{0.267752767f, 0.466109544f},
std::array<float,2>{0.60923183f, 0.793690801f},
std::array<float,2>{0.493410975f, 0.99241519f},
std::array<float,2>{0.739634335f, 0.279773563f},
std::array<float,2>{0.149754509f, 0.212546989f},
std::array<float,2>{0.947097778f, 0.500582814f},
std::array<float,2>{0.042588722f, 0.893414438f},
std::array<float,2>{0.797576249f, 0.336025894f},
std::array<float,2>{0.371837318f, 0.132429868f},
std::array<float,2>{0.513623714f, 0.60745734f},
std::array<float,2>{0.375571936f, 0.657763481f},
std::array<float,2>{0.68034029f, 0.124617182f},
std::array<float,2>{0.227147698f, 0.424170285f},
std::array<float,2>{0.919135451f, 0.849291265f},
std::array<float,2>{0.181577131f, 0.534828126f},
std::array<float,2>{0.999066472f, 0.247564927f},
std::array<float,2>{0.453081965f, 0.306686103f},
std::array<float,2>{0.691039503f, 0.952306747f},
std::array<float,2>{0.306388259f, 0.75837779f},
std::array<float,2>{0.583108604f, 0.478552133f},
std::array<float,2>{0.0681753457f, 0.0376886353f},
std::array<float,2>{0.823397279f, 0.73621726f},
std::array<float,2>{0.125708729f, 0.961606026f},
std::array<float,2>{0.956606567f, 0.290098608f},
std::array<float,2>{0.481358916f, 0.221386045f},
std::array<float,2>{0.719746292f, 0.561479211f},
std::array<float,2>{0.254798949f, 0.725437999f},
std::array<float,2>{0.611382484f, 0.0590866059f},
std::array<float,2>{0.106342025f, 0.490966678f},
std::array<float,2>{0.872253358f, 0.771214604f},
std::array<float,2>{0.0227199346f, 0.614742219f},
std::array<float,2>{0.750314474f, 0.14677529f},
std::array<float,2>{0.340987116f, 0.31436497f},
std::array<float,2>{0.549696505f, 0.878609002f},
std::array<float,2>{0.415121317f, 0.860282898f},
std::array<float,2>{0.652554095f, 0.42148453f},
std::array<float,2>{0.214167207f, 0.10112647f},
std::array<float,2>{0.903942585f, 0.684412301f},
std::array<float,2>{0.0787425861f, 0.808730185f},
std::array<float,2>{0.840689957f, 0.449065953f},
std::array<float,2>{0.289217204f, 0.0237035472f},
std::array<float,2>{0.577736616f, 0.70247823f},
std::array<float,2>{0.46393609f, 0.520588577f},
std::array<float,2>{0.716114759f, 0.195759252f},
std::array<float,2>{0.164131194f, 0.252294093f},
std::array<float,2>{0.972805977f, 0.970896125f},
std::array<float,2>{0.240895241f, 0.631105185f},
std::array<float,2>{0.931143761f, 0.0836687461f},
std::array<float,2>{0.402662724f, 0.403297871f},
std::array<float,2>{0.671705365f, 0.834314823f},
std::array<float,2>{0.35869205f, 0.917050838f},
std::array<float,2>{0.517201364f, 0.355955154f},
std::array<float,2>{0.059402246f, 0.171192139f},
std::array<float,2>{0.786597133f, 0.569400668f},
std::array<float,2>{0.207317784f, 0.762495697f},
std::array<float,2>{0.898030281f, 0.482604593f},
std::array<float,2>{0.412439317f, 0.0328300484f},
std::array<float,2>{0.645395637f, 0.739720404f},
std::array<float,2>{0.330419213f, 0.536047637f},
std::array<float,2>{0.560827613f, 0.246092349f},
std::array<float,2>{0.0255072471f, 0.308729857f},
std::array<float,2>{0.765294135f, 0.949188232f},
std::array<float,2>{0.101234987f, 0.661343277f},
std::array<float,2>{0.862964809f, 0.119696692f},
std::array<float,2>{0.260989636f, 0.426698238f},
std::array<float,2>{0.619226754f, 0.844056129f},
std::array<float,2>{0.471185416f, 0.897005558f},
std::array<float,2>{0.729085565f, 0.342323393f},
std::array<float,2>{0.135697454f, 0.1288919f},
std::array<float,2>{0.968003392f, 0.605374873f},
std::array<float,2>{0.047064282f, 0.996887743f},
std::array<float,2>{0.795451701f, 0.276276171f},
std::array<float,2>{0.351146132f, 0.216139406f},
std::array<float,2>{0.523510158f, 0.504334331f},
std::array<float,2>{0.391597211f, 0.706070364f},
std::array<float,2>{0.659072042f, 0.0149621982f},
std::array<float,2>{0.243769184f, 0.463207781f},
std::array<float,2>{0.92560184f, 0.791528821f},
std::array<float,2>{0.15974094f, 0.592104018f},
std::array<float,2>{0.979769528f, 0.186671153f},
std::array<float,2>{0.455362767f, 0.361004114f},
std::array<float,2>{0.705107272f, 0.935598314f},
std::array<float,2>{0.284463167f, 0.821720779f},
std::array<float,2>{0.569094241f, 0.387049586f},
std::array<float,2>{0.0933176428f, 0.068628639f},
std::array<float,2>{0.832158566f, 0.647350669f},
std::array<float,2>{0.142600283f, 0.91939038f},
std::array<float,2>{0.944850087f, 0.353202194f},
std::array<float,2>{0.487806648f, 0.167491466f},
std::array<float,2>{0.746729195f, 0.566375911f},
std::array<float,2>{0.277757585f, 0.62822628f},
std::array<float,2>{0.595320106f, 0.0817464888f},
std::array<float,2>{0.110510424f, 0.399491787f},
std::array<float,2>{0.847481847f, 0.829942584f},
std::array<float,2>{0.00188485638f, 0.516565442f},
std::array<float,2>{0.774326682f, 0.202039167f},
std::array<float,2>{0.326652437f, 0.257709891f},
std::array<float,2>{0.53436631f, 0.97446698f},
std::array<float,2>{0.432115823f, 0.805314064f},
std::array<float,2>{0.629849851f, 0.452685714f},
std::array<float,2>{0.201717958f, 0.0289293081f},
std::array<float,2>{0.87615633f, 0.69912827f},
std::array<float,2>{0.0751917511f, 0.865756154f},
std::array<float,2>{0.817080259f, 0.41668576f},
std::array<float,2>{0.299654126f, 0.0964874104f},
std::array<float,2>{0.590904415f, 0.682970941f},
std::array<float,2>{0.444426417f, 0.612265944f},
std::array<float,2>{0.695848167f, 0.14284043f},
std::array<float,2>{0.175064594f, 0.319363803f},
std::array<float,2>{0.991755068f, 0.879323483f},
std::array<float,2>{0.225422606f, 0.720657229f},
std::array<float,2>{0.912255347f, 0.0552868173f},
std::array<float,2>{0.386373132f, 0.487218738f},
std::array<float,2>{0.67296797f, 0.767537653f},
std::array<float,2>{0.364026099f, 0.965531051f},
std::array<float,2>{0.500552952f, 0.295425713f},
std::array<float,2>{0.0353793167f, 0.222895622f},
std::array<float,2>{0.808798015f, 0.555331171f},
std::array<float,2>{0.186480716f, 0.841401398f},
std::array<float,2>{0.995583594f, 0.391845167f},
std::array<float,2>{0.44736892f, 0.0925283358f},
std::array<float,2>{0.693188488f, 0.637716293f},
std::array<float,2>{0.31067276f, 0.575680435f},
std::array<float,2>{0.58158046f, 0.160550922f},
std::array<float,2>{0.0654760301f, 0.347172111f},
std::array<float,2>{0.826150239f, 0.909716189f},
std::array<float,2>{0.0464162268f, 0.691498935f},
std::array<float,2>{0.802089334f, 0.0193413701f},
std::array<float,2>{0.370839983f, 0.439953685f},
std::array<float,2>{0.511509955f, 0.803648472f},
std::array<float,2>{0.381975144f, 0.983430862f},
std::array<float,2>{0.685697973f, 0.265175611f},
std::array<float,2>{0.232850328f, 0.191316679f},
std::array<float,2>{0.91705066f, 0.530733705f},
std::array<float,2>{0.120604597f, 0.889228284f},
std::array<float,2>{0.858935237f, 0.32367751f},
std::array<float,2>{0.272160977f, 0.149370536f},
std::array<float,2>{0.602068424f, 0.624512494f},
std::array<float,2>{0.497647643f, 0.676745892f},
std::array<float,2>{0.737011075f, 0.10521163f},
std::array<float,2>{0.155738205f, 0.408935994f},
std::array<float,2>{0.953026056f, 0.868835628f},
std::array<float,2>{0.189109832f, 0.554602444f},
std::array<float,2>{0.884616137f, 0.233917609f},
std::array<float,2>{0.422202349f, 0.281615496f},
std::array<float,2>{0.634451628f, 0.959678292f},
std::array<float,2>{0.318067551f, 0.773532033f},
std::array<float,2>{0.546650052f, 0.493704796f},
std::array<float,2>{0.0118081411f, 0.0490095653f},
std::array<float,2>{0.768283069f, 0.728571653f},
std::array<float,2>{0.237988397f, 0.93835777f},
std::array<float,2>{0.933863044f, 0.301076531f},
std::array<float,2>{0.402132481f, 0.236442506f},
std::array<float,2>{0.667867005f, 0.542002916f},
std::array<float,2>{0.35477066f, 0.749871314f},
std::array<float,2>{0.521177232f, 0.0402949676f},
std::array<float,2>{0.0578751266f, 0.470757663f},
std::array<float,2>{0.781950712f, 0.751832187f},
std::array<float,2>{0.0831560194f, 0.599317074f},
std::array<float,2>{0.839422226f, 0.13371706f},
std::array<float,2>{0.294481814f, 0.334729224f},
std::array<float,2>{0.571233809f, 0.899571478f},
std::array<float,2>{0.464934707f, 0.852433264f},
std::array<float,2>{0.713484049f, 0.437458277f},
std::array<float,2>{0.170306519f, 0.113515273f},
std::array<float,2>{0.969376683f, 0.67163527f},
std::array<float,2>{0.0194815099f, 0.788535655f},
std::array<float,2>{0.755129457f, 0.459472537f},
std::array<float,2>{0.337265193f, 0.00664861081f},
std::array<float,2>{0.552414238f, 0.718388855f},
std::array<float,2>{0.419850767f, 0.511118472f},
std::array<float,2>{0.652294457f, 0.208764777f},
std::array<float,2>{0.217824966f, 0.269877672f},
std::array<float,2>{0.901017368f, 0.989023924f},
std::array<float,2>{0.130766764f, 0.649472356f},
std::array<float,2>{0.959546208f, 0.0709257126f},
std::array<float,2>{0.478741527f, 0.379165888f},
std::array<float,2>{0.723358452f, 0.81842649f},
std::array<float,2>{0.251658648f, 0.922732711f},
std::array<float,2>{0.614149928f, 0.373411924f},
std::array<float,2>{0.102895916f, 0.177777171f},
std::array<float,2>{0.86859709f, 0.578502119f},
std::array<float,2>{0.138922408f, 0.79898423f},
std::array<float,2>{0.962170839f, 0.444576383f},
std::array<float,2>{0.475914598f, 0.019833073f},
std::array<float,2>{0.731110752f, 0.689258218f},
std::array<float,2>{0.265429467f, 0.526692986f},
std::array<float,2>{0.623367667f, 0.194737107f},
std::array<float,2>{0.0950252041f, 0.261125147f},
std::array<float,2>{0.865455985f, 0.978690922f},
std::array<float,2>{0.0289433412f, 0.632840335f},
std::array<float,2>{0.759924293f, 0.0877433792f},
std::array<float,2>{0.335217237f, 0.39468804f},
std::array<float,2>{0.556081414f, 0.838442445f},
std::array<float,2>{0.406826615f, 0.913297653f},
std::array<float,2>{0.643787563f, 0.351423979f},
std::array<float,2>{0.203672722f, 0.157768041f},
std::array<float,2>{0.892121196f, 0.573925972f},
std::array<float,2>{0.0868946016f, 0.955813885f},
std::array<float,2>{0.829750061f, 0.287438005f},
std::array<float,2>{0.287464738f, 0.229718894f},
std::array<float,2>{0.565261483f, 0.547070861f},
std::array<float,2>{0.457697272f, 0.731187761f},
std::array<float,2>{0.707163811f, 0.0527293347f},
std::array<float,2>{0.163888738f, 0.496405244f},
std::array<float,2>{0.983346879f, 0.77968657f},
std::array<float,2>{0.246575236f, 0.61753428f},
std::array<float,2>{0.928403616f, 0.154021397f},
std::array<float,2>{0.397791386f, 0.325788617f},
std::array<float,2>{0.661167145f, 0.885661542f},
std::array<float,2>{0.345192134f, 0.874944866f},
std::array<float,2>{0.527946293f, 0.412150145f},
std::array<float,2>{0.0535288528f, 0.108872823f},
std::array<float,2>{0.791978896f, 0.67249006f},
std::array<float,2>{0.198461697f, 0.905419171f},
std::array<float,2>{0.881700099f, 0.328210533f},
std::array<float,2>{0.435400277f, 0.140248224f},
std::array<float,2>{0.626525402f, 0.593919873f},
std::array<float,2>{0.32114765f, 0.667011142f},
std::array<float,2>{0.538149774f, 0.110525526f},
std::array<float,2>{0.00637401501f, 0.43357867f},
std::array<float,2>{0.777552843f, 0.857606292f},
std::array<float,2>{0.113641277f, 0.545322418f},
std::array<float,2>{0.849843204f, 0.240061522f},
std::array<float,2>{0.276969761f, 0.297656685f},
std::array<float,2>{0.5978719f, 0.944067538f},
std::array<float,2>{0.489626974f, 0.756135404f},
std::array<float,2>{0.742453814f, 0.474423677f},
std::array<float,2>{0.145858154f, 0.0440644026f},
std::array<float,2>{0.940102398f, 0.743671298f},
std::array<float,2>{0.0346312746f, 0.815779388f},
std::array<float,2>{0.806454241f, 0.378867745f},
std::array<float,2>{0.362603128f, 0.0770726278f},
std::array<float,2>{0.505130708f, 0.655437171f},
std::array<float,2>{0.387003839f, 0.585743904f},
std::array<float,2>{0.675961137f, 0.174923435f},
std::array<float,2>{0.219660297f, 0.370425165f},
std::array<float,2>{0.909830093f, 0.927729964f},
std::array<float,2>{0.176216394f, 0.712916791f},
std::array<float,2>{0.986192048f, 0.00303898682f},
std::array<float,2>{0.441304386f, 0.455107421f},
std::array<float,2>{0.699840605f, 0.783393264f},
std::array<float,2>{0.303349167f, 0.986538231f},
std::array<float,2>{0.58708334f, 0.266486585f},
std::array<float,2>{0.0722202435f, 0.204253227f},
std::array<float,2>{0.814296722f, 0.513131201f},
std::array<float,2>{0.230040371f, 0.849833727f},
std::array<float,2>{0.919945359f, 0.422605485f},
std::array<float,2>{0.37870723f, 0.122590117f},
std::array<float,2>{0.682930827f, 0.658239663f},
std::array<float,2>{0.37458092f, 0.606661916f},
std::array<float,2>{0.514857411f, 0.130644068f},
std::array<float,2>{0.0408878773f, 0.338469774f},
std::array<float,2>{0.800087869f, 0.890924454f},
std::array<float,2>{0.069447957f, 0.736622572f},
std::array<float,2>{0.821337581f, 0.0370608754f},
std::array<float,2>{0.308563799f, 0.476654619f},
std::array<float,2>{0.585169256f, 0.760081351f},
std::array<float,2>{0.450756371f, 0.950747848f},
std::array<float,2>{0.688851118f, 0.305323809f},
std::array<float,2>{0.182090312f, 0.249077544f},
std::array<float,2>{0.997716367f, 0.532567441f},
std::array<float,2>{0.00873024575f, 0.932005703f},
std::array<float,2>{0.770757258f, 0.367156982f},
std::array<float,2>{0.314367205f, 0.179970041f},
std::array<float,2>{0.540901482f, 0.588797987f},
std::array<float,2>{0.427503526f, 0.642960489f},
std::array<float,2>{0.638597608f, 0.064347066f},
std::array<float,2>{0.194466189f, 0.383952409f},
std::array<float,2>{0.88972491f, 0.827778578f},
std::array<float,2>{0.152289912f, 0.502309263f},
std::array<float,2>{0.948771298f, 0.214356378f},
std::array<float,2>{0.495747834f, 0.277780741f},
std::array<float,2>{0.741124868f, 0.995714962f},
std::array<float,2>{0.266658127f, 0.795544863f},
std::array<float,2>{0.606064379f, 0.466813326f},
std::array<float,2>{0.122476786f, 0.00987111311f},
std::array<float,2>{0.852425396f, 0.708950937f},
std::array<float,2>{0.167412326f, 0.969343066f},
std::array<float,2>{0.974706471f, 0.250285298f},
std::array<float,2>{0.46210742f, 0.197998077f},
std::array<float,2>{0.717922986f, 0.523217082f},
std::array<float,2>{0.291920811f, 0.700689614f},
std::array<float,2>{0.575635552f, 0.0254651308f},
std::array<float,2>{0.0813768432f, 0.446659774f},
std::array<float,2>{0.843473673f, 0.811778784f},
std::array<float,2>{0.0624935068f, 0.567856908f},
std::array<float,2>{0.788917303f, 0.16937016f},
std::array<float,2>{0.357347846f, 0.359263718f},
std::array<float,2>{0.51918292f, 0.91536355f},
std::array<float,2>{0.40606454f, 0.832947552f},
std::array<float,2>{0.669070899f, 0.404603899f},
std::array<float,2>{0.238539234f, 0.0851992816f},
std::array<float,2>{0.932956934f, 0.629254818f},
std::array<float,2>{0.108553469f, 0.772332668f},
std::array<float,2>{0.874622643f, 0.488768607f},
std::array<float,2>{0.257484555f, 0.0619158819f},
std::array<float,2>{0.609874964f, 0.722814262f},
std::array<float,2>{0.483633757f, 0.560477734f},
std::array<float,2>{0.721004963f, 0.219418615f},
std::array<float,2>{0.127763197f, 0.291263074f},
std::array<float,2>{0.954300463f, 0.963231921f},
std::array<float,2>{0.21103327f, 0.687024474f},
std::array<float,2>{0.904606223f, 0.0977305472f},
std::array<float,2>{0.417446256f, 0.419171542f},
std::array<float,2>{0.655279696f, 0.862133503f},
std::array<float,2>{0.342603743f, 0.875993848f},
std::array<float,2>{0.548736989f, 0.314785749f},
std::array<float,2>{0.0205272604f, 0.145523295f},
std::array<float,2>{0.753599405f, 0.616975009f}} | 49.002441 | 52 | 0.734702 | st-ario |
97e44e0a09f0f6cba84334a9a869ab7feedaa76d | 187 | cpp | C++ | structural/main.cpp | eivinsam/structural | f36e6606f0b6c0ba9d4eed5eebe20543ed16e15e | [
"MIT"
] | null | null | null | structural/main.cpp | eivinsam/structural | f36e6606f0b6c0ba9d4eed5eebe20543ed16e15e | [
"MIT"
] | null | null | null | structural/main.cpp | eivinsam/structural | f36e6606f0b6c0ba9d4eed5eebe20543ed16e15e | [
"MIT"
] | null | null | null | #include <oui_window.h>
oui::window::Description oui::window::initialize()
{
return { "structural", 1280, 720 };
}
void oui::window::update(oui::Rectangle area, oui::Input& input)
{
} | 17 | 64 | 0.684492 | eivinsam |
97e4abe74f762aa913105d17f6871450252b07ee | 2,598 | cpp | C++ | test/run_test_xuanwu.cpp | chnlkw/xuanwu | f796e9a851d8fad289ac5a625679e7db6c090a04 | [
"MIT"
] | 1 | 2018-04-09T01:45:17.000Z | 2018-04-09T01:45:17.000Z | test/run_test_xuanwu.cpp | chnlkw/xuanwu | f796e9a851d8fad289ac5a625679e7db6c090a04 | [
"MIT"
] | null | null | null | test/run_test_xuanwu.cpp | chnlkw/xuanwu | f796e9a851d8fad289ac5a625679e7db6c090a04 | [
"MIT"
] | 1 | 2020-04-14T03:39:20.000Z | 2020-04-14T03:39:20.000Z | #include <iostream>
#include <vector>
#include <random>
#include <map>
#include <functional>
#include <set>
#include <xuanwu.hpp>
#include <gtest/gtest.h>
#include "Kernels.h"
#include <boost/di.hpp>
namespace di = boost::di;
using namespace Xuanwu;
namespace std {
template<class K, class V>
std::ostream &operator<<(std::ostream &os, const std::pair<K, V> &p) {
os << "(" << p.first << "," << p.second << ")";
return os;
};
}
TEST(Xuanwu, AddTask) {
auto print = [](const auto &arr) {
printf("%p : ", &arr[0]);
for (unsigned i = 0; i < arr.size(); i++) {
printf("%d ", arr[i]);
}
printf("\n");
};
auto d1 = Data<int>(10);
d1.Write();
auto d2 = Data<int>(d1.size());
d2.Write();
for (unsigned i = 0; i < d1.size(); i++) {
d1[i] = i;
d2[i] = i * i;
}
auto d3 = Data<int>(d1.size());
print(d1);
print(d2);
auto t1 = create_taskadd(d1, d2, d3);
Xuanwu::AddTask(t1);
auto d4 = Data<int>(d1.size());
auto t2 = create_taskadd(d2, d3, d4);
Xuanwu::AddTask(t2);
t2->WaitFinish();
// LOG(INFO) << "After resize";
d1.Read();
d2.Read();
d3.Read();
d4.Read();
// d1.resize(2);
print(d1);
print(d2);
d3.Read();
CUDA_CHECK();
print(d3);
d4.Read();
CUDA_CHECK();
print(d4);
}
INITIALIZE_EASYLOGGINGPP
size_t gpu_memory = 100LU<<20;
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
el::Loggers::configureFromGlobal("logging.conf");
int num_gpu = DataCopyInitP2P();
auto injector = di::make_injector(
di::bind<>.to(GPUDevice::NumWorkers{4}),
#ifdef NUMA
di::bind<AllocatorFactory<CPUDevice>>().to<NumaAllocatorFactory<CudaHostAllocator>>(),
#else
di::bind<AllocatorFactory<CPUDevice>>().to<CudaHostAllocatorFactory>(),
#endif
// di::bind<AllocatorFactory<GPUDevice>>().to<CudaAllocatorFactory>(),
di::bind<AllocatorFactory<GPUDevice>>().to<PreAllocatorFactory<CudaAllocatorFactory>>(),
di::bind<>.to(PreAllocatorFactory<CudaAllocatorFactory>::Space{gpu_memory}),
di::bind<MMBase>().to<MMMultiDevice<CPUDevice, GPUDevice>>(),
di::bind<MyDeviceGroup>().to(MultipleDevicesGroup<CPUDevice, GPUDevice>(1, num_gpu))
);
// auto m = injector.create<std::unique_ptr<MMBase>>();
// auto e = injector.create<std::unique_ptr<Engine>>();
auto xw = injector.create<std::shared_ptr<Xuanwu::Xuanwu>>();
int ret = RUN_ALL_TESTS();
return ret;
} | 25.223301 | 100 | 0.583526 | chnlkw |
97e6fe9b9ba656e667aff15e2474f2a79fc6594a | 506 | cpp | C++ | 05. Searching/Find_Right_Interval.cpp | Ujjawalgupta42/Hacktoberfest2021-DSA | eccd9352055085973e3d6a1feb10dd193905584b | [
"MIT"
] | 225 | 2021-10-01T03:09:01.000Z | 2022-03-11T11:32:49.000Z | 05. Searching/Find_Right_Interval.cpp | Ujjawalgupta42/Hacktoberfest2021-DSA | eccd9352055085973e3d6a1feb10dd193905584b | [
"MIT"
] | 252 | 2021-10-01T03:45:20.000Z | 2021-12-07T18:32:46.000Z | 05. Searching/Find_Right_Interval.cpp | Ujjawalgupta42/Hacktoberfest2021-DSA | eccd9352055085973e3d6a1feb10dd193905584b | [
"MIT"
] | 911 | 2021-10-01T02:55:19.000Z | 2022-02-06T09:08:37.000Z | // link to problem: https://leetcode.com/problems/find-right-interval/
class Solution {
public:
vector<int> findRightInterval(vector<vector<int>>& intervals) {
map<int,int> m;
vector<int> ans(intervals.size());
for(int i=0;i<intervals.size();i++){
m[intervals[i][0]]=i;
}
for(int i=0;i<intervals.size();i++){
ans[i]=m.lower_bound(intervals[i][1])!=m.end()?m.lower_bound(intervals[i][1])->second:-1;
}
return ans;
}
}; | 31.625 | 101 | 0.567194 | Ujjawalgupta42 |
97e7033444b4adf50f216f36412f793fe70e3533 | 1,328 | cpp | C++ | tests/job/test_jobsystem.cpp | grandmaster789/bop | 909d4156503f83b66de3f7e3284e086bd98905eb | [
"MIT"
] | null | null | null | tests/job/test_jobsystem.cpp | grandmaster789/bop | 909d4156503f83b66de3f7e3284e086bd98905eb | [
"MIT"
] | null | null | null | tests/job/test_jobsystem.cpp | grandmaster789/bop | 909d4156503f83b66de3f7e3284e086bd98905eb | [
"MIT"
] | null | null | null | #include <iostream>
#include <memory>
#include "../../src/job/job_system.h"
#include <catch2/catch.hpp>
namespace testing {
// because of the statics and one-time initialization, we're kind of limited
// in setup/teardown of the scheduler. Hence, we only have a single file
// with a single scheduler configuration that is tested.
//
// We could possibly adress that, but it would mean getting rid of all static
// variables in the scheduler, and re-expressing shared queue access between
// worker threads by going via some kind of parent object.
//
// It's probably going to be trickier than the current setup.
std::atomic<uint32_t> g_Total;
uint32_t test_single_job() {
g_Total = 1111;
auto& job = bop::schedule(
[&] { g_Total = 2222; }
);
job.wait();
return g_Total;
}
uint32_t test_basic_continuation() {
g_Total = 1111;
auto& job = bop::schedule(
[&] { g_Total = 2222; })
.then([&] { g_Total = 3333; })
.then([&] { g_Total = 4444; });
job.wait();
return g_Total;
}
}
TEST_CASE("test_scheduler[single_job]") {
REQUIRE(testing::test_single_job() == 2222);
REQUIRE(testing::test_basic_continuation() == 4444);
} | 26.56 | 81 | 0.600904 | grandmaster789 |
97e8378eec4b6b95d002b74990d743da679d5325 | 32,738 | cpp | C++ | src/backend/vulkan/VulkanTexture.cpp | Shimmen/ArkoseRenderer | d39e1b3d5f5b669370b8aeed5cd1cfada5216763 | [
"MIT"
] | 7 | 2020-11-02T22:27:27.000Z | 2022-01-11T04:25:48.000Z | src/backend/vulkan/VulkanTexture.cpp | Shimmen/ArkoseRenderer | d39e1b3d5f5b669370b8aeed5cd1cfada5216763 | [
"MIT"
] | null | null | null | src/backend/vulkan/VulkanTexture.cpp | Shimmen/ArkoseRenderer | d39e1b3d5f5b669370b8aeed5cd1cfada5216763 | [
"MIT"
] | 2 | 2020-12-09T03:40:05.000Z | 2021-09-14T03:12:40.000Z | #include "VulkanTexture.h"
#include "backend/vulkan/VulkanBackend.h"
#include "utility/Profiling.h"
#include "utility/Logging.h"
#include <stb_image.h>
VulkanTexture::VulkanTexture(Backend& backend, TextureDescription desc)
: Texture(backend, desc)
{
SCOPED_PROFILE_ZONE_GPURESOURCE();
// HACK: Now we longer specify what usage we want for the texture, and instead always select all
// possible capabilities. However, some texture formats (e.g. sRGB formats) do not support being
// used as a storage image, so we need to explicitly disable it for those formats.
bool storageCapable = true;
switch (format()) {
case Texture::Format::R32:
vkFormat = VK_FORMAT_R32_UINT;
break;
case Texture::Format::RGBA8:
vkFormat = VK_FORMAT_R8G8B8A8_UNORM;
break;
case Texture::Format::sRGBA8:
vkFormat = VK_FORMAT_R8G8B8A8_SRGB;
storageCapable = false;
break;
case Texture::Format::R16F:
vkFormat = VK_FORMAT_R16_SFLOAT;
break;
case Texture::Format::R32F:
vkFormat = VK_FORMAT_R32_SFLOAT;
break;
case Texture::Format::RG16F:
vkFormat = VK_FORMAT_R16G16_SFLOAT;
break;
case Texture::Format::RG32F:
vkFormat = VK_FORMAT_R32G32_SFLOAT;
break;
case Texture::Format::RGBA16F:
vkFormat = VK_FORMAT_R16G16B16A16_SFLOAT;
break;
case Texture::Format::RGBA32F:
vkFormat = VK_FORMAT_R32G32B32A32_SFLOAT;
break;
case Texture::Format::Depth32F:
vkFormat = VK_FORMAT_D32_SFLOAT;
storageCapable = false;
break;
case Texture::Format::Depth24Stencil8:
vkFormat = VK_FORMAT_D24_UNORM_S8_UINT;
storageCapable = false;
break;
case Texture::Format::Unknown:
LogErrorAndExit("Trying to create new texture with format Unknown, which is not allowed!\n");
default:
ASSERT_NOT_REACHED();
}
// Unless we want to enable the multisampled storage images feature we can't have that.. So let's just not, for now..
// The Vulkan spec states: If the multisampled storage images feature is not enabled, and usage contains VK_IMAGE_USAGE_STORAGE_BIT, samples must be VK_SAMPLE_COUNT_1_BIT
if (multisampling() != Texture::Multisampling::None) {
storageCapable = false;
}
// Since we don't specify usage we have to assume all of them may be used (at least the common operations)
const VkImageUsageFlags attachmentFlags = hasDepthFormat() ? VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT : VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
VkImageUsageFlags usageFlags = attachmentFlags | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
if (storageCapable)
usageFlags |= VK_IMAGE_USAGE_STORAGE_BIT;
// (if we later want to generate mipmaps we need the ability to use each mip as a src & dst in blitting)
if (hasMipmaps()) {
usageFlags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
usageFlags |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
}
if (vulkanDebugMode) {
// for nsight debugging & similar stuff, which needs access to everything
usageFlags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
usageFlags |= VK_BUFFER_USAGE_TRANSFER_DST_BIT;
}
// TODO: For now always keep images in device local memory.
VmaAllocationCreateInfo allocCreateInfo = {};
allocCreateInfo.usage = VMA_MEMORY_USAGE_GPU_ONLY;
VkImageCreateInfo imageCreateInfo = { VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO };
imageCreateInfo.extent = { .width = extent().width(), .height = extent().height(), .depth = 1 };
imageCreateInfo.mipLevels = mipLevels();
imageCreateInfo.usage = usageFlags;
imageCreateInfo.format = vkFormat;
imageCreateInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
imageCreateInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
imageCreateInfo.samples = static_cast<VkSampleCountFlagBits>(multisampling());
imageCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
vkUsage = usageFlags;
switch (type()) {
case Type::Texture2D:
imageCreateInfo.imageType = VK_IMAGE_TYPE_2D;
imageCreateInfo.arrayLayers = arrayCount();
break;
case Type::Cubemap:
imageCreateInfo.imageType = VK_IMAGE_TYPE_2D;
imageCreateInfo.flags = VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
imageCreateInfo.arrayLayers = 6 * arrayCount();
break;
default:
ASSERT_NOT_REACHED();
}
{
SCOPED_PROFILE_ZONE_NAMED("vmaCreateImage");
auto& allocator = static_cast<VulkanBackend&>(backend).globalAllocator();
if (vmaCreateImage(allocator, &imageCreateInfo, &allocCreateInfo, &image, &allocation, nullptr) != VK_SUCCESS) {
LogError("VulkanBackend::newTexture(): could not create image.\n");
}
}
VkImageAspectFlags aspectFlags = 0u;
if (hasDepthFormat()) {
// Create view for the depth aspect only
aspectFlags |= VK_IMAGE_ASPECT_DEPTH_BIT;
} else {
aspectFlags |= VK_IMAGE_ASPECT_COLOR_BIT;
}
VkImageViewCreateInfo viewCreateInfo = { VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO };
viewCreateInfo.subresourceRange.aspectMask = aspectFlags;
viewCreateInfo.image = image;
viewCreateInfo.format = vkFormat;
viewCreateInfo.components = {
VK_COMPONENT_SWIZZLE_IDENTITY,
VK_COMPONENT_SWIZZLE_IDENTITY,
VK_COMPONENT_SWIZZLE_IDENTITY,
VK_COMPONENT_SWIZZLE_IDENTITY
};
viewCreateInfo.subresourceRange.baseMipLevel = 0;
viewCreateInfo.subresourceRange.levelCount = mipLevels();
switch (type()) {
case Type::Texture2D:
viewCreateInfo.subresourceRange.baseArrayLayer = 0;
viewCreateInfo.subresourceRange.layerCount = arrayCount();
viewCreateInfo.viewType = isArray()
? VK_IMAGE_VIEW_TYPE_2D_ARRAY
: VK_IMAGE_VIEW_TYPE_2D;
break;
case Type::Cubemap:
viewCreateInfo.subresourceRange.baseArrayLayer = 0;
viewCreateInfo.subresourceRange.layerCount = 6 * arrayCount();
viewCreateInfo.viewType = isArray()
? VK_IMAGE_VIEW_TYPE_CUBE_ARRAY
: VK_IMAGE_VIEW_TYPE_CUBE;
break;
default:
ASSERT_NOT_REACHED();
}
VkDevice device = static_cast<VulkanBackend&>(backend).device();
if (vkCreateImageView(device, &viewCreateInfo, nullptr, &imageView) != VK_SUCCESS) {
LogError("VulkanBackend::newTexture(): could not create image view.\n");
}
VkFilter vkMinFilter;
switch (minFilter()) {
case Texture::MinFilter::Linear:
vkMinFilter = VK_FILTER_LINEAR;
break;
case Texture::MinFilter::Nearest:
vkMinFilter = VK_FILTER_NEAREST;
break;
default:
vkMinFilter = VK_FILTER_MAX_ENUM;
ASSERT_NOT_REACHED();
}
VkFilter vkMagFilter;
switch (magFilter()) {
case Texture::MagFilter::Linear:
vkMagFilter = VK_FILTER_LINEAR;
break;
case Texture::MagFilter::Nearest:
vkMagFilter = VK_FILTER_NEAREST;
break;
default:
vkMagFilter = VK_FILTER_MAX_ENUM;
ASSERT_NOT_REACHED();
}
auto wrapModeToAddressMode = [](WrapMode mode) -> VkSamplerAddressMode {
switch (mode) {
case WrapMode::Repeat:
return VK_SAMPLER_ADDRESS_MODE_REPEAT;
case WrapMode::MirroredRepeat:
return VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT;
case WrapMode::ClampToEdge:
return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
default:
ASSERT_NOT_REACHED();
}
};
VkSamplerCreateInfo samplerCreateInfo = { VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO };
samplerCreateInfo.unnormalizedCoordinates = VK_FALSE;
samplerCreateInfo.magFilter = vkMagFilter;
samplerCreateInfo.minFilter = vkMinFilter;
samplerCreateInfo.addressModeU = wrapModeToAddressMode(wrapMode().u);
samplerCreateInfo.addressModeV = wrapModeToAddressMode(wrapMode().v);
samplerCreateInfo.addressModeW = wrapModeToAddressMode(wrapMode().w);
samplerCreateInfo.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK;
samplerCreateInfo.anisotropyEnable = VK_TRUE;
samplerCreateInfo.maxAnisotropy = 16.0f;
samplerCreateInfo.compareEnable = VK_FALSE;
samplerCreateInfo.compareOp = VK_COMPARE_OP_ALWAYS;
samplerCreateInfo.mipLodBias = 0.0f;
samplerCreateInfo.minLod = 0.0f;
switch (mipmap()) {
case Texture::Mipmap::None:
samplerCreateInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST;
samplerCreateInfo.maxLod = 0.0f;
break;
case Texture::Mipmap::Nearest:
samplerCreateInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST;
samplerCreateInfo.maxLod = static_cast<float>(mipLevels());
break;
case Texture::Mipmap::Linear:
samplerCreateInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
samplerCreateInfo.maxLod = static_cast<float>(mipLevels());
break;
}
if (vkCreateSampler(device, &samplerCreateInfo, nullptr, &sampler) != VK_SUCCESS) {
LogError("VulkanBackend::newTexture(): could not create sampler for the image.\n");
}
currentLayout = VK_IMAGE_LAYOUT_UNDEFINED;
}
VulkanTexture::~VulkanTexture()
{
if (!hasBackend())
return;
auto& vulkanBackend = static_cast<VulkanBackend&>(backend());
vkDestroySampler(vulkanBackend.device(), sampler, nullptr);
vkDestroyImageView(vulkanBackend.device(), imageView, nullptr);
vmaDestroyImage(vulkanBackend.globalAllocator(), image, allocation);
}
void VulkanTexture::setName(const std::string& name)
{
SCOPED_PROFILE_ZONE_GPURESOURCE();
Resource::setName(name);
auto& vulkanBackend = static_cast<VulkanBackend&>(backend());
if (vulkanBackend.hasDebugUtilsSupport()) {
std::string imageViewName = name + "-view";
std::string samplerName = name + "-sampler";
{
VkDebugUtilsObjectNameInfoEXT nameInfo = { VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT };
nameInfo.objectType = VK_OBJECT_TYPE_IMAGE;
nameInfo.objectHandle = reinterpret_cast<uint64_t>(image);
nameInfo.pObjectName = name.c_str();
if (vulkanBackend.debugUtils().vkSetDebugUtilsObjectNameEXT(vulkanBackend.device(), &nameInfo) != VK_SUCCESS) {
LogWarning("Could not set debug name for vulkan image resource.\n");
}
}
{
VkDebugUtilsObjectNameInfoEXT nameInfo = { VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT };
nameInfo.objectType = VK_OBJECT_TYPE_IMAGE_VIEW;
nameInfo.objectHandle = reinterpret_cast<uint64_t>(imageView);
nameInfo.pObjectName = imageViewName.c_str();
if (vulkanBackend.debugUtils().vkSetDebugUtilsObjectNameEXT(vulkanBackend.device(), &nameInfo) != VK_SUCCESS) {
LogWarning("Could not set debug name for vulkan image view resource.\n");
}
}
{
VkDebugUtilsObjectNameInfoEXT nameInfo = { VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT };
nameInfo.objectType = VK_OBJECT_TYPE_SAMPLER;
nameInfo.objectHandle = reinterpret_cast<uint64_t>(sampler);
nameInfo.pObjectName = samplerName.c_str();
if (vulkanBackend.debugUtils().vkSetDebugUtilsObjectNameEXT(vulkanBackend.device(), &nameInfo) != VK_SUCCESS) {
LogWarning("Could not set debug name for vulkan sampler resource.\n");
}
}
}
}
void VulkanTexture::clear(ClearColor color)
{
SCOPED_PROFILE_ZONE_GPURESOURCE();
auto& vulkanBackend = static_cast<VulkanBackend&>(backend());
// TODO: Support depth texture clears!
ASSERT(!hasDepthFormat());
std::optional<VkImageLayout> originalLayout;
if (currentLayout != VK_IMAGE_LAYOUT_GENERAL && currentLayout != VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL) {
originalLayout = currentLayout;
VkImageMemoryBarrier imageBarrier = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER };
imageBarrier.oldLayout = originalLayout.value();
imageBarrier.newLayout = VK_IMAGE_LAYOUT_GENERAL;
imageBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
imageBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
imageBarrier.image = image;
imageBarrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
imageBarrier.subresourceRange.baseMipLevel = 0;
imageBarrier.subresourceRange.levelCount = mipLevels();
imageBarrier.subresourceRange.baseArrayLayer = 0;
imageBarrier.subresourceRange.layerCount = layerCount();
// FIXME: Probably overly aggressive barriers!
VkPipelineStageFlags sourceStage = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
imageBarrier.srcAccessMask = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT;
VkPipelineStageFlags destinationStage = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
imageBarrier.dstAccessMask = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT;
bool success = vulkanBackend.issueSingleTimeCommand([&](VkCommandBuffer commandBuffer) {
vkCmdPipelineBarrier(commandBuffer,
sourceStage, destinationStage, 0,
0, nullptr,
0, nullptr,
1, &imageBarrier);
});
if (!success) {
LogError("Could not transition image to general layout.\n");
return;
}
}
VkClearColorValue clearValue {};
clearValue.float32[0] = color.r;
clearValue.float32[1] = color.g;
clearValue.float32[2] = color.b;
clearValue.float32[3] = color.a;
VkImageSubresourceRange range {};
range.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
range.baseMipLevel = 0;
range.levelCount = mipLevels();
range.baseArrayLayer = 0;
range.layerCount = layerCount();
bool success = vulkanBackend.issueSingleTimeCommand([&](VkCommandBuffer commandBuffer) {
vkCmdClearColorImage(commandBuffer, image, VK_IMAGE_LAYOUT_GENERAL, &clearValue, 1, &range);
});
if (!success) {
LogError("Could not clear the color image.\n");
return;
}
if (originalLayout.has_value() && originalLayout.value() != VK_IMAGE_LAYOUT_UNDEFINED && originalLayout.value() != VK_IMAGE_LAYOUT_PREINITIALIZED) {
VkImageMemoryBarrier imageBarrier = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER };
imageBarrier.oldLayout = VK_IMAGE_LAYOUT_GENERAL;
imageBarrier.newLayout = originalLayout.value();
imageBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
imageBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
imageBarrier.image = image;
imageBarrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
imageBarrier.subresourceRange.baseMipLevel = 0;
imageBarrier.subresourceRange.levelCount = mipLevels();
imageBarrier.subresourceRange.baseArrayLayer = 0;
imageBarrier.subresourceRange.layerCount = layerCount();
// FIXME: Probably overly aggressive barriers!
VkPipelineStageFlags sourceStage = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
imageBarrier.srcAccessMask = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT;
VkPipelineStageFlags destinationStage = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
imageBarrier.dstAccessMask = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT;
bool success = vulkanBackend.issueSingleTimeCommand([&](VkCommandBuffer commandBuffer) {
vkCmdPipelineBarrier(commandBuffer,
sourceStage, destinationStage, 0,
0, nullptr,
0, nullptr,
1, &imageBarrier);
});
if (!success) {
LogError("Could not transition image back to original layout.\n");
return;
}
}
}
void VulkanTexture::setPixelData(vec4 pixel)
{
SCOPED_PROFILE_ZONE_GPURESOURCE();
int numChannels;
bool isHdr = false;
switch (format()) {
case Texture::Format::R32:
numChannels = 1;
isHdr = false;
break;
case Texture::Format::R16F:
case Texture::Format::R32F:
numChannels = 1;
isHdr = true;
break;
case Texture::Format::RG16F:
case Texture::Format::RG32F:
numChannels = 2;
isHdr = true;
break;
case Texture::Format::RGBA8:
case Texture::Format::sRGBA8:
numChannels = 4;
isHdr = false;
break;
case Texture::Format::RGBA16F:
case Texture::Format::RGBA32F:
numChannels = 4;
isHdr = true;
break;
case Texture::Format::Depth32F:
numChannels = 1;
isHdr = true;
break;
case Texture::Format::Unknown:
ASSERT_NOT_REACHED();
break;
}
ASSERT(numChannels == 4);
moos::u8 pixels[4];
VkDeviceSize pixelsSize;
if (isHdr) {
pixelsSize = sizeof(vec4);
} else {
pixels[0] = (stbi_uc)(moos::clamp(pixel.x, 0.0f, 1.0f) * 255.99f);
pixels[1] = (stbi_uc)(moos::clamp(pixel.y, 0.0f, 1.0f) * 255.99f);
pixels[2] = (stbi_uc)(moos::clamp(pixel.z, 0.0f, 1.0f) * 255.99f);
pixels[3] = (stbi_uc)(moos::clamp(pixel.w, 0.0f, 1.0f) * 255.99f);
pixelsSize = 4 * sizeof(stbi_uc);
}
VkBufferCreateInfo bufferCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
bufferCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
bufferCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
bufferCreateInfo.size = pixelsSize;
VmaAllocationCreateInfo allocCreateInfo = {};
allocCreateInfo.usage = VMA_MEMORY_USAGE_CPU_ONLY;
auto& vulkanBackend = static_cast<VulkanBackend&>(backend());
VkBuffer stagingBuffer;
VmaAllocation stagingAllocation;
if (vmaCreateBuffer(vulkanBackend.globalAllocator(), &bufferCreateInfo, &allocCreateInfo, &stagingBuffer, &stagingAllocation, nullptr) != VK_SUCCESS) {
LogError("Could not create staging buffer for updating image with pixel-data.\n");
}
if (!vulkanBackend.setBufferMemoryUsingMapping(stagingAllocation, isHdr ? (uint8_t*)value_ptr(pixel) : (uint8_t*)pixels, pixelsSize)) {
LogError("Could not set the buffer memory for the staging buffer for updating image with pixel-data.\n");
return;
}
AtScopeExit cleanUpStagingBuffer([&]() {
vmaDestroyBuffer(vulkanBackend.globalAllocator(), stagingBuffer, stagingAllocation);
});
if (currentLayout != VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL) {
VkImageMemoryBarrier imageBarrier = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER };
imageBarrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED;
imageBarrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
imageBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
imageBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
imageBarrier.image = image;
imageBarrier.subresourceRange.aspectMask = aspectMask();
imageBarrier.subresourceRange.baseMipLevel = 0;
imageBarrier.subresourceRange.levelCount = 1;
imageBarrier.subresourceRange.baseArrayLayer = 0;
imageBarrier.subresourceRange.layerCount = 1;
VkPipelineStageFlags sourceStage = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
imageBarrier.srcAccessMask = 0;
VkPipelineStageFlags destinationStage = VK_PIPELINE_STAGE_TRANSFER_BIT;
imageBarrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
bool success = vulkanBackend.issueSingleTimeCommand([&](VkCommandBuffer commandBuffer) {
vkCmdPipelineBarrier(commandBuffer, sourceStage, destinationStage, 0,
0, nullptr,
0, nullptr,
1, &imageBarrier);
});
if (!success) {
LogError("Could not transition the image to transfer optimal layout.\n");
return;
}
}
if (!vulkanBackend.copyBufferToImage(stagingBuffer, image, 1, 1, hasDepthFormat())) {
LogError("Could not copy the staging buffer to the image.\n");
return;
}
VkImageMemoryBarrier imageBarrier = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER };
{
imageBarrier.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
imageBarrier.newLayout = VK_IMAGE_LAYOUT_GENERAL;
imageBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
imageBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
imageBarrier.image = image;
imageBarrier.subresourceRange.aspectMask = aspectMask();
imageBarrier.subresourceRange.baseMipLevel = 0;
imageBarrier.subresourceRange.levelCount = 1;
imageBarrier.subresourceRange.baseArrayLayer = 0;
imageBarrier.subresourceRange.layerCount = 1;
imageBarrier.srcAccessMask = 0;
imageBarrier.dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
}
bool success = static_cast<VulkanBackend&>(backend()).issueSingleTimeCommand([&](VkCommandBuffer commandBuffer) {
vkCmdPipelineBarrier(commandBuffer,
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0,
0, nullptr,
0, nullptr,
1, &imageBarrier);
});
if (!success) {
LogError("Error transitioning layout after setting pixel data\n");
}
currentLayout = VK_IMAGE_LAYOUT_GENERAL;
}
void VulkanTexture::setData(const void* data, size_t size)
{
SCOPED_PROFILE_ZONE_GPURESOURCE();
auto& vulkanBackend = static_cast<VulkanBackend&>(backend());
VkBufferCreateInfo bufferCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
bufferCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
bufferCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
bufferCreateInfo.size = size;
VmaAllocationCreateInfo allocCreateInfo = {};
allocCreateInfo.usage = VMA_MEMORY_USAGE_CPU_ONLY;
VkBuffer stagingBuffer;
VmaAllocation stagingAllocation;
if (vmaCreateBuffer(vulkanBackend.globalAllocator(), &bufferCreateInfo, &allocCreateInfo, &stagingBuffer, &stagingAllocation, nullptr) != VK_SUCCESS) {
LogError("VulkanBackend::updateTexture(): could not create staging buffer.\n");
}
if (!vulkanBackend.setBufferMemoryUsingMapping(stagingAllocation, (uint8_t*)data, size)) {
LogError("VulkanBackend::updateTexture(): could set the buffer memory for the staging buffer.\n");
return;
}
AtScopeExit cleanUpStagingBuffer([&]() {
vmaDestroyBuffer(vulkanBackend.globalAllocator(), stagingBuffer, stagingAllocation);
});
if (currentLayout != VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL) {
VkImageMemoryBarrier imageBarrier = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER };
imageBarrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED;
imageBarrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
imageBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
imageBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
imageBarrier.image = image;
imageBarrier.subresourceRange.aspectMask = aspectMask();
imageBarrier.subresourceRange.baseMipLevel = 0;
imageBarrier.subresourceRange.levelCount = 1;
imageBarrier.subresourceRange.baseArrayLayer = 0;
imageBarrier.subresourceRange.layerCount = 1;
VkPipelineStageFlags sourceStage = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
imageBarrier.srcAccessMask = 0;
VkPipelineStageFlags destinationStage = VK_PIPELINE_STAGE_TRANSFER_BIT;
imageBarrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
bool success = vulkanBackend.issueSingleTimeCommand([&](VkCommandBuffer commandBuffer) {
vkCmdPipelineBarrier(commandBuffer, sourceStage, destinationStage, 0,
0, nullptr,
0, nullptr,
1, &imageBarrier);
});
if (!success) {
LogError("Could not transition the image to transfer optimal layout.\n");
return;
}
}
if (!vulkanBackend.copyBufferToImage(stagingBuffer, image, extent().width(), extent().height(), hasDepthFormat())) {
LogError("Could not copy the staging buffer to the image.\n");
return;
}
currentLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
if (mipmap() != Texture::Mipmap::None && extent().width() > 1 && extent().height() > 1) {
generateMipmaps();
} else {
VkImageMemoryBarrier imageBarrier = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER };
{
imageBarrier.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
imageBarrier.newLayout = VK_IMAGE_LAYOUT_GENERAL;
imageBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
imageBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
imageBarrier.image = image;
imageBarrier.subresourceRange.aspectMask = aspectMask();
imageBarrier.subresourceRange.baseMipLevel = 0;
imageBarrier.subresourceRange.levelCount = 1;
imageBarrier.subresourceRange.baseArrayLayer = 0;
imageBarrier.subresourceRange.layerCount = 1;
imageBarrier.srcAccessMask = 0;
imageBarrier.dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
}
bool success = static_cast<VulkanBackend&>(backend()).issueSingleTimeCommand([&](VkCommandBuffer commandBuffer) {
vkCmdPipelineBarrier(commandBuffer,
VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0,
0, nullptr,
0, nullptr,
1, &imageBarrier);
});
if (!success) {
LogError("Error transitioning layout after setting texture data\n");
}
}
currentLayout = VK_IMAGE_LAYOUT_GENERAL;
}
void VulkanTexture::generateMipmaps()
{
SCOPED_PROFILE_ZONE_GPURESOURCE();
if (!hasMipmaps()) {
LogError("VulkanTexture: generateMipmaps() called on texture which doesn't have space for mipmaps allocated. Ignoring request.\n");
return;
}
if (currentLayout == VK_IMAGE_LAYOUT_UNDEFINED) {
LogError("VulkanTexture: generateMipmaps() called on texture which currently has the layout VK_IMAGE_LAYOUT_UNDEFINED. Ignoring request.\n");
return;
}
VkImageMemoryBarrier barrier = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER };
barrier.subresourceRange.aspectMask = aspectMask();
barrier.image = image;
barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
barrier.subresourceRange.baseArrayLayer = 0;
barrier.subresourceRange.layerCount = 1;
barrier.subresourceRange.levelCount = 1;
uint32_t levels = mipLevels();
int32_t mipWidth = extent().width();
int32_t mipHeight = extent().height();
// We have to be very general in this function..
VkPipelineStageFlags dstStage = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
VkImageLayout finalLayout = VK_IMAGE_LAYOUT_GENERAL;
VkAccessFlags finalAccess = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT;
bool success = static_cast<VulkanBackend&>(backend()).issueSingleTimeCommand([&](VkCommandBuffer commandBuffer) {
// Transition mips 1-n to transfer dst optimal
{
VkImageMemoryBarrier initialBarrier = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER };
initialBarrier.image = image;
initialBarrier.subresourceRange.aspectMask = aspectMask();
initialBarrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED;
initialBarrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
initialBarrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
initialBarrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
initialBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
initialBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
initialBarrier.subresourceRange.baseArrayLayer = 0;
initialBarrier.subresourceRange.layerCount = 1;
initialBarrier.subresourceRange.baseMipLevel = 1;
initialBarrier.subresourceRange.levelCount = levels - 1;
vkCmdPipelineBarrier(commandBuffer,
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0,
0, nullptr,
0, nullptr,
1, &initialBarrier);
}
for (uint32_t i = 1; i < levels; ++i) {
int32_t nextWidth = mipWidth > 1 ? mipWidth / 2 : 1;
int32_t nextHeight = mipHeight > 1 ? mipHeight / 2 : 1;
// The 'currentLayout' keeps track of the whole image (or kind of mip0) but when we are messing
// with it here, it will have to be different for the different mip levels.
VkImageLayout oldLayout = (i == 1) ? currentLayout : VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
barrier.subresourceRange.baseMipLevel = i - 1;
barrier.oldLayout = oldLayout;
barrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
barrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
vkCmdPipelineBarrier(commandBuffer,
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0,
0, nullptr,
0, nullptr,
1, &barrier);
VkImageBlit blit = {};
blit.srcOffsets[0] = { 0, 0, 0 };
blit.srcOffsets[1] = { mipWidth, mipHeight, 1 };
blit.srcSubresource.aspectMask = aspectMask();
blit.srcSubresource.mipLevel = i - 1;
blit.srcSubresource.baseArrayLayer = 0;
blit.srcSubresource.layerCount = 1;
blit.dstOffsets[0] = { 0, 0, 0 };
blit.dstOffsets[1] = { nextWidth, nextHeight, 1 };
blit.dstSubresource.aspectMask = aspectMask();
blit.dstSubresource.mipLevel = i;
blit.dstSubresource.baseArrayLayer = 0;
blit.dstSubresource.layerCount = 1;
vkCmdBlitImage(commandBuffer,
image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
1, &blit,
VK_FILTER_LINEAR);
barrier.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
barrier.newLayout = finalLayout;
barrier.srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
barrier.dstAccessMask = finalAccess;
vkCmdPipelineBarrier(commandBuffer,
VK_PIPELINE_STAGE_TRANSFER_BIT, dstStage, 0,
0, nullptr,
0, nullptr,
1, &barrier);
mipWidth = nextWidth;
mipHeight = nextHeight;
}
barrier.subresourceRange.baseMipLevel = levels - 1;
barrier.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
barrier.newLayout = finalLayout;
barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
barrier.dstAccessMask = finalAccess;
vkCmdPipelineBarrier(commandBuffer,
VK_PIPELINE_STAGE_TRANSFER_BIT, dstStage, 0,
0, nullptr,
0, nullptr,
1, &barrier);
});
if (!success) {
LogError("VulkanTexture: error while generating mipmaps\n");
}
}
uint32_t VulkanTexture::layerCount() const
{
switch (type()) {
case Texture::Type::Texture2D:
return arrayCount();
case Texture::Type::Cubemap:
return 6 * arrayCount();
default:
ASSERT_NOT_REACHED();
}
}
VkImageAspectFlags VulkanTexture::aspectMask() const
{
VkImageAspectFlags mask = 0u;
if (hasDepthFormat()) {
mask |= VK_IMAGE_ASPECT_DEPTH_BIT;
if (hasStencilFormat())
mask |= VK_IMAGE_ASPECT_STENCIL_BIT;
} else {
mask |= VK_IMAGE_ASPECT_COLOR_BIT;
}
return mask;
}
| 40.070991 | 174 | 0.668581 | Shimmen |
97e90f3bdcbc8371608e10bf9bf69f4535f6f780 | 766 | cpp | C++ | linked_list/19_remove_Nth_node_from_end_of_list.cpp | rspezialetti/leetcode | 4614ffe2a4923aae02f93096b6200239e6f201c1 | [
"MIT"
] | 1 | 2019-08-21T21:25:34.000Z | 2019-08-21T21:25:34.000Z | linked_list/19_remove_Nth_node_from_end_of_list.cpp | rspezialetti/leetcode | 4614ffe2a4923aae02f93096b6200239e6f201c1 | [
"MIT"
] | null | null | null | linked_list/19_remove_Nth_node_from_end_of_list.cpp | rspezialetti/leetcode | 4614ffe2a4923aae02f93096b6200239e6f201c1 | [
"MIT"
] | null | null | null | /**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode* removeNthFromEnd(ListNode* head, int n)
{
ListNode* p1 = head;
ListNode* p2 = head;
for(int k = 0; k < n; ++k)
{
p2 = p2->next;
if(!p2)
return head->next;
}
while(p2)
{
p2 = p2->next;
if(p2 == nullptr)
{
p1->next = p1->next->next;
break;
}
else
{
p1 = p1->next;
}
}
return head;
}
};
| 19.15 | 54 | 0.362924 | rspezialetti |
97ecd6e60cca1510d0b00c74c3d8503ed7845cfc | 602 | cpp | C++ | clang/test/SemaTemplate/anonymous-union.cpp | clairechingching/ScaffCC | 737ae90f85d9fe79819d66219747d27efa4fa5b9 | [
"BSD-2-Clause"
] | 58 | 2016-08-27T03:19:14.000Z | 2022-01-05T17:33:44.000Z | clang/test/SemaTemplate/anonymous-union.cpp | clairechingching/ScaffCC | 737ae90f85d9fe79819d66219747d27efa4fa5b9 | [
"BSD-2-Clause"
] | 14 | 2017-12-01T17:16:59.000Z | 2020-12-21T12:16:35.000Z | clang/test/SemaTemplate/anonymous-union.cpp | clairechingching/ScaffCC | 737ae90f85d9fe79819d66219747d27efa4fa5b9 | [
"BSD-2-Clause"
] | 22 | 2016-11-27T09:53:31.000Z | 2021-11-22T00:22:53.000Z | // RUN: %clang_cc1 -fsyntax-only -verify %s
// PR5868
struct T0 {
int x;
union {
void *m0;
};
};
template <typename T>
struct T1 : public T0, public T {
void f0() {
m0 = 0; // expected-error{{ambiguous conversion}}
}
};
struct A : public T0 { };
void f1(T1<A> *S) { S->f0(); } // expected-note{{instantiation of member function}}
namespace rdar8635664 {
template<typename T>
struct X {
struct inner;
struct inner {
union {
int x;
float y;
};
typedef T type;
};
};
void test() {
X<int>::inner i;
i.x = 0;
}
}
| 14.682927 | 83 | 0.536545 | clairechingching |
97f00d5ac2bf65e3e4ea704afc2d160f16c51781 | 608 | cpp | C++ | 1. White/Week 2/04. Maximizer/main.cpp | AmaterasuOmikami/The-art-of-modern-Cpp-development | 4f0958197da92d216ee526384a6f7386a0fe62a0 | [
"MIT"
] | 1 | 2022-02-17T10:58:58.000Z | 2022-02-17T10:58:58.000Z | 1. White/Week 2/04. Maximizer/main.cpp | AmaterasuOmikami/The-art-of-modern-Cpp-development | 4f0958197da92d216ee526384a6f7386a0fe62a0 | [
"MIT"
] | null | null | null | 1. White/Week 2/04. Maximizer/main.cpp | AmaterasuOmikami/The-art-of-modern-Cpp-development | 4f0958197da92d216ee526384a6f7386a0fe62a0 | [
"MIT"
] | null | null | null | /*
* Напишите функцию UpdateIfGreater, которая принимает два целочисленных
* аргумента: first и second. Если first оказался больше second, Ваша функция
* должна записывать в second значение параметра first. При этом указанная
* функция не должна ничего возвращать, а изменение параметра second должно
* быть видно на вызывающей стороне.
*/
#include <iostream>
using namespace std;
void UpdateIfGreater(int first, int& second) {
if (first > second) {
second = first;
}
}
int main() {
int a = 13, b = 4;
UpdateIfGreater(a, b);
cout << "a: " << a << ", b: " << b << endl;
}
| 26.434783 | 77 | 0.674342 | AmaterasuOmikami |
97f1d17c41bb3592018f10de3d971d9c554fb8ac | 17,268 | cpp | C++ | examples/compiled_hello.cpp | rafzi/tflite_micro_compiler | 0b077f0e8e5895f62a992046ed05c877e78c0df8 | [
"Apache-2.0"
] | null | null | null | examples/compiled_hello.cpp | rafzi/tflite_micro_compiler | 0b077f0e8e5895f62a992046ed05c877e78c0df8 | [
"Apache-2.0"
] | null | null | null | examples/compiled_hello.cpp | rafzi/tflite_micro_compiler | 0b077f0e8e5895f62a992046ed05c877e78c0df8 | [
"Apache-2.0"
] | null | null | null | #include "tensorflow/lite/c/builtin_op_data.h"
#include <stdint.h>
#include <assert.h>
namespace tflite { namespace ops { namespace micro {
namespace quantize { extern void* Init(TfLiteContext*, const char*, size_t); }
namespace quantize { extern TfLiteStatus Prepare(TfLiteContext*, TfLiteNode*); }
namespace quantize { extern TfLiteStatus Eval(TfLiteContext*, TfLiteNode*); }
namespace fully_connected { extern void* Init(TfLiteContext*, const char*, size_t); }
namespace fully_connected { extern TfLiteStatus Prepare(TfLiteContext*, TfLiteNode*); }
namespace fully_connected { extern TfLiteStatus Eval(TfLiteContext*, TfLiteNode*); }
namespace dequantize { extern void* Init(TfLiteContext*, const char*, size_t); }
namespace dequantize { extern TfLiteStatus Prepare(TfLiteContext*, TfLiteNode*); }
namespace dequantize { extern TfLiteStatus Eval(TfLiteContext*, TfLiteNode*); }
} } }
static TfLiteTensor hello_tensors[12];
static TfLiteNode hello_nodes[5];
static TfLiteContext hello_context;
static const uint8_t hello_opdata0[0] = { }; /* op type 114 */
static const int hello_inputs0[2] = { 1, 10 };
static const int hello_outputs0[2] = { 1, 1 };
static const TfLiteFullyConnectedParams hello_opdata1 = { kTfLiteActRelu, kTfLiteFullyConnectedWeightsFormatDefault, false, false };
static const int hello_inputs1[4] = { 3, 1,2,3 };
static const int hello_outputs1[2] = { 1, 4 };
static const TfLiteFullyConnectedParams hello_opdata2 = { kTfLiteActRelu, kTfLiteFullyConnectedWeightsFormatDefault, false, false };
static const int hello_inputs2[4] = { 3, 4,5,6 };
static const int hello_outputs2[2] = { 1, 7 };
static const TfLiteFullyConnectedParams hello_opdata3 = { kTfLiteActNone, kTfLiteFullyConnectedWeightsFormatDefault, false, false };
static const int hello_inputs3[4] = { 3, 7,8,9 };
static const int hello_outputs3[2] = { 1, 0 };
static const uint8_t hello_opdata4[0] = { }; /* op type 6 */
static const int hello_inputs4[2] = { 1, 0 };
static const int hello_outputs4[2] = { 1, 11 };
static const int hello_tensor_dimension0[3] = { 2, 1,1 };
static const struct { int sz; float elem[1]; } hello_quant_scale0 = { 1, { 0.0084758, } };
static const int hello_quant_zero0[2] = { 1, 2};
static const TfLiteAffineQuantization hello_quantization0 = { (TfLiteFloatArray*)&hello_quant_scale0, (TfLiteIntArray*)&hello_quant_zero0, 0 };
static const int hello_tensor_dimension1[3] = { 2, 1,1 };
static const struct { int sz; float elem[1]; } hello_quant_scale1 = { 1, { 0.024574, } };
static const int hello_quant_zero1[2] = { 1, -128};
static const TfLiteAffineQuantization hello_quantization1 = { (TfLiteFloatArray*)&hello_quant_scale1, (TfLiteIntArray*)&hello_quant_zero1, 0 };
static const int8_t hello_tensor_data2[16*1] = {
115,
28,
17,
-31,
12,
-127,
-91,
67,
-2,
-43,
-43,
-78,
96,
119,
25,
-33,
};
static const int hello_tensor_dimension2[3] = { 2, 16,1 };
static const struct { int sz; float elem[1]; } hello_quant_scale2 = { 1, { 0.00422428, } };
static const int hello_quant_zero2[2] = { 1, 0};
static const TfLiteAffineQuantization hello_quantization2 = { (TfLiteFloatArray*)&hello_quant_scale2, (TfLiteIntArray*)&hello_quant_zero2, 0 };
static const int32_t hello_tensor_data3[16] = { 1, 2897, -2489, 0, 3100, 0, 0, 1435, 0, 0, 8423, 0, 1938, -2828, -4011, 0, };
static const int hello_tensor_dimension3[2] = { 1, 16 };
static const struct { int sz; float elem[1]; } hello_quant_scale3 = { 1, { 0.000103807, } };
static const int hello_quant_zero3[2] = { 1, 0};
static const TfLiteAffineQuantization hello_quantization3 = { (TfLiteFloatArray*)&hello_quant_scale3, (TfLiteIntArray*)&hello_quant_zero3, 0 };
static const int hello_tensor_dimension4[3] = { 2, 1,16 };
static const struct { int sz; float elem[1]; } hello_quant_scale4 = { 1, { 0.0119366, } };
static const int hello_quant_zero4[2] = { 1, -128};
static const TfLiteAffineQuantization hello_quantization4 = { (TfLiteFloatArray*)&hello_quant_scale4, (TfLiteIntArray*)&hello_quant_zero4, 0 };
static const int8_t hello_tensor_data5[16*16] = {
-18, -4, 0, -20, 5, 22, -17, -20, -26, -8, 3, 1, 0, -6, -8, -11,
-38, -21, 39, 20, -17, -34, -30, -38, -16, -33, 50, 6, 1, -26, -18, -7,
0, 22, 7, -32, -2, -1, -23, 5, -25, -17, -127, 27, 24, -22, -54, 1,
15, 0, -37, -9, 14, -20, 18, 30, 4, 19, -78, -25, -3, 6, -69, -32,
12, -20, -16, -33, -21, -9, 5, 38, 25, -28, 112, 26, -22, 30, 52, -33,
25, -13, -15, 25, 14, 3, 27, -31, -34, 19, -10, 25, -1, -10, 26, 23,
-15, 28, -37, 26, 26, 32, -26, 25, -11, -1, -105, 11, 0, 0, -50, -33,
13, -9, 21, -28, -19, -4, 13, -23, -5, -20, 92, -4, 29, 2, 88, -29,
-32, -12, 21, -20, -7, 0, 19, 5, -20, 12, 28, 20, 12, -23, 10, -12,
24, 0, -41, 5, 39, 2, 21, -22, -22, 2, -101, 0, 12, -6, -23, -22,
-2, 1, 20, -3, 11, 2, -16, -17, 6, -18, 1, 13, 6, -25, -9, 17,
-11, 10, -7, -15, 35, -1, 13, -14, -20, 17, 38, 29, -14, -22, 40, 24,
-32, -5, -13, -12, 5, 28, 29, -5, -3, 30, -4, 17, -24, 6, 9, 3,
18, -14, 53, -5, -35, 27, -7, -17, -13, -25, 111, 12, 29, 0, 67, -3,
13, -15, 10, 25, 26, -6, -32, 24, 30, 19, 55, 28, 18, -20, 58, 12,
-74, -53, -26, 19, -9, -21, -15, 5, 27, -6, 25, -27, -20, -49, 12, -12,
};
static const int hello_tensor_dimension5[3] = { 2, 16,16 };
static const struct { int sz; float elem[1]; } hello_quant_scale5 = { 1, { 0.0127847, } };
static const int hello_quant_zero5[2] = { 1, 0};
static const TfLiteAffineQuantization hello_quantization5 = { (TfLiteFloatArray*)&hello_quant_scale5, (TfLiteIntArray*)&hello_quant_zero5, 0 };
static const int32_t hello_tensor_data6[16] = { 0, 1276, 2719, 1637, -1987, 0, 2795, -2001, 1256, 2593, -442, 1224, 0, -2141, -1752, 1434, };
static const int hello_tensor_dimension6[2] = { 1, 16 };
static const struct { int sz; float elem[1]; } hello_quant_scale6 = { 1, { 0.000152606, } };
static const int hello_quant_zero6[2] = { 1, 0};
static const TfLiteAffineQuantization hello_quantization6 = { (TfLiteFloatArray*)&hello_quant_scale6, (TfLiteIntArray*)&hello_quant_zero6, 0 };
static const int hello_tensor_dimension7[3] = { 2, 1,16 };
static const struct { int sz; float elem[1]; } hello_quant_scale7 = { 1, { 0.00581308, } };
static const int hello_quant_zero7[2] = { 1, -128};
static const TfLiteAffineQuantization hello_quantization7 = { (TfLiteFloatArray*)&hello_quant_scale7, (TfLiteIntArray*)&hello_quant_zero7, 0 };
static const int8_t hello_tensor_data8[1*16] = {
33, -94, -116, -55, 95, 29, -50, 65, -97, -51, 32, -79, -33, 83, 47, -127,
};
static const int hello_tensor_dimension8[3] = { 2, 1,16 };
static const struct { int sz; float elem[1]; } hello_quant_scale8 = { 1, { 0.00849693, } };
static const int hello_quant_zero8[2] = { 1, 0};
static const TfLiteAffineQuantization hello_quantization8 = { (TfLiteFloatArray*)&hello_quant_scale8, (TfLiteIntArray*)&hello_quant_zero8, 0 };
static const int32_t hello_tensor_data9[1] = { -4382, };
static const int hello_tensor_dimension9[2] = { 1, 1 };
static const struct { int sz; float elem[1]; } hello_quant_scale9 = { 1, { 4.93934e-05, } };
static const int hello_quant_zero9[2] = { 1, 0};
static const TfLiteAffineQuantization hello_quantization9 = { (TfLiteFloatArray*)&hello_quant_scale9, (TfLiteIntArray*)&hello_quant_zero9, 0 };
static const int hello_tensor_dimension10[3] = { 2, 1,1 };
static const int hello_tensor_dimension11[3] = { 2, 1,1 };
static uint8_t* next_allocation = nullptr;
static TfLiteStatus AllocatePersistentBuffer(struct TfLiteContext* ctx, size_t bytes, void** ptr) {
next_allocation -= bytes;
*ptr = next_allocation;
return kTfLiteOk;
}
void hello_init(uint8_t* tensor_arena) {
hello_tensors[0].type = kTfLiteInt8;
hello_tensors[0].allocation_type = kTfLiteArenaRw;
hello_tensors[0].bytes = 1;
hello_tensors[0].name = (char*)"Identity_int8";
hello_tensors[0].dims = (struct TfLiteIntArray*)hello_tensor_dimension0;
hello_tensors[0].data.raw = (char*)(tensor_arena + 0);
hello_tensors[0].params.scale = 0.0084758;
hello_tensors[0].params.zero_point = 2;
hello_tensors[0].quantization.type = kTfLiteAffineQuantization;
hello_tensors[0].quantization.params = (void*)&hello_quantization0;
hello_tensors[1].type = kTfLiteInt8;
hello_tensors[1].allocation_type = kTfLiteArenaRw;
hello_tensors[1].bytes = 1;
hello_tensors[1].name = (char*)"dense_2_input_int8";
hello_tensors[1].dims = (struct TfLiteIntArray*)hello_tensor_dimension1;
hello_tensors[1].data.raw = (char*)(tensor_arena + 0);
hello_tensors[1].params.scale = 0.024574;
hello_tensors[1].params.zero_point = -128;
hello_tensors[1].quantization.type = kTfLiteAffineQuantization;
hello_tensors[1].quantization.params = (void*)&hello_quantization1;
hello_tensors[2].type = kTfLiteInt8;
hello_tensors[2].allocation_type = kTfLiteMmapRo;
hello_tensors[2].bytes = 16;
hello_tensors[2].name = (char*)"sequential_1/dense_2/MatMul/ReadVariableOp/transpose";
hello_tensors[2].dims = (struct TfLiteIntArray*)hello_tensor_dimension2;
hello_tensors[2].data.raw_const = (const char*)hello_tensor_data2;
hello_tensors[2].params.scale = 0.00422428;
hello_tensors[2].params.zero_point = 0;
hello_tensors[2].quantization.type = kTfLiteAffineQuantization;
hello_tensors[2].quantization.params = (void*)&hello_quantization2;
hello_tensors[3].type = kTfLiteInt32;
hello_tensors[3].allocation_type = kTfLiteMmapRo;
hello_tensors[3].bytes = 64;
hello_tensors[3].name = (char*)"sequential_1/dense_2/MatMul_bias";
hello_tensors[3].dims = (struct TfLiteIntArray*)hello_tensor_dimension3;
hello_tensors[3].data.raw_const = (const char*)hello_tensor_data3;
hello_tensors[3].params.scale = 0.000103807;
hello_tensors[3].params.zero_point = 0;
hello_tensors[3].quantization.type = kTfLiteAffineQuantization;
hello_tensors[3].quantization.params = (void*)&hello_quantization3;
hello_tensors[4].type = kTfLiteInt8;
hello_tensors[4].allocation_type = kTfLiteArenaRw;
hello_tensors[4].bytes = 16;
hello_tensors[4].name = (char*)"sequential_1/dense_2/Relu";
hello_tensors[4].dims = (struct TfLiteIntArray*)hello_tensor_dimension4;
hello_tensors[4].data.raw = (char*)(tensor_arena + 16);
hello_tensors[4].params.scale = 0.0119366;
hello_tensors[4].params.zero_point = -128;
hello_tensors[4].quantization.type = kTfLiteAffineQuantization;
hello_tensors[4].quantization.params = (void*)&hello_quantization4;
hello_tensors[5].type = kTfLiteInt8;
hello_tensors[5].allocation_type = kTfLiteMmapRo;
hello_tensors[5].bytes = 256;
hello_tensors[5].name = (char*)"sequential_1/dense_3/MatMul/ReadVariableOp/transpose";
hello_tensors[5].dims = (struct TfLiteIntArray*)hello_tensor_dimension5;
hello_tensors[5].data.raw_const = (const char*)hello_tensor_data5;
hello_tensors[5].params.scale = 0.0127847;
hello_tensors[5].params.zero_point = 0;
hello_tensors[5].quantization.type = kTfLiteAffineQuantization;
hello_tensors[5].quantization.params = (void*)&hello_quantization5;
hello_tensors[6].type = kTfLiteInt32;
hello_tensors[6].allocation_type = kTfLiteMmapRo;
hello_tensors[6].bytes = 64;
hello_tensors[6].name = (char*)"sequential_1/dense_3/MatMul_bias";
hello_tensors[6].dims = (struct TfLiteIntArray*)hello_tensor_dimension6;
hello_tensors[6].data.raw_const = (const char*)hello_tensor_data6;
hello_tensors[6].params.scale = 0.000152606;
hello_tensors[6].params.zero_point = 0;
hello_tensors[6].quantization.type = kTfLiteAffineQuantization;
hello_tensors[6].quantization.params = (void*)&hello_quantization6;
hello_tensors[7].type = kTfLiteInt8;
hello_tensors[7].allocation_type = kTfLiteArenaRw;
hello_tensors[7].bytes = 16;
hello_tensors[7].name = (char*)"sequential_1/dense_3/Relu";
hello_tensors[7].dims = (struct TfLiteIntArray*)hello_tensor_dimension7;
hello_tensors[7].data.raw = (char*)(tensor_arena + 32);
hello_tensors[7].params.scale = 0.00581308;
hello_tensors[7].params.zero_point = -128;
hello_tensors[7].quantization.type = kTfLiteAffineQuantization;
hello_tensors[7].quantization.params = (void*)&hello_quantization7;
hello_tensors[8].type = kTfLiteInt8;
hello_tensors[8].allocation_type = kTfLiteMmapRo;
hello_tensors[8].bytes = 16;
hello_tensors[8].name = (char*)"sequential_1/dense_4/MatMul/ReadVariableOp/transpose";
hello_tensors[8].dims = (struct TfLiteIntArray*)hello_tensor_dimension8;
hello_tensors[8].data.raw_const = (const char*)hello_tensor_data8;
hello_tensors[8].params.scale = 0.00849693;
hello_tensors[8].params.zero_point = 0;
hello_tensors[8].quantization.type = kTfLiteAffineQuantization;
hello_tensors[8].quantization.params = (void*)&hello_quantization8;
hello_tensors[9].type = kTfLiteInt32;
hello_tensors[9].allocation_type = kTfLiteMmapRo;
hello_tensors[9].bytes = 4;
hello_tensors[9].name = (char*)"sequential_1/dense_4/MatMul_bias";
hello_tensors[9].dims = (struct TfLiteIntArray*)hello_tensor_dimension9;
hello_tensors[9].data.raw_const = (const char*)hello_tensor_data9;
hello_tensors[9].params.scale = 4.93934e-05;
hello_tensors[9].params.zero_point = 0;
hello_tensors[9].quantization.type = kTfLiteAffineQuantization;
hello_tensors[9].quantization.params = (void*)&hello_quantization9;
hello_tensors[10].type = kTfLiteFloat32;
hello_tensors[10].allocation_type = kTfLiteArenaRw;
hello_tensors[10].bytes = 4;
hello_tensors[10].name = (char*)"dense_2_input";
hello_tensors[10].dims = (struct TfLiteIntArray*)hello_tensor_dimension10;
hello_tensors[10].data.raw = (char*)(tensor_arena + 16);
hello_tensors[11].type = kTfLiteFloat32;
hello_tensors[11].allocation_type = kTfLiteArenaRw;
hello_tensors[11].bytes = 4;
hello_tensors[11].name = (char*)"Identity";
hello_tensors[11].dims = (struct TfLiteIntArray*)hello_tensor_dimension11;
hello_tensors[11].data.raw = (char*)(tensor_arena + 16);
hello_nodes[0].inputs = (struct TfLiteIntArray*)hello_inputs0;
hello_nodes[0].outputs = (struct TfLiteIntArray*)hello_outputs0;
hello_nodes[0].builtin_data = (void*)&hello_opdata0;
hello_nodes[1].inputs = (struct TfLiteIntArray*)hello_inputs1;
hello_nodes[1].outputs = (struct TfLiteIntArray*)hello_outputs1;
hello_nodes[1].builtin_data = (void*)&hello_opdata1;
hello_nodes[2].inputs = (struct TfLiteIntArray*)hello_inputs2;
hello_nodes[2].outputs = (struct TfLiteIntArray*)hello_outputs2;
hello_nodes[2].builtin_data = (void*)&hello_opdata2;
hello_nodes[3].inputs = (struct TfLiteIntArray*)hello_inputs3;
hello_nodes[3].outputs = (struct TfLiteIntArray*)hello_outputs3;
hello_nodes[3].builtin_data = (void*)&hello_opdata3;
hello_nodes[4].inputs = (struct TfLiteIntArray*)hello_inputs4;
hello_nodes[4].outputs = (struct TfLiteIntArray*)hello_outputs4;
hello_nodes[4].builtin_data = (void*)&hello_opdata4;
hello_context.tensors_size = 12;
hello_context.tensors = (TfLiteTensor*)hello_tensors;
hello_context.AllocatePersistentBuffer = &AllocatePersistentBuffer;
next_allocation = tensor_arena + 3000; // = minimum size of the tensor arena
TfLiteStatus status = kTfLiteOk;
hello_nodes[0].user_data = tflite::ops::micro::quantize::Init(&hello_context, (const char*)(hello_nodes[0].builtin_data), 0);
hello_nodes[1].user_data = tflite::ops::micro::fully_connected::Init(&hello_context, (const char*)(hello_nodes[1].builtin_data), 0);
hello_nodes[2].user_data = tflite::ops::micro::fully_connected::Init(&hello_context, (const char*)(hello_nodes[2].builtin_data), 0);
hello_nodes[3].user_data = tflite::ops::micro::fully_connected::Init(&hello_context, (const char*)(hello_nodes[3].builtin_data), 0);
hello_nodes[4].user_data = tflite::ops::micro::dequantize::Init(&hello_context, (const char*)(hello_nodes[4].builtin_data), 0);
status = tflite::ops::micro::quantize::Prepare(&hello_context, &hello_nodes[0]);
assert(status==kTfLiteOk);
status = tflite::ops::micro::fully_connected::Prepare(&hello_context, &hello_nodes[1]);
assert(status==kTfLiteOk);
status = tflite::ops::micro::fully_connected::Prepare(&hello_context, &hello_nodes[2]);
assert(status==kTfLiteOk);
status = tflite::ops::micro::fully_connected::Prepare(&hello_context, &hello_nodes[3]);
assert(status==kTfLiteOk);
status = tflite::ops::micro::dequantize::Prepare(&hello_context, &hello_nodes[4]);
assert(status==kTfLiteOk);
hello_context.AllocatePersistentBuffer = nullptr;
}
void hello_invoke(float const*input, float* output) {
hello_tensors[10].data.raw_const = (const char*)input; // (1,1)
hello_tensors[11].data.raw = (char*)output; // (1,1)
TfLiteStatus status = kTfLiteOk;
status = tflite::ops::micro::quantize::Eval(&hello_context, &hello_nodes[0]); // Input 10 Output 1
assert(status==kTfLiteOk);
status = tflite::ops::micro::fully_connected::Eval(&hello_context, &hello_nodes[1]); // Input 1,2,3 Output 4
assert(status==kTfLiteOk);
status = tflite::ops::micro::fully_connected::Eval(&hello_context, &hello_nodes[2]); // Input 4,5,6 Output 7
assert(status==kTfLiteOk);
status = tflite::ops::micro::fully_connected::Eval(&hello_context, &hello_nodes[3]); // Input 7,8,9 Output 0
assert(status==kTfLiteOk);
status = tflite::ops::micro::dequantize::Eval(&hello_context, &hello_nodes[4]); // Input 0 Output 11
assert(status==kTfLiteOk);
}
| 58.734694 | 143 | 0.724809 | rafzi |
97f6c41d0fcb8f6ea8f119470bf7954e17830a16 | 3,205 | cpp | C++ | UICPC/13/UICPC Round #13 (Div 1)/UICPC Round #13 (Div 1)/submits/Aoi Albatross/Problem C - Car Vet/Accepted/submission_7511361_src/submission_7511361_src/main.cpp | MilladMuhammadi/Competitive-Programming | 9f84a2d2734a5efe0e1fde0062e51782cd5af2c6 | [
"MIT"
] | null | null | null | UICPC/13/UICPC Round #13 (Div 1)/UICPC Round #13 (Div 1)/submits/Aoi Albatross/Problem C - Car Vet/Accepted/submission_7511361_src/submission_7511361_src/main.cpp | MilladMuhammadi/Competitive-Programming | 9f84a2d2734a5efe0e1fde0062e51782cd5af2c6 | [
"MIT"
] | null | null | null | UICPC/13/UICPC Round #13 (Div 1)/UICPC Round #13 (Div 1)/submits/Aoi Albatross/Problem C - Car Vet/Accepted/submission_7511361_src/submission_7511361_src/main.cpp | MilladMuhammadi/Competitive-Programming | 9f84a2d2734a5efe0e1fde0062e51782cd5af2c6 | [
"MIT"
] | null | null | null | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mx = 260;
int arr[mx][mx];
bool moved[mx * mx];
int n, m;
int dx, dy;
ll ansSize = INT_MAX;
vector<int> ans;
bool ir(int a, int b) {
return (a >= 0 && a < n && b >= 0 && b < m);
}
void solve(int x, int y, vector<int> moves) {
if (x == dx && y == dy) {
if (moves.size() < ansSize) {
ansSize = moves.size();
ans = moves;
}
else if (moves.size() == ansSize) {
bool better = false;
for (int i = 0; i < moves.size(); ++i) {
if (moves[i] < ans[i]) {
better = true;
break;
}
}
if (better)
ans = moves;
}
}
if (ir(x - 1, y) && ir(x - 2, y) && arr[x - 1][y] == arr[x - 2][y] && arr[x - 1][y] != -2) {
if (!moved[arr[x - 2][y]]) {
moved[arr[x - 2][y]] = true;
arr[x][y] = arr[x - 2][y];
arr[x - 2][y] = -1;
moves.push_back(arr[x][y]);
solve(x - 2, y, moves);
arr[x - 2][y] = arr[x][y];
arr[x][y] = -1;
moves.pop_back();
moved[arr[x - 2][y]] = false;
}
}
if (ir(x + 1, y) && ir(x + 2, y) && arr[x + 1][y] == arr[x + 2][y] && arr[x + 1][y] != -2) {
if (!moved[arr[x + 2][y]]) {
moved[arr[x + 2][y]] = true;
arr[x][y] = arr[x + 2][y];
arr[x + 2][y] = -1;
moves.push_back(arr[x][y]);
solve(x + 2, y, moves);
arr[x + 2][y] = arr[x][y];
arr[x][y] = -1;
moves.pop_back();
moved[arr[x + 2][y]] = false;
}
}
if (ir(x, y - 1) && ir(x, y - 2) && arr[x][y - 1] == arr[x][y - 2] && arr[x][y - 1] != -2) {
if (!moved[arr[x][y - 2]]) {
moved[arr[x][y - 2]] = true;
arr[x][y] = arr[x][y - 2];
arr[x][y - 2] = -1;
moves.push_back(arr[x][y]);
solve(x, y - 2, moves);
arr[x][y - 2] = arr[x][y];
arr[x][y] = -1;
moves.pop_back();
moved[arr[x][y - 2]] = false;
}
}
if (ir(x, y + 1) && ir(x, y + 2) && arr[x][y + 1] == arr[x][y + 2] && arr[x][y + 1] != -2) {
if (!moved[arr[x][y + 2]]) {
moved[arr[x][y + 2]] = true;
arr[x][y] = arr[x][y + 2];
arr[x][y + 2] = -1;
moves.push_back(arr[x][y]);
solve(x, y + 2, moves);
arr[x][y + 2] = arr[x][y];
arr[x][y] = -1;
moves.pop_back();
moved[arr[x][y + 2]] = false;
}
}
}
int main() {
int tx, ty;
cin >> n >> m;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
cin >> arr[i][j];
if (arr[i][j] == -1) {
tx = i; ty = j;
}
}
}
cin >> dx >> dy;
dx--;dy--;
vector<int> vc;
solve(tx, ty, vc);
if (ansSize != INT_MAX) {
for (auto t : ans) {
cout << t << ' ';
}
cout << endl;
}
else {
cout << "impossible" << endl;
}
}
| 27.869565 | 96 | 0.346958 | MilladMuhammadi |
97f71d19eb120b707987701e910827a7e00c84a3 | 2,700 | hpp | C++ | simann.hpp | CISMM/SimulatedAnnealing | cd25cc58ced18a0df8e93fde32dc7a8107a1eca7 | [
"BSD-3-Clause"
] | 4 | 2018-02-07T05:13:05.000Z | 2019-04-02T06:02:12.000Z | simann.hpp | CISMM/SimulatedAnnealing | cd25cc58ced18a0df8e93fde32dc7a8107a1eca7 | [
"BSD-3-Clause"
] | null | null | null | simann.hpp | CISMM/SimulatedAnnealing | cd25cc58ced18a0df8e93fde32dc7a8107a1eca7 | [
"BSD-3-Clause"
] | 5 | 2015-07-16T23:44:29.000Z | 2019-02-05T20:33:43.000Z | // simanneal.hpp A general purpose Simulated Annealing Class
// This version allows vector data
// (c) Copyright 1994, Everett F. Carter Jr.
// Permission is granted by the author to use
// this software for any application provided this
// copyright notice is preserved.
// Updated to 2003 C++ standard by Shawn Waldon in 2014
// rcsid: @(#)simann.hpp 1.4 15:02:11 7/25/94 EFC
#ifndef SIM_ANNEAL_HPP_
#define SIM_ANNEAL_HPP_ 1.4
#include <random.hpp>
#ifndef PI
#define PI 3.141592653589793
#endif
// Added to allow a more object oriented cost function to be passed in without
// the need for global data accessible to the cost function
struct CostFunction
{
public:
double (*function)(double*, void*);
void* data;
// Constructors:
CostFunction() : function(NULL), data(NULL) {}
CostFunction(double (*f)(double*, void*), void* d = NULL) : function(f), data(d)
{
}
double operator()(double* f) { return function(f, data); }
};
//typedef double (*CostFunction)(double*);
class SimAnneal
{
private:
RUniform uniform;
CostFunction func;
int dimension, maxit, ddwell;
int err;
double* x, *xnew, *xbest;
double dt; // temperature increment to use when melting
double c_jump; // phase transition step size
double rrange;
double K, rho, t0, tscale, y, ybest;
int equilibrate(const double t, const int n);
public:
SimAnneal()
: func(NULL),
dimension(1),
maxit(400),
ddwell(20),
dt(0.1),
c_jump(100.0),
rrange(PI / 2.0),
K(1.0),
rho(0.5),
t0(0.0),
tscale(0.1)
{
}
SimAnneal(const CostFunction& f, const int d = 1);
~SimAnneal()
{
delete[] x;
delete[] xnew;
delete[] xbest;
}
int set_up(CostFunction f, const int d = 1);
const int operator!() const { return err; }
double melt(const int iters = -1);
double anneal(const int iters = -1);
int iterations(const int m = -1)
{
if (m > 0) maxit = m;
return maxit;
}
int dwell(const int d = -1)
{
if (d > 0) ddwell = d;
return ddwell;
}
double Boltzmann(const double k = -1.0)
{
if (k > 0.0) K = k;
return K;
}
double learning_rate(const double r = -1.0)
{
if (r > 0.0) rho = r;
return rho;
}
double temperature(const double t = -1.0)
{
if (t >= 0.0) t0 = t;
return t0;
}
double jump(const double j = -1.0)
{
if (j > 0.0) c_jump = j;
return c_jump;
}
double range(const double r = -1.0)
{
if (r > 0.0) rrange = r;
return rrange;
}
void initial(const double* xinit);
void current(double* xcur);
void optimum(double* xopt);
};
#endif
| 21.259843 | 82 | 0.604444 | CISMM |
97f9a23515425a3252d9984af18ed1d855ddd06a | 1,176 | cpp | C++ | docs/examples/draw_patch.cpp | mohad12211/skia | 042a53aa094715e031ebad4da072524ace316744 | [
"BSD-3-Clause"
] | 6,304 | 2015-01-05T23:45:12.000Z | 2022-03-31T09:48:13.000Z | docs/examples/draw_patch.cpp | mohad12211/skia | 042a53aa094715e031ebad4da072524ace316744 | [
"BSD-3-Clause"
] | 67 | 2016-04-18T13:30:02.000Z | 2022-03-31T23:06:55.000Z | docs/examples/draw_patch.cpp | mohad12211/skia | 042a53aa094715e031ebad4da072524ace316744 | [
"BSD-3-Clause"
] | 1,231 | 2015-01-05T03:17:39.000Z | 2022-03-31T22:54:58.000Z | // Copyright 2020 Google LLC.
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#include "tools/fiddle/examples.h"
REG_FIDDLE(draw_patch, 350, 350, false, 6) {
// draw_patch
void draw(SkCanvas* canvas) {
canvas->clear(SK_ColorWHITE);
SkPaint p;
p.setAntiAlias(true);
const SkColor colors[] = {SK_ColorRED, SK_ColorCYAN, SK_ColorGREEN, SK_ColorWHITE,
SK_ColorMAGENTA, SK_ColorBLUE, SK_ColorYELLOW};
const SkPoint pts[] = {{100.f / 4.f, 0.f}, {3.f * 100.f / 4.f, 100.f}};
p.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors),
SkTileMode::kMirror));
const SkPoint cubics[] = {{100, 100}, {150, 50}, {250, 150}, {300, 100},
{250, 150}, {350, 250}, {300, 300}, {250, 250},
{150, 350}, {100, 300}, {50, 250}, {150, 150}};
const SkPoint texCoords[] = {
{0.0f, 0.0f}, {100.0f, 0.0f}, {100.0f, 100.0f}, {0.0f, 100.0f}};
canvas->drawPatch(cubics, nullptr, texCoords, SkBlendMode::kSrcOver, p);
}
} // END FIDDLE
| 51.130435 | 100 | 0.576531 | mohad12211 |
97fcbfd529b53be65bb88383dd8f4218fde858cf | 473 | cpp | C++ | codeforces/869/a.cpp | AadityaJ/Spoj | 61664c1925ef5bb072a3fe78fb3dac4fb68d77a1 | [
"MIT"
] | null | null | null | codeforces/869/a.cpp | AadityaJ/Spoj | 61664c1925ef5bb072a3fe78fb3dac4fb68d77a1 | [
"MIT"
] | null | null | null | codeforces/869/a.cpp | AadityaJ/Spoj | 61664c1925ef5bb072a3fe78fb3dac4fb68d77a1 | [
"MIT"
] | null | null | null | #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define MX 4000007
bool vis[MX];
using namespace std;
int main(int argc, char const *argv[]) {
int n;
cin>>n;
int a1[n];
int a2[n];
for(int i=0;i<n;i++) {cin>>a1[i];vis[a1[i]]=1;}
for(int i=0;i<n;i++) {cin>>a2[i];vis[a2[i]]=1;}
int ans=0;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(vis[a1[i]^a2[j]]) ans++;
}
}
if(ans%2) cout<<"Koyomi\n";
else cout<<"Karen\n";
return 0;
}
| 18.92 | 48 | 0.579281 | AadityaJ |
97fce3b5f39138d051fc5034bc0516e036de731b | 1,493 | hpp | C++ | C-ATTL3/core/gpu/cudnn/CuDNNError.hpp | ViktorC/CppNN | daf7207fdc047412957761ef412fa805b2656d65 | [
"MIT"
] | 16 | 2018-07-03T09:39:10.000Z | 2021-11-16T07:53:09.000Z | C-ATTL3/core/gpu/cudnn/CuDNNError.hpp | Merlin1A/C-ATTL3 | daf7207fdc047412957761ef412fa805b2656d65 | [
"MIT"
] | null | null | null | C-ATTL3/core/gpu/cudnn/CuDNNError.hpp | Merlin1A/C-ATTL3 | daf7207fdc047412957761ef412fa805b2656d65 | [
"MIT"
] | 5 | 2019-11-01T09:38:29.000Z | 2021-11-09T00:41:05.000Z | /*
* CuDNNError.hpp
*
* Created on: 14.06.2018
* Author: Viktor Csomor
*/
#ifndef C_ATTL3_CORE_GPU_CUDNN_CUDNNERROR_H_
#define C_ATTL3_CORE_GPU_CUDNN_CUDNNERROR_H_
#include <cudnn.h>
#include <cstdlib>
#include <exception>
#include <iostream>
#include <string>
#define cudnnErrorCheck(status) { _cudnn_error_check(status, __FILE__, __LINE__); }
#define cudnnAssert(status) { _cudnn_assert(status, __FILE__, __LINE__); }
namespace cattle {
namespace gpu {
/**
* A class representing a cuDNN runtime error.
*/
class CuDNNError : public std::runtime_error {
public:
/**
* @param status The cuDNN status code.
* @param file The name of the file in which the error occurred.
* @param line The number of the line at which the error occurred.
*/
CuDNNError(cudnnStatus_t status, const char* file, int line) :
std::runtime_error("cuDNN Error: " + std::string(cudnnGetErrorString(status)) + "; File: " +
std::string(file) + "; Line: " + std::to_string(line)) { }
};
namespace {
__inline__ void _cudnn_error_check(cudnnStatus_t status, const char* file, int line) {
if (status != CUDNN_STATUS_SUCCESS)
throw CuDNNError(status, file, line);
}
__inline__ void _cudnn_assert(cudnnStatus_t status, const char* file, int line) {
try {
_cudnn_error_check(status, file, line);
} catch (const CuDNNError& e) {
std::cout << e.what() << std::endl;
exit(-1);
}
}
}
} /* namespace gpu */
} /* namespace cattle */
#endif /* C_ATTL3_CORE_GPU_CUDNN_CUDNNERROR_H_ */
| 24.883333 | 94 | 0.70864 | ViktorC |
97fd58fb15fb351383d1aef7d733cf6e639eaee9 | 896 | cpp | C++ | Cpp/fost-core/exception-tests.cpp | KayEss/fost-base | 05ac1b6a1fb672c61ba6502efea86f9c5207e28f | [
"BSL-1.0"
] | 2 | 2016-05-25T22:17:38.000Z | 2019-04-02T08:34:17.000Z | Cpp/fost-core/exception-tests.cpp | KayEss/fost-base | 05ac1b6a1fb672c61ba6502efea86f9c5207e28f | [
"BSL-1.0"
] | 5 | 2018-07-13T10:43:05.000Z | 2019-09-02T14:54:42.000Z | Cpp/fost-core/exception-tests.cpp | KayEss/fost-base | 05ac1b6a1fb672c61ba6502efea86f9c5207e28f | [
"BSL-1.0"
] | 1 | 2020-10-22T20:44:24.000Z | 2020-10-22T20:44:24.000Z | /**
Copyright 2010-2019 Red Anchor Trading Co. Ltd.
Distributed under the Boost Software License, Version 1.0.
See <http://www.boost.org/LICENSE_1_0.txt>
*/
#include "fost-core-test.hpp"
#include <boost/asio.hpp>
FSL_TEST_SUITE(exceptions);
FSL_TEST_FUNCTION(not_implemented) {
FSL_CHECK_EXCEPTION(
throw fostlib::exceptions::not_implemented(
"Not implemented exception thrown"),
fostlib::exceptions::not_implemented &);
FSL_CHECK_EXCEPTION(
throw fostlib::exceptions::not_implemented(
"test_func", boost::asio::error::eof),
fostlib::exceptions::not_implemented &);
FSL_CHECK_EXCEPTION(
throw fostlib::exceptions::not_implemented(
"test_func", boost::asio::error::eof, "Check EOF throw"),
fostlib::exceptions::not_implemented &);
}
| 29.866667 | 77 | 0.639509 | KayEss |
97fd8d8f1210c0ec53f6932eaf5c516c524d002c | 903 | hpp | C++ | kernel/x86/paging.hpp | Bunogi/bunos | 52e55d16938c87d45aa148c18d3bf389f2067445 | [
"BSD-3-Clause"
] | null | null | null | kernel/x86/paging.hpp | Bunogi/bunos | 52e55d16938c87d45aa148c18d3bf389f2067445 | [
"BSD-3-Clause"
] | null | null | null | kernel/x86/paging.hpp | Bunogi/bunos | 52e55d16938c87d45aa148c18d3bf389f2067445 | [
"BSD-3-Clause"
] | null | null | null | #pragma once
#include <bustd/stddef.hpp>
#pragma once
#pragma once
#include <kernel/memory.hpp>
namespace kernel::x86 {
class PageTableEntry {
public:
bool present : 1;
bool read_write : 1;
bool user : 1;
bool write_through : 1;
bool cache_disable : 1;
bool accessed : 1;
bool dirty : 1;
bool zero : 1; // must be zero in a valid entry
bool global : 1;
u8 available : 3;
PhysicalAddress page_address;
u32 as_u32() const;
static PageTableEntry from_u32(u32 from);
};
class PageDirectoryEntry {
public:
bool present : 1;
bool read_write : 1;
bool user : 1;
bool write_through : 1;
bool cache_disable : 1;
bool accessed : 1;
bool zero : 1; // must be zero in a valid entry
bool is_large : 1;
bool global : 1;
u8 available : 3;
u32 page_table_address;
u32 as_u32() const;
static PageDirectoryEntry from_u32(u32 from);
};
} // namespace kernel::x86
| 19.212766 | 49 | 0.682171 | Bunogi |
3f019b33403af683c7a70cfc690aaa208092aa10 | 1,584 | hpp | C++ | PnC/NaoPnC/NaoInterface.hpp | BharathMasetty/PnC | 3800bd7e3c5dd5ffa00e6a5f09d48d21c405206f | [
"MIT"
] | null | null | null | PnC/NaoPnC/NaoInterface.hpp | BharathMasetty/PnC | 3800bd7e3c5dd5ffa00e6a5f09d48d21c405206f | [
"MIT"
] | null | null | null | PnC/NaoPnC/NaoInterface.hpp | BharathMasetty/PnC | 3800bd7e3c5dd5ffa00e6a5f09d48d21c405206f | [
"MIT"
] | null | null | null | #pragma once
#include "PnC/EnvInterface.hpp"
#include "PnC/NaoPnC/NaoDefinition.hpp"
class NaoStateProvider;
class NaoStateEstimator;
class NaoSensorData {
public:
NaoSensorData() {
q = Eigen::VectorXd::Zero(Nao::n_adof);
qdot = Eigen::VectorXd::Zero(Nao::n_adof);
virtual_q = Eigen::VectorXd::Zero(Nao::n_vdof);
virtual_qdot = Eigen::VectorXd::Zero(Nao::n_vdof);
// Ignore
lf_wrench = Eigen::VectorXd::Zero(6);
rf_wrench = Eigen::VectorXd::Zero(6);
rfoot_contact = false;
lfoot_contact = false;
}
virtual ~NaoSensorData() {}
Eigen::VectorXd q;
Eigen::VectorXd qdot;
Eigen::VectorXd virtual_q;
Eigen::VectorXd virtual_qdot;
Eigen::VectorXd lf_wrench;
Eigen::VectorXd rf_wrench;
bool rfoot_contact;
bool lfoot_contact;
};
class NaoCommand {
public:
NaoCommand() {
q = Eigen::VectorXd::Zero(Nao::n_adof);
qdot = Eigen::VectorXd::Zero(Nao::n_adof);
jtrq = Eigen::VectorXd::Zero(Nao::n_adof);
}
virtual ~NaoCommand() {}
Eigen::VectorXd q;
Eigen::VectorXd qdot;
Eigen::VectorXd jtrq;
};
class NaoInterface : public EnvInterface {
protected:
void _ParameterSetting();
NaoStateEstimator* state_estimator_;
NaoStateProvider* sp_;
void CropTorque_(NaoCommand*);
bool Initialization_(NaoSensorData*, NaoCommand*);
int count_;
int waiting_count_;
Eigen::VectorXd cmd_jpos_;
Eigen::VectorXd cmd_jvel_;
Eigen::VectorXd cmd_jtrq_;
public:
NaoInterface();
virtual ~NaoInterface();
// Main method
virtual void getCommand(void* _sensor_data, void* _command_data);
};
| 21.12 | 67 | 0.700126 | BharathMasetty |
3f02733f3611ed3dd1fb6964ceba2b89ca2cb1bf | 2,712 | cpp | C++ | RoboRePair/ProgressTracker.cpp | erwinbonsma/RoboRePairGB | 202308220d7bc320a8c228f7a7372545c3e97559 | [
"MIT"
] | null | null | null | RoboRePair/ProgressTracker.cpp | erwinbonsma/RoboRePairGB | 202308220d7bc320a8c228f7a7372545c3e97559 | [
"MIT"
] | null | null | null | RoboRePair/ProgressTracker.cpp | erwinbonsma/RoboRePairGB | 202308220d7bc320a8c228f7a7372545c3e97559 | [
"MIT"
] | null | null | null | /*
* Bumble Bots Re-Pair, a Gamebuino game
*
* Copyright 2020, Erwin Bonsma
*/
#include "ProgressTracker.h"
#include "Levels.h"
//-----------------------------------------------------------------------------
// ProgressTracker implementation
constexpr uint8_t VMAJOR = 1;
constexpr uint8_t VMINOR = 0;
constexpr uint8_t SAVEINDEX_VMAJOR = 0;
constexpr uint8_t SAVEINDEX_VMINOR = 1;
constexpr uint8_t SAVEINDEX_HISCORE = 2;
constexpr uint8_t SAVEINDEX_LEVELHI_L0 = 3;
constexpr uint8_t SAVEINDEX_LAST = SAVEINDEX_LEVELHI_L0 + numLevels - 1;
void ProgressTracker::clearStoredHiScore() {
gb.save.set(SAVEINDEX_HISCORE, (int32_t)0);
}
void ProgressTracker::clearStoredLevelScores() {
for (uint8_t level = 0; level < numLevels; level++) {
gb.save.set(SAVEINDEX_LEVELHI_L0 + level, (int32_t)0);
}
}
void ProgressTracker::init() {
if (
gb.save.get(SAVEINDEX_VMAJOR) != VMAJOR ||
gb.save.get(SAVEINDEX_VMINOR) != VMINOR
) {
// Reset all data. Although format itself has not changed, levels have been
// tweaked so that previous scores are not valid anymore.
clearStoredLevelScores();
clearStoredHiScore();
}
dump();
gb.save.set(SAVEINDEX_VMAJOR, (int32_t)VMAJOR);
gb.save.set(SAVEINDEX_VMINOR, (int32_t)VMINOR);
}
void ProgressTracker::dump() {
#ifdef DEVELOPMENT
SerialUSB.printf("Save file format v%d.%d\n", gb.save.get(SAVEINDEX_VMAJOR), gb.save.get(SAVEINDEX_VMINOR));
SerialUSB.printf("High score = %d\n", gb.save.get(SAVEINDEX_HISCORE));
for (uint8_t i = 0; i < numLevels; i++) {
SerialUSB.printf("Max score level %d = %d\n", (i + 1), gb.save.get(SAVEINDEX_LEVELHI_L0 + i));
}
#endif
}
Score ProgressTracker::levelHiScore(int level) {
return gb.save.get(SAVEINDEX_LEVELHI_L0 + level);
}
Score ProgressTracker::hiScore() {
return gb.save.get(SAVEINDEX_HISCORE);
}
void ProgressTracker::startGame() {
_score = 0;
_improvedHiScore = false;
}
void ProgressTracker::updateHiScore() {
Score oldHiScore = hiScore();
if (_score > oldHiScore) {
gb.save.set(SAVEINDEX_HISCORE, (int32_t)_score);
_improvedHiScore = true;
}
}
void ProgressTracker::startLevel(Score score) {
_score = score;
}
bool ProgressTracker::levelDone(int level, Score score) {
Score oldLevelHi = levelHiScore(level);
Score levelScore = score - _score;
bool improvedLevelHi = false;
if (levelScore > oldLevelHi) {
// New level hi-score!
gb.save.set(SAVEINDEX_LEVELHI_L0 + level, levelScore);
improvedLevelHi = true;
}
updateHiScore();
return improvedLevelHi;
}
bool ProgressTracker::gameDone(Score finalScore) {
_score = finalScore;
updateHiScore();
return improvedHiScore();
}
ProgressTracker progressTracker;
| 24.432432 | 110 | 0.696165 | erwinbonsma |
3f0607721528a5aee61a3387de5b23ec8f3939de | 1,343 | cpp | C++ | Codeforces Online Judge Solve/Candies-1343A.cpp | Remonhasan/programming-solve | 5a4ac8c738dd361e1c974162e0eaebbaae72fd80 | [
"Apache-2.0"
] | null | null | null | Codeforces Online Judge Solve/Candies-1343A.cpp | Remonhasan/programming-solve | 5a4ac8c738dd361e1c974162e0eaebbaae72fd80 | [
"Apache-2.0"
] | null | null | null | Codeforces Online Judge Solve/Candies-1343A.cpp | Remonhasan/programming-solve | 5a4ac8c738dd361e1c974162e0eaebbaae72fd80 | [
"Apache-2.0"
] | null | null | null | #include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define pqb priority_queue<int>
#define pqs priority_queue<int,vi,greater<int> >
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type) type *arr=new type[n];
#define w(x) int x; cin>>x; while(x--)
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int32_t main()
{
FIO;
w(t)
{
int n; cin >> n;
int x;
for (int k = 2; k <= 35; ++k)
{
int shakin = pow(2, k) - 1;
if (n % shakin)
continue;
x = n / shakin;
break;
}
cout << x << '\n';
}
return 0;
}
| 25.339623 | 94 | 0.55175 | Remonhasan |
3f073cd0a1f4afd7e3437dbfacaf8772a15623cb | 188 | cpp | C++ | Hackerearth/Practice/birthday_party.cpp | Pankajcoder1/Competitive_programming | 72ee0d41f3f72f43a5c2a232255eb84a04b14df9 | [
"MIT"
] | null | null | null | Hackerearth/Practice/birthday_party.cpp | Pankajcoder1/Competitive_programming | 72ee0d41f3f72f43a5c2a232255eb84a04b14df9 | [
"MIT"
] | null | null | null | Hackerearth/Practice/birthday_party.cpp | Pankajcoder1/Competitive_programming | 72ee0d41f3f72f43a5c2a232255eb84a04b14df9 | [
"MIT"
] | 1 | 2020-10-02T04:51:22.000Z | 2020-10-02T04:51:22.000Z | #include<iostream>
using namespace std;
int main()
{
int T,M,N;
cin>>T;
for(int i=0;i<T;i++)
{
cin>>N>>M;
if(M%N==0)
{
cout<<"Yes"<<endl;
}
else
cout<<"No"<<endl;
}
} | 10.444444 | 21 | 0.505319 | Pankajcoder1 |
3f07af23cde2df8c41582d236fb35a559c92d0e1 | 2,447 | cpp | C++ | 0827-Making A Large Island/0827-Making A Large Island.cpp | zhuangli1987/LeetCode-1 | e81788abf9e95e575140f32a58fe983abc97fa4a | [
"MIT"
] | 49 | 2018-05-05T02:53:10.000Z | 2022-03-30T12:08:09.000Z | 0801-0900/0827-Making A Large Island/0827-Making A Large Island.cpp | jolly-fellow/LeetCode | ab20b3ec137ed05fad1edda1c30db04ab355486f | [
"MIT"
] | 11 | 2017-12-15T22:31:44.000Z | 2020-10-02T12:42:49.000Z | 0801-0900/0827-Making A Large Island/0827-Making A Large Island.cpp | jolly-fellow/LeetCode | ab20b3ec137ed05fad1edda1c30db04ab355486f | [
"MIT"
] | 28 | 2017-12-05T10:56:51.000Z | 2022-01-26T18:18:27.000Z | class Solution {
public:
int largestIsland(vector<vector<int>>& grid) {
int m = grid.size(), n = grid[0].size();
vector<int> parents(m * n), areas(m * n);
for (int i = 0; i < m * n; ++i) {
parents[i] = i;
}
int maxArea = 0;
for (int i = 0; i < m; ++i) {
for (int j = 0; j < n; ++j) {
if (grid[i][j] == 1) {
int p1 = i * n + j;
areas[p1] = 1;
if (i > 0 && grid[i - 1][j] == 1) {
p1 = findParent(parents, (i - 1) * n + j);
parents[i * n + j] = p1;
++areas[p1];
}
if (j > 0 && grid[i][j - 1] == 1) {
p1 = findParent(parents, i * n + j - 1);
int p2 = findParent(parents, i * n + j);
if (p1 != p2) {
parents[p2] = p1;
areas[p1] += areas[p2];
}
}
maxArea = max(maxArea, areas[p1]);
}
}
}
int dr[4] = {-1, 1, 0, 0};
int dc[4] = {0, 0, -1, 1};
for (int i = 0; i < m; ++i) {
for (int j = 0; j < n; ++j) {
if (grid[i][j] == 0) {
areas[i * n + j] = 1;
unordered_set<int> visited;
for (int k = 0; k < 4; ++k) {
int r = i + dr[k];
int c = j + dc[k];
if (r >= 0 && r < m && c >= 0 && c < n && grid[r][c] == 1) {
int p = findParent(parents, r * n + c);
if (!visited.count(p)) {
visited.insert(p);
areas[i * n + j] += areas[p];
}
}
}
maxArea = max(maxArea, areas[i * n + j]);
}
}
}
return maxArea;
}
private:
int findParent(vector<int>& parents, int i) {
while (parents[i] != i) {
parents[i] = parents[parents[i]];
i = parents[i];
}
return i;
}
};
| 35.985294 | 112 | 0.275439 | zhuangli1987 |
3f095c05754dc312170d78527f8bcc5838148604 | 43,169 | cpp | C++ | Core/SoarKernel/src/explanation_based_chunking/build.cpp | Bryan-Stearns/Soar | 969f4fec676293b459ed552ad096549519800534 | [
"BSD-2-Clause"
] | 1 | 2021-03-03T23:20:23.000Z | 2021-03-03T23:20:23.000Z | Core/SoarKernel/src/explanation_based_chunking/build.cpp | Bryan-Stearns/Soar | 969f4fec676293b459ed552ad096549519800534 | [
"BSD-2-Clause"
] | null | null | null | Core/SoarKernel/src/explanation_based_chunking/build.cpp | Bryan-Stearns/Soar | 969f4fec676293b459ed552ad096549519800534 | [
"BSD-2-Clause"
] | 1 | 2021-03-03T23:20:25.000Z | 2021-03-03T23:20:25.000Z | /*************************************************************************
* PLEASE SEE THE FILE "license.txt" (INCLUDED WITH THIS SOFTWARE PACKAGE)
* FOR LICENSE AND COPYRIGHT INFORMATION.
*************************************************************************/
/*************************************************************************
*
* file: ebc_build.cpp
*
* =======================================================================
* These are the routines that support printing Soar data structures.
*
* =======================================================================
*/
#include "ebc.h"
#include "agent.h"
#include "condition.h"
#include "debug.h"
#include "decide.h"
#include "explain.h"
#include "instantiation.h"
#include "preference.h"
#include "print.h"
#include "production.h"
#include "rete.h"
#include "rhs.h"
#include "soar_TraceNames.h"
#include "slot.h"
#include "symbol.h"
#include "test.h"
#include "working_memory.h"
#include "working_memory_activation.h"
#include "xml.h"
#include <stdlib.h>
#include <cstring>
#include <ctype.h>
#include <run_soar.h>
using namespace soar_TraceNames;
/* =====================================================================
Results Calculation
Get_results_for_instantiation() finds and returns the result preferences
for a given instantiation. This is the main routine here.
The results are accumulated in the list "results," linked via the
"next_result" field of the preference structures. (NOTE: to save
space, just use conses for this.)
Add_pref_to_results() adds a preference to the results.
Add_results_for_id() adds any preferences for the given identifier.
Identifiers are marked with results_tc_number as they are added.
===================================================================== */
void Explanation_Based_Chunker::add_results_if_needed(Symbol* sym)
{
if ((sym)->symbol_type == IDENTIFIER_SYMBOL_TYPE)
if (((sym)->id->level >= m_results_match_goal_level) &&
((sym)->tc_num != m_results_tc))
{
add_results_for_id(sym);
}
}
void Explanation_Based_Chunker::add_pref_to_results(preference* pref)
{
preference* p;
/* --- if an equivalent pref is already a result, don't add this one --- */
for (p = m_results; p != NIL; p = p->next_result)
{
if (p->id != pref->id)
{
continue;
}
if (p->attr != pref->attr)
{
continue;
}
if (p->value != pref->value)
{
continue;
}
if (p->type != pref->type)
{
continue;
}
if (preference_is_unary(pref->type))
{
return;
}
if (p->referent != pref->referent)
{
continue;
}
return;
}
/* --- if pref isn't at the right level, find a clone that is --- */
if (pref->inst->match_goal_level != m_results_match_goal_level)
{
for (p = pref->next_clone; p != NIL; p = p->next_clone)
if (p->inst->match_goal_level == m_results_match_goal_level)
{
break;
}
if (!p)
for (p = pref->prev_clone; p != NIL; p = p->prev_clone)
if (p->inst->match_goal_level == m_results_match_goal_level)
{
break;
}
if (!p)
{
return; /* if can't find one, it isn't a result */
}
pref = p;
}
/* --- add this preference to the result list --- */
pref->next_result = m_results;
m_results = pref;
/* --- follow transitive closure through value, referent links --- */
add_results_if_needed(pref->value);
if (preference_is_binary(pref->type))
{
add_results_if_needed(pref->referent);
}
}
void Explanation_Based_Chunker::add_results_for_id(Symbol* id)
{
slot* s;
preference* pref;
wme* w;
id->tc_num = m_results_tc;
/* --- scan through all preferences and wmes for all slots for this id --- */
for (w = id->id->input_wmes; w != NIL; w = w->next)
{
add_results_if_needed(w->value);
}
for (s = id->id->slots; s != NIL; s = s->next)
{
for (pref = s->all_preferences; pref != NIL; pref = pref->all_of_slot_next)
{
add_pref_to_results(pref);
}
for (w = s->wmes; w != NIL; w = w->next)
{
add_results_if_needed(w->value);
}
} /* end of for slots loop */
/* --- now scan through extra prefs and look for any with this id --- */
for (pref = m_extra_results; pref != NIL;
pref = pref->inst_next)
{
if (pref->id == id)
{
add_pref_to_results(pref);
}
}
}
void Explanation_Based_Chunker::get_results_for_instantiation()
{
preference* pref;
m_results = NIL;
m_results_match_goal_level = m_inst->match_goal_level;
m_results_tc = get_new_tc_number(thisAgent);
m_extra_results = m_inst->preferences_generated;
for (pref = m_inst->preferences_generated; pref != NIL; pref = pref->inst_next)
if ((pref->id->id->level < m_results_match_goal_level) &&
(pref->id->tc_num != m_results_tc))
{
add_pref_to_results(pref);
dprint(DT_VARIABLIZATION_MANAGER, "Pref %p added to results.\n", pref);
} else {
dprint(DT_VARIABLIZATION_MANAGER, "Did not add pref %p to results. %d >= %d\n", pref, pref->id->id->level, m_results_match_goal_level);
}
}
action* Explanation_Based_Chunker::copy_action_list(action* actions)
{
action* old, *New, *prev, *first;
char first_letter;
prev = NIL;
first = NIL; /* unneeded, but without it gcc -Wall warns here */
old = actions;
while (old)
{
New = make_action(thisAgent);
if (prev)
{
prev->next = New;
}
else
{
first = New;
}
prev = New;
New->type = old->type;
New->preference_type = old->preference_type;
New->support = old->support;
if (old->type == FUNCALL_ACTION)
{
New->value = copy_rhs_value(thisAgent, old->value);
}
else
{
New->id = copy_rhs_value(thisAgent, old->id);
New->attr = copy_rhs_value(thisAgent, old->attr);
first_letter = first_letter_from_rhs_value(New->attr);
New->value = copy_rhs_value(thisAgent, old->value);
if (preference_is_binary(old->preference_type))
{
New->referent = copy_rhs_value(thisAgent, old->referent);
}
}
old = old->next;
}
if (prev)
{
prev->next = NIL;
}
else
{
first = NIL;
}
return first;
}
/* ====================================================================
Chunk Conditions, and Chunk Conditions Set Manipulation Routines
These structures have two uses. First, for every ground condition,
one of these structures maintains certain information about it--
pointers to the original (instantiation's) condition, the chunks's
instantiation's condition, and the variablized condition, etc.
Second, for negated conditions, these structures are entered into
a hash table with keys hash_condition(thisAgent, this_cond). This hash
table is used so we can add a new negated condition to the set of
negated potentials quickly--we don't want to add a duplicate of a
negated condition that's already there, and the hash table lets us
quickly determine whether a duplicate is already there.
I used one type of structure for both of these uses, (1) for simplicity
and (2) to avoid having to do a second allocation when we move
negated conditions over to the ground set.
==================================================================== */
/* --------------------------------------------------------------------
Chunk Cond Set Routines
Init_chunk_cond_set() initializes a given chunk_cond_set to be empty.
Make_chunk_cond_for_condition() takes a condition and returns a
chunk_cond for it, for use in a chunk_cond_set. This is used only
for the negated conditions, not grounds.
Add_to_chunk_cond_set() adds a given chunk_cond to a given chunk_cond_set
and returns true if the condition isn't already in the set. If the
condition is already in the set, the routine deallocates the given
chunk_cond and returns false.
Remove_from_chunk_cond_set() removes a given chunk_cond from a given
chunk_cond_set, but doesn't deallocate it.
-------------------------------------------------------------------- */
/* set of all negated conditions we encounter
during backtracing--these are all potentials
and (some of them) are added to the grounds
in one pass at the end of the backtracing */
void Explanation_Based_Chunker::init_chunk_cond_set(chunk_cond_set* set)
{
int i;
set->all = NIL;
for (i = 0; i < CHUNK_COND_HASH_TABLE_SIZE; i++)
{
set->table[i] = NIL;
}
}
/* -- Note: add_to_chunk_cond_set and make_chunk_cond_for_negated_condition are both
* only used for negative conditions and NCCS. Used in a single line in
* backtrace_through_instantiation() -- */
chunk_cond* Explanation_Based_Chunker::make_chunk_cond_for_negated_condition(condition* cond)
{
chunk_cond* cc;
uint32_t remainder, hv;
thisAgent->memoryManager->allocate_with_pool(MP_chunk_cond, &cc);
cc->cond = cond;
cc->hash_value = hash_condition(thisAgent, cond);
remainder = cc->hash_value;
hv = 0;
while (remainder)
{
hv ^= (remainder &
masks_for_n_low_order_bits[LOG_2_CHUNK_COND_HASH_TABLE_SIZE]);
remainder = remainder >> LOG_2_CHUNK_COND_HASH_TABLE_SIZE;
}
cc->compressed_hash_value = hv;
return cc;
}
bool Explanation_Based_Chunker::add_to_chunk_cond_set(chunk_cond_set* set, chunk_cond* new_cc)
{
chunk_cond* old;
for (old = set->table[new_cc->compressed_hash_value]; old != NIL;
old = old->next_in_bucket)
if (old->hash_value == new_cc->hash_value)
if (conditions_are_equal(old->cond, new_cc->cond))
{
break;
}
if (old)
{
/* --- the new condition was already in the set; so don't add it --- */
thisAgent->memoryManager->free_with_pool(MP_chunk_cond, new_cc);
return false;
}
/* --- add new_cc to the table --- */
insert_at_head_of_dll(set->all, new_cc, next, prev);
insert_at_head_of_dll(set->table[new_cc->compressed_hash_value], new_cc,
next_in_bucket, prev_in_bucket);
return true;
}
void Explanation_Based_Chunker::remove_from_chunk_cond_set(chunk_cond_set* set, chunk_cond* cc)
{
remove_from_dll(set->all, cc, next, prev);
remove_from_dll(set->table[cc->compressed_hash_value],
cc, next_in_bucket, prev_in_bucket);
}
/* ====================================================================
Other Miscellaneous Chunking Routines
==================================================================== */
/* --------------------------------------------------------------------
Build Chunk Conds For Grounds And Add Negateds
This routine is called once backtracing is finished. It goes through
the ground conditions and builds a chunk_cond (see above) for each
one. The chunk_cond includes two new copies of the condition: one
to be used for the initial instantiation of the chunk, and one to
be (variablized and) used for the chunk itself.
This routine also goes through the negated conditions and adds to
the ground set (again building chunk_cond's) any negated conditions
that are connected to the grounds.
At exit, the "dest_top" and "dest_bottom" arguments are set to point
to the first and last chunk_cond in the ground set. The "tc_to_use"
argument is the tc number that this routine will use to mark the
TC of the ground set. At exit, this TC indicates the set of identifiers
in the grounds. (This is used immediately afterwards to figure out
which Nots must be added to the chunk.)
-------------------------------------------------------------------- */
inline void add_cond(condition** c, condition** prev, condition** first)
{
if (*prev)
{
(*c)->prev = *prev;
(*prev)->next = *c;
}
else
{
*first = *c;
*prev = NIL;
(*c)->prev = NIL;
}
*prev = *c;
}
void Explanation_Based_Chunker::create_instantiated_counterparts()
{
condition* copy_cond = m_vrblz_top;
condition* c_inst = NULL, *first_inst = NULL, *prev_inst = NULL;
condition* ncc_cond, *ncc_icond;
while (copy_cond)
{
c_inst = copy_condition(thisAgent, copy_cond);
c_inst->inst = copy_cond->inst;
assert(c_inst->inst);
/*-- Store a link from the variablized condition to the instantiated
* condition. Used during merging if the chunker needs
* to delete a redundant condition. Also used to reorder
* instantiated condition to match the re-ordered variablized
* conditions list (required by the rete.) -- */
c_inst->counterpart = copy_cond;
copy_cond->counterpart = c_inst;
if (copy_cond->type == CONJUNCTIVE_NEGATION_CONDITION)
{
ncc_cond = copy_cond->data.ncc.top;
ncc_icond = c_inst->data.ncc.top;
while (ncc_cond)
{
ncc_cond->counterpart = ncc_icond;
ncc_icond->counterpart = ncc_cond;
ncc_cond = ncc_cond->next;
ncc_icond = ncc_icond->next;
}
}
add_cond(&c_inst, &prev_inst, &first_inst);
copy_cond = copy_cond->next;
}
if (prev_inst)
{
prev_inst->next = NIL;
}
else
{
first_inst->next = NIL;
}
m_inst_top = first_inst;
m_inst_bottom = c_inst;
}
void Explanation_Based_Chunker::create_initial_chunk_condition_lists()
{
cons* c;
condition* ground, *c_vrblz, *first_vrblz = nullptr, *prev_vrblz;
bool should_unify_and_simplify = learning_is_on_for_instantiation();
tc_number tc_to_use = get_new_tc_number(thisAgent);
c_vrblz = NIL; /* unnecessary, but gcc -Wall warns without it */
dprint(DT_BUILD_CHUNK_CONDS, "Building conditions for new chunk...\n");
dprint(DT_BUILD_CHUNK_CONDS, "Grounds from backtrace: \n");
dprint_noprefix(DT_BUILD_CHUNK_CONDS, "%3", grounds);
dprint(DT_BUILD_CHUNK_CONDS, "...creating positive conditions from final ground set.\n");
/* --- build instantiated conds for grounds and setup their TC --- */
reset_constraint_found_tc_num();
prev_vrblz = NIL;
while (grounds)
{
c = grounds;
grounds = grounds->rest;
ground = static_cast<condition_struct*>(c->first);
free_cons(thisAgent, c);
/* --- make the instantiated condition --- */
dprint(DT_BACKTRACE, " processing ground condition: %l\n", ground);
/* -- Originally cc->cond would be set to ground and cc->inst was a copy-- */
c_vrblz = copy_condition(thisAgent, ground, true, should_unify_and_simplify);
c_vrblz->inst = ground->inst;
add_cond(&c_vrblz, &prev_vrblz, &first_vrblz);
/* --- add this condition to the TC. Needed to see if NCC are grounded. --- */
add_cond_to_tc(thisAgent, ground, tc_to_use, NIL, NIL);
}
dprint(DT_BACKTRACE, "...adding negated conditions from backtraced negated set.\n");
/* --- scan through negated conditions and check which ones are connected
to the grounds --- */
if (thisAgent->sysparams[TRACE_BACKTRACING_SYSPARAM])
{
print_string(thisAgent, "\n\n*** Adding Grounded Negated Conditions ***\n");
}
chunk_cond *cc;
bool has_local_negation = false;
while (negated_set.all)
{
cc = negated_set.all;
remove_from_chunk_cond_set(&negated_set, cc);
if (cond_is_in_tc(thisAgent, cc->cond, tc_to_use))
{
/* --- negated cond is in the TC, so add it to the grounds --- */
if (thisAgent->sysparams[TRACE_BACKTRACING_SYSPARAM])
{
print_string(thisAgent, "\n-->Moving to grounds: ");
print_condition(thisAgent, cc->cond);
}
c_vrblz = copy_condition(thisAgent, cc->cond, true, should_unify_and_simplify);
c_vrblz->inst = cc->cond->inst;
add_cond(&c_vrblz, &prev_vrblz, &first_vrblz);
}
else
{
/* --- not in TC, so discard the condition --- */
if (thisAgent->sysparams[CHUNK_THROUGH_LOCAL_NEGATIONS_SYSPARAM] == false)
{
// this chunk will be overgeneral! don't create it
// SBW 5/07
// report what local negations are preventing the chunk,
// and set flags like we saw a ^quiescence t so it won't be created
report_local_negation(cc->cond); // in backtrace.cpp
m_reliable = false;
}
thisAgent->memoryManager->free_with_pool(MP_chunk_cond, cc);
has_local_negation = true;
}
}
#ifdef BUILD_WITH_EXPLAINER
if (has_local_negation)
{
thisAgent->explanationLogger->increment_stat_tested_local_negation();
}
#endif
if (prev_vrblz)
{
prev_vrblz->next = NIL;
}
else if (first_vrblz)
{
first_vrblz->next = NIL;
}
m_vrblz_top = first_vrblz;
if (first_vrblz)
{
add_additional_constraints();
create_instantiated_counterparts();
}
dprint(DT_BUILD_CHUNK_CONDS, "Instantiated chunk conditions after identity unification: \n%1", m_inst_top);
dprint(DT_BUILD_CHUNK_CONDS, "Variablized chunk conditions after copying and adding additional conditions: \n%1", m_vrblz_top);
dprint(DT_BUILD_CHUNK_CONDS, "build_chunk_conds_for_grounds_and_add_negateds done.\n");
}
/* --------------------------------------------------------------------
Add Goal or Impasse Tests
This routine adds goal id or impasse id tests to the variablized
conditions. For each id in the grounds that happens to be the
identifier of a goal or impasse, we add a goal/impasse id test
to the variablized conditions, to make sure that in the resulting
chunk, the variablization of that id is constrained to match against
a goal/impasse. (Note: actually, in the current implementation of
chunking, it's impossible for an impasse id to end up in the ground
set. So part of this code is unnecessary.)
-------------------------------------------------------------------- */
void Explanation_Based_Chunker::add_goal_or_impasse_tests()
{
condition* cc;
tc_number tc; /* mark each id as we add a test for it, so we don't add
a test for the same id in two different places */
Symbol* id;
test t;
tc = get_new_tc_number(thisAgent);
for (cc = m_inst_top; cc != NIL; cc = cc->next)
{
if (cc->type != POSITIVE_CONDITION)
{
continue;
}
id = cc->data.tests.id_test->eq_test->data.referent;
if ((id->id->isa_goal || id->id->isa_impasse) &&
(id->tc_num != tc))
{
/* We add the goal test to the counterpart, which is the variablized condition list */
t = make_test(thisAgent, NULL, ((id->id->isa_goal) ? GOAL_ID_TEST : IMPASSE_ID_TEST));
add_test(thisAgent, &(cc->counterpart->data.tests.id_test), t);
id->tc_num = tc;
}
}
}
/* --------------------------------------------------------------------
Reorder Instantiated Conditions
The Rete routines require the instantiated conditions (on the
instantiation structure) to be in the same order as the original
conditions from which the Rete was built. This means that the
initial instantiation of the chunk must have its conditions in
the same order as the variablized conditions. The trouble is,
the variablized conditions get rearranged by the reorderer. So,
after reordering, we have to rearrange the instantiated conditions
to put them in the same order as the now-scrambled variablized ones.
This routine does this.
-------------------------------------------------------------------- */
void Explanation_Based_Chunker::reorder_instantiated_conditions(condition* top_cond,
condition** dest_inst_top,
condition** dest_inst_bottom)
{
dprint(DT_MERGE, "Re-ordering...\n");
dprint_noprefix(DT_MERGE, "%1", top_cond->counterpart);
dprint(DT_MERGE, "..to match...\n");
dprint_noprefix(DT_MERGE, "%1", top_cond);
condition* c, *p, *n;
for (c = top_cond; c != NIL; c = c->next)
{
if (c->counterpart)
{
p = c->prev;
n = c->next;
if (!n)
{
c->counterpart->next = NULL;
*dest_inst_bottom = c->counterpart;
} else {
c->counterpart->next = n->counterpart;
}
if (!p)
{
c->counterpart->prev = NULL;
*dest_inst_top = c->counterpart;
} else {
c->counterpart->prev = p->counterpart;
}
}
}
dprint(DT_MERGE, "Result:\n");
dprint_noprefix(DT_MERGE, "%1", *dest_inst_top);
}
/* --------------------------------------------------------------------
Make Clones of Results
When we build the initial instantiation of the new chunk, we have
to fill in preferences_generated with *copies* of all the result
preferences. These copies are clones of the results. This routine
makes these clones and fills in chunk_inst->preferences_generated.
-------------------------------------------------------------------- */
void Explanation_Based_Chunker::make_clones_of_results()
{
preference* p, *result_p;
m_chunk_inst->preferences_generated = NIL;
for (result_p = m_results; result_p != NIL; result_p = result_p->next_result)
{
/* --- copy the preference --- */
p = make_preference(thisAgent, result_p->type, result_p->id, result_p->attr,
result_p->value, result_p->referent,
result_p->o_ids, result_p->rhs_funcs);
symbol_add_ref(thisAgent, p->id);
symbol_add_ref(thisAgent, p->attr);
symbol_add_ref(thisAgent, p->value);
if (preference_is_binary(p->type))
{
symbol_add_ref(thisAgent, p->referent);
}
/* --- put it onto the list for chunk_inst --- */
p->inst = m_chunk_inst;
insert_at_head_of_dll(m_chunk_inst->preferences_generated, p,
inst_next, inst_prev);
/* --- insert it into the list of clones for this preference --- */
p->next_clone = result_p;
p->prev_clone = result_p->prev_clone;
result_p->prev_clone = p;
if (p->prev_clone)
{
p->prev_clone->next_clone = p;
}
}
}
bool Explanation_Based_Chunker::can_learn_from_instantiation()
{
preference* pref;
/* --- if it only matched an attribute impasse, don't chunk --- */
if (! m_inst->match_goal)
{
return false;
}
/* --- if no preference is above the match goal level, exit --- */
/* MToDo | This seems redundant given what get_results_for_instantiation does. Is it faster
* and worth it because most calls won't have results, little less extra results? */
for (pref = m_inst->preferences_generated; pref != NIL; pref = pref->inst_next)
{
if (pref->id->id->level < m_inst->match_goal_level)
{
break;
}
}
if (!pref)
{
return false;
}
return true;
}
void Explanation_Based_Chunker::perform_dependency_analysis()
{
preference* pref;
goal_stack_level grounds_level = m_inst->match_goal_level - 1;
increment_counter(backtrace_number);
increment_counter(grounds_tc);
increment_counter(potentials_tc);
increment_counter(locals_tc);
grounds = NIL;
positive_potentials = NIL;
locals = NIL;
#ifdef BUILD_WITH_EXPLAINER
thisAgent->explanationLogger->set_backtrace_number(backtrace_number);
#endif
/* --- backtrace through the instantiation that produced each result --- */
dprint(DT_BACKTRACE, "Backtracing through base instantiation: \n%7that produced result preferences:\n%6\n", m_inst, NULL, m_results);
for (pref = m_results; pref != NIL; pref = pref->next_result)
{
if (thisAgent->sysparams[TRACE_BACKTRACING_SYSPARAM])
{
print_string(thisAgent, "\nFor result preference ");
xml_begin_tag(thisAgent, kTagBacktraceResult);
print_preference(thisAgent, pref);
print_string(thisAgent, " ");
}
backtrace_through_instantiation(pref->inst, grounds_level, NULL, pref->o_ids, pref->rhs_funcs, 0, (pref->inst == m_inst) ? BT_BaseInstantiation : BT_ExtraResults);
if (thisAgent->sysparams[TRACE_BACKTRACING_SYSPARAM])
{
xml_end_tag(thisAgent, kTagBacktraceResult);
}
}
dprint(DT_BACKTRACE, "Backtracing through results DONE. Grounds:\n%3", grounds);
while (true)
{
trace_locals(grounds_level);
trace_grounded_potentials();
if (! trace_ungrounded_potentials(grounds_level))
{
break;
}
}
dprint(DT_BACKTRACE, "Tracing DONE. Grounds after tracing:\n%3", grounds);
// dprint(DT_VARIABLIZATION_MANAGER, "Results:\n%6", pref);
free_list(thisAgent, positive_potentials);
}
void Explanation_Based_Chunker::deallocate_failed_chunk()
{
deallocate_condition_list(thisAgent, m_vrblz_top);
m_vrblz_top = NULL;
deallocate_condition_list(thisAgent, m_inst_top);
m_inst_top = m_inst_bottom = NULL;
deallocate_action_list(thisAgent, m_rhs);
m_rhs = NULL;
}
void Explanation_Based_Chunker::revert_chunk_to_instantiation()
{
print_with_symbols(thisAgent, "\nWarning: Chunk learned is invalid:\n\nsp {%y\n", m_prod_name);
print_condition_list(thisAgent, m_vrblz_top, 4, false);
print(thisAgent, "\n -->\n");
print_action_list(thisAgent, m_rhs, 4, false);
thisAgent->outputManager->display_soar_error(thisAgent, ebc_error_invalid_chunk);
/* Change to justification naming */
symbol_remove_ref(thisAgent, m_prod_name);
set_up_rule_name(false);
/* Clean up */
/* Note: We could decrease chunks_this_d_cycle but probably safer not to in case
* something can happen where you get massive number of failed chunks */
deallocate_failed_chunk();
m_vrblz_top = m_saved_justification_top;
m_saved_justification_top = m_saved_justification_bottom = NULL;
/* Re-do work without variablization */
create_instantiated_counterparts();
m_rhs = variablize_results_into_actions(m_results, false);
add_goal_or_impasse_tests();
print_with_symbols(thisAgent, "\nCreating the following justification instead:\n\nsp {%y\n", m_prod_name);
print_condition_list(thisAgent, m_vrblz_top, 4, false);
print(thisAgent, "\n -->\n");
print_action_list(thisAgent, m_rhs, 4, false);
print(thisAgent, "\n}\n\n");
}
void Explanation_Based_Chunker::set_up_rule_name(bool pForChunk)
{
/* Generate a new symbol for the name of the new chunk or justification */
if (pForChunk)
{
chunks_this_d_cycle++;
m_prod_name = generate_chunk_name(m_inst, pForChunk);
m_prod_type = CHUNK_PRODUCTION_TYPE;
m_should_print_name = (thisAgent->sysparams[TRACE_CHUNK_NAMES_SYSPARAM] != 0);
m_should_print_prod = (thisAgent->sysparams[TRACE_CHUNKS_SYSPARAM] != 0);
#ifdef BUILD_WITH_EXPLAINER
thisAgent->explanationLogger->increment_stat_chunks_attempted();
#endif
}
else
{
m_prod_name = generate_chunk_name(m_inst, pForChunk);
// m_prod_name = generate_new_str_constant(thisAgent, "justification-", &justification_count);
m_prod_type = JUSTIFICATION_PRODUCTION_TYPE;
m_should_print_name = (thisAgent->sysparams[TRACE_JUSTIFICATION_NAMES_SYSPARAM] != 0);
m_should_print_prod = (thisAgent->sysparams[TRACE_JUSTIFICATIONS_SYSPARAM] != 0);
#ifdef BUILD_WITH_EXPLAINER
thisAgent->explanationLogger->increment_stat_justifications_attempted();
#endif
}
if (m_should_print_name)
{
start_fresh_line(thisAgent);
if (pForChunk)
{
print_with_symbols(thisAgent, "Learning chunk %y\n", m_prod_name);
} else {
print_with_symbols(thisAgent, "Learning justification %y\n", m_prod_name);
}
xml_begin_tag(thisAgent, kTagLearning);
xml_begin_tag(thisAgent, kTagProduction);
xml_att_val(thisAgent, kProduction_Name, m_prod_name);
xml_end_tag(thisAgent, kTagProduction);
xml_end_tag(thisAgent, kTagLearning);
}
}
void Explanation_Based_Chunker::add_chunk_to_rete()
{
byte rete_addition_result;
production* duplicate_rule = NULL;
rete_addition_result = add_production_to_rete(thisAgent, m_prod, m_vrblz_top, m_chunk_inst, m_should_print_name, duplicate_rule);
if (m_should_print_prod && (rete_addition_result != DUPLICATE_PRODUCTION))
{
print(thisAgent, "\n");
xml_begin_tag(thisAgent, kTagLearning);
print_production(thisAgent, m_prod, false);
xml_end_tag(thisAgent, kTagLearning);
}
if (rete_addition_result == REFRACTED_INST_MATCHED)
{
#ifdef BUILD_WITH_EXPLAINER
assert(m_prod);
thisAgent->explanationLogger->record_chunk_contents(m_prod, m_vrblz_top, m_rhs, m_results, unification_map, m_inst, m_chunk_inst);
if (m_prod_type == JUSTIFICATION_PRODUCTION_TYPE) {
thisAgent->explanationLogger->increment_stat_justifications();
} else {
thisAgent->explanationLogger->increment_stat_succeeded();
}
#endif
dprint(DT_VARIABLIZATION_MANAGER, "Add production to rete result: Refracted instantiation matched.\n");
} else if (rete_addition_result == DUPLICATE_PRODUCTION) {
#ifdef BUILD_WITH_EXPLAINER
thisAgent->explanationLogger->increment_stat_duplicates(duplicate_rule);
thisAgent->explanationLogger->cancel_chunk_record();
#endif
excise_production(thisAgent, m_prod, false);
m_chunk_inst->in_ms = false;
dprint(DT_VARIABLIZATION_MANAGER, "Add production to rete result: Duplicate production.\n");
} else if (rete_addition_result == REFRACTED_INST_DID_NOT_MATCH) {
if (m_prod_type == JUSTIFICATION_PRODUCTION_TYPE)
{
#ifdef BUILD_WITH_EXPLAINER
thisAgent->explanationLogger->increment_stat_justification_did_not_match();
thisAgent->explanationLogger->cancel_chunk_record();
#endif
excise_production(thisAgent, m_prod, false);
} else {
#ifdef BUILD_WITH_EXPLAINER
thisAgent->explanationLogger->increment_stat_chunk_did_not_match();
assert(m_prod);
thisAgent->explanationLogger->record_chunk_contents(m_prod, m_vrblz_top, m_rhs, m_results, unification_map, m_inst, m_chunk_inst);
#endif
/* MToDo | Why don't we excise the chunk here like we do non-matching
* justifications? It doesn't seem like either case of non-matching rule
* should be possible unless a chunking or gds problem has occurred.
* Can we even get here? Let's see.*/
assert(false);
}
m_chunk_inst->in_ms = false;
dprint(DT_VARIABLIZATION_MANAGER, "Add production to rete result: Refracted instantiation did not match.\n");
} else {
dprint(DT_VARIABLIZATION_MANAGER, "Add production to rete result: No refracted instantiation given.\n");
/* Don't think this can happen either */
assert(false);
}
}
void Explanation_Based_Chunker::build_chunk_or_justification(instantiation* inst, instantiation** custom_inst_list)
{
preference* pref;
condition* inst_lhs_top = 0, *inst_lhs_bottom = 0;
bool variablize;
bool lChunkValidated = false;
#if !defined(NO_TIMING_STUFF) && defined(DETAILED_TIMING_STATS)
soar_timer local_timer;
local_timer.set_enabled(&(thisAgent->sysparams[ TIMERS_ENABLED ]));
#endif
m_inst = inst;
m_chunk_new_i_id = 0;
if (!can_learn_from_instantiation()) { m_inst = NULL; return; }
#if !defined(NO_TIMING_STUFF) && defined(DETAILED_TIMING_STATS)
local_timer.start();
#endif
// dprint(DT_DEBUG, "Chunk number %u\n", chunk_count);
// if (this->chunk_count == 6)
// {
// dprint(DT_DEBUG, "Chunk found.\n");
// }
get_results_for_instantiation();
if (!m_results) {
m_extra_results = NULL;
m_inst = NULL;
return;
}
dprint_header(DT_MILESTONES, PrintBoth, "Learning EBC rule for firing of %s (i%u)\n", m_inst->prod_name, m_inst->i_id);
m_reliable = true;
m_inst_top = m_inst_bottom = m_vrblz_top = NULL;
/* --- If we're over MAX_CHUNKS, abort chunk --- */
if (chunks_this_d_cycle > static_cast<uint64_t>(thisAgent->sysparams[MAX_CHUNKS_SYSPARAM]))
{
thisAgent->outputManager->display_soar_error(thisAgent, ebc_error_max_chunks, PRINT_WARNINGS_SYSPARAM);
max_chunks_reached = true;
#ifdef BUILD_WITH_EXPLAINER
thisAgent->explanationLogger->increment_stat_max_chunks();
#endif
m_extra_results = NULL;
m_inst = NULL;
return;
}
#ifdef BUILD_WITH_EXPLAINER
thisAgent->explanationLogger->add_chunk_record(m_inst);
#endif
/* set allow_bottom_up_chunks to false for all higher goals to prevent chunking */
{
Symbol* g;
for (g = m_inst->match_goal->id->higher_goal; g && g->id->allow_bottom_up_chunks; g = g->id->higher_goal)
{
g->id->allow_bottom_up_chunks = false;
}
}
/* Determine which WMEs in the topstate were relevent to problem-solving */
perform_dependency_analysis();
/* --- Assign a new instantiation ID --- */
m_chunk_new_i_id = get_new_inst_id();
/* --- Collect the grounds into the chunk condition lists --- */
create_initial_chunk_condition_lists();
/* --- Backtracing done. If there aren't any grounds, abort chunk --- */
if (!m_inst_top)
{
thisAgent->outputManager->display_soar_error(thisAgent, ebc_error_no_conditions, PRINT_WARNINGS_SYSPARAM);
#ifdef BUILD_WITH_EXPLAINER
thisAgent->explanationLogger->increment_stat_no_grounds();
thisAgent->explanationLogger->cancel_chunk_record();
#endif
clean_up();
return;
}
/* Determine if we create a justification or chunk */
variablize = learning_is_on_for_instantiation() && m_reliable;
set_up_rule_name(variablize);
dprint(DT_MILESTONES, "Backtracing done. Building chunk %y\n", m_prod_name);
dprint(DT_PRINT_INSTANTIATIONS, "Chunk_instantiation instantiated conditions from backtrace:\n%6", m_inst_top, m_results);
dprint(DT_BUILD_CHUNK_CONDS, "Counterparts conditions for variablization:\n%6", m_vrblz_top, m_results);
#ifdef BUILD_WITH_EXPLAINER
thisAgent->explanationLogger->add_result_instantiations(m_inst, m_results);
#endif
if (variablize)
{
/* Save conditions and results in case we need to make a justification because chunking fails */
copy_condition_list(thisAgent, m_vrblz_top, &m_saved_justification_top, &m_saved_justification_bottom, false, false, true);
reset_variable_generator(thisAgent, m_vrblz_top, NIL);
variablize_condition_list(m_vrblz_top);
dprint(DT_VARIABLIZATION_MANAGER, "chunk_instantiation after variablizing conditions and relational constraints: \n%6", m_vrblz_top, m_results);
#ifdef EBC_MERGE_CONDITIONS
merge_conditions(m_vrblz_top);
#endif
dprint(DT_VARIABLIZATION_MANAGER, "chunk_instantiation after merging conditions: \n%6", m_vrblz_top, m_results);
}
reset_variable_generator(thisAgent, m_vrblz_top, NIL);
dprint(DT_VARIABLIZATION_MANAGER, "Unifying and variablizing results... \n%6", m_vrblz_top, m_results);
m_rhs = variablize_results_into_actions(m_results, variablize);
add_goal_or_impasse_tests();
dprint(DT_VARIABLIZATION_MANAGER, "EBC created variablized rule: \n%1-->\n%2", m_vrblz_top, m_rhs);
dprint(DT_CONSTRAINTS, "- Instantiated conds after add_goal_test\n%5", m_inst_top, NULL);
thisAgent->name_of_production_being_reordered = m_prod_name->sc->name;
lChunkValidated = reorder_and_validate_chunk();
if (!lChunkValidated)
{
#ifdef BUILD_WITH_EXPLAINER
thisAgent->explanationLogger->increment_stat_unorderable();
#endif
if (variablize)
{
/* Could not re-order chunk, so we need to go back and create a justification for the results instead */
revert_chunk_to_instantiation();
m_prod = make_production(thisAgent, m_prod_type, m_prod_name, m_inst->prod_name->sc->name, &m_vrblz_top, &m_rhs, false, NULL);
if (m_prod)
{
dprint(DT_VARIABLIZATION_MANAGER, "Successfully generated justification for failed chunk.\n");
/* MToDo | Make this an option to interrrupt when an explanation is made*/
//thisAgent->stop_soar = true;
#ifdef BUILD_WITH_EXPLAINER
thisAgent->explanationLogger->increment_stat_reverted();
#endif
}
} else {
print_with_symbols(thisAgent, "\nWarning: Soar was not able to create a valid justification for a result:\n\nsp {%y\n", m_prod_name);
print_condition_list(thisAgent, m_vrblz_top, 2, false);
print(thisAgent, "\n -->\n ");
print_action_list(thisAgent, m_rhs, 3, false);
thisAgent->outputManager->display_soar_error(thisAgent, ebc_error_invalid_justification);
deallocate_failed_chunk();
#ifdef BUILD_WITH_EXPLAINER
thisAgent->explanationLogger->cancel_chunk_record();
#endif
clean_up();
return;
}
} else {
m_prod = make_production(thisAgent, m_prod_type, m_prod_name, m_inst->prod_name->sc->name, &m_vrblz_top, &m_rhs, false, NULL);
}
#ifdef BUILD_WITH_EXPLAINER
if (m_inst->prod && m_inst->prod->explain_its_chunks)
{
m_prod ->explain_its_chunks = true;
}
#endif
/* We don't want to accidentally delete it. Production struct is now responsible for it. */
m_prod_name = NULL;
reorder_instantiated_conditions(m_vrblz_top, &inst_lhs_top, &inst_lhs_bottom);
thisAgent->memoryManager->allocate_with_pool(MP_instantiation, &m_chunk_inst);
m_chunk_inst->prod = m_prod;
m_chunk_inst->prod_name = m_prod->name;
symbol_add_ref(thisAgent, m_chunk_inst->prod_name);
m_chunk_inst->top_of_instantiated_conditions = inst_lhs_top;
m_chunk_inst->bottom_of_instantiated_conditions = inst_lhs_bottom;
m_chunk_inst->GDS_evaluated_already = false;
m_chunk_inst->i_id = m_chunk_new_i_id;
m_chunk_inst->reliable = m_reliable;
m_chunk_inst->in_ms = true; /* set true for now, we'll find out later... */
m_chunk_inst->explain_status = explain_unrecorded;
m_chunk_inst->explain_depth = 0;
m_chunk_inst->explain_tc_num = 0;
make_clones_of_results();
init_instantiation(thisAgent, m_chunk_inst, true, m_inst);
dprint(DT_VARIABLIZATION_MANAGER, "Refracted instantiation: \n%5", m_chunk_inst->top_of_instantiated_conditions, m_chunk_inst->preferences_generated);
dprint(DT_VARIABLIZATION_MANAGER, "Saved instantiation with constraints: \n%5", m_inst_top, m_chunk_inst->preferences_generated);
add_chunk_to_rete();
/* --- deallocate chunks conds and variablized conditions --- */
deallocate_condition_list(thisAgent, m_vrblz_top);
m_vrblz_top = NULL;
/* --- assert the preferences --- */
m_chunk_inst->next = (*custom_inst_list);
(*custom_inst_list) = m_chunk_inst;
clean_up();
if (!max_chunks_reached)
{
dprint(DT_MILESTONES, "Calling chunk instantiation from chunk instantiation for i%u START\n", m_chunk_new_i_id);
set_learning_for_instantiation(*custom_inst_list);
build_chunk_or_justification(*custom_inst_list, custom_inst_list);
dprint(DT_MILESTONES, "Chunk instantiation called from chunk instantiation for i%u DONE.\n", m_chunk_new_i_id);
}
}
void Explanation_Based_Chunker::clean_up ()
{
if (m_chunk_new_i_id)
{
thisAgent->ebChunker->cleanup_for_instantiation(m_chunk_new_i_id);
}
thisAgent->explanationLogger->end_chunk_record();
if (m_vrblz_top)
{
deallocate_condition_list(thisAgent, m_vrblz_top);
}
if (m_prod_name)
{
dprint_header(DT_MILESTONES, PrintAfter, "chunk_instantiation() done building and cleaning up for chunk %y.\n", m_prod_name);
symbol_remove_ref(thisAgent, m_prod_name);
}
if (m_saved_justification_top)
{
deallocate_condition_list(thisAgent, m_saved_justification_top);
}
m_inst = NULL;
m_results = NULL;
m_extra_results = NULL;
m_inst_top = NULL;
m_inst_bottom = NULL;
m_vrblz_top = NULL;
m_rhs = NULL;
m_prod = NULL;
m_chunk_inst = NULL;
m_prod_name = NULL;
m_saved_justification_top = NULL;
m_saved_justification_bottom = NULL;
clear_variablization_maps();
clear_cached_constraints();
clear_o_id_substitution_map();
clear_attachment_map();
clear_singletons();
#if !defined(NO_TIMING_STUFF) && defined(DETAILED_TIMING_STATS)
local_timer.stop();
thisAgent->timers_chunking_cpu_time[thisAgent->current_phase].update(local_timer);
#endif
}
| 36.896581 | 171 | 0.618986 | Bryan-Stearns |
3f0bc0d87a6da9cca0f1dbb831ade745365325c6 | 2,522 | cpp | C++ | src/model/FirstLastList.cpp | lhui2010/AnchorWave | 388dcc8ee10ca8df131a7b526b0e72de09dcfa77 | [
"MIT"
] | 50 | 2021-07-31T12:54:48.000Z | 2022-03-10T09:09:05.000Z | src/model/FirstLastList.cpp | lhui2010/AnchorWave | 388dcc8ee10ca8df131a7b526b0e72de09dcfa77 | [
"MIT"
] | 15 | 2021-08-02T08:18:02.000Z | 2022-03-30T12:01:28.000Z | src/model/FirstLastList.cpp | lhui2010/AnchorWave | 388dcc8ee10ca8df131a7b526b0e72de09dcfa77 | [
"MIT"
] | 13 | 2021-07-30T19:43:53.000Z | 2022-03-22T05:53:51.000Z | /*
* =====================================================================================
*
* Filename: FirstLastList.cpp
*
* Description:
*
* Version: 1.0
* Created: 06/05/2017 15:47:39
* Revision: none
* Compiler: gcc
*
* Author: Baoxing Song (songbx.me), songbaoxing168@163.com
*
* =====================================================================================
*/
/*************************************************************************
**************************************************************************/
#include "FirstLastList.h"
Data::Data(Variant& mapSingleRecord){
this->mapSingleRecord = mapSingleRecord;
this->prev = NULL;
this->next = NULL;
}
const Variant& Data::getMapSingleRecord() const{
return mapSingleRecord;
}
Data* Data::getNext() const{
return this->next;
}
Data* Data::getPrev() const{
return this->prev;
}
void Data::setNext( Data* data ){
this->next = data;
}
void Data::setPrev( Data* data){
this->prev = data;
}
void Data::setMapSingleRecord( Variant& mapSingleRecord){
this->mapSingleRecord=mapSingleRecord;
}
void FirstLastList::insertLast(Data* data){
if(this->first == NULL){
this->first = data;
}else{
this->last->setNext(data);
data->setPrev(this->last);
}
this->last = data;
}
void FirstLastList::setLast(Data* data){
if( data == NULL ){
this->first = NULL;
this->last = NULL;
}else{
data->setNext(NULL);
this->last = data;
}
}
void FirstLastList::deleteFirst(){
if(this->first == NULL){ // this is a empty link
return;// this->first->getMapSingleRecord();
}
if( this->first->getNext() == NULL) { // this link has only one element
delete(this->first);
this->last = NULL;
this->first = NULL;
return;
}
Data * temp = this->first;
this->first->getNext()->setPrev( NULL );
this->first = (this->first->getNext());
delete(temp);
}
void FirstLastList::deleteLast(){
if(this->first == NULL){
return;
}
if( this->first == this->last ){
delete(this->last);
this->first = NULL;
this->last = NULL;
return;
}
Data * temp = this->last;
this->last = (last->getPrev());
this->last->setNext(NULL);
delete(temp);
}
Data* FirstLastList::getFirst() const{
return this->first;
}
Data* FirstLastList::getLast() const {
return this->last;
}
| 22.318584 | 88 | 0.501586 | lhui2010 |
3f0f71fce0263087f932fb0c7c8d3c60fc737810 | 5,003 | cpp | C++ | SDK/ARKSurvivalEvolved_AIStateWanderOnLand_functions.cpp | 2bite/ARK-SDK | c38ca9925309516b2093ad8c3a70ed9489e1d573 | [
"MIT"
] | 10 | 2020-02-17T19:08:46.000Z | 2021-07-31T11:07:19.000Z | SDK/ARKSurvivalEvolved_AIStateWanderOnLand_functions.cpp | 2bite/ARK-SDK | c38ca9925309516b2093ad8c3a70ed9489e1d573 | [
"MIT"
] | 9 | 2020-02-17T18:15:41.000Z | 2021-06-06T19:17:34.000Z | SDK/ARKSurvivalEvolved_AIStateWanderOnLand_functions.cpp | 2bite/ARK-SDK | c38ca9925309516b2093ad8c3a70ed9489e1d573 | [
"MIT"
] | 3 | 2020-07-22T17:42:07.000Z | 2021-06-19T17:16:13.000Z | // ARKSurvivalEvolved (329.9) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
#include "ARKSurvivalEvolved_AIStateWanderOnLand_parameters.hpp"
namespace sdk
{
//---------------------------------------------------------------------------
//Functions
//---------------------------------------------------------------------------
// Function AIStateWanderOnLand.AIStateWanderOnLand_C.FindTargetAreas
// ()
// Parameters:
// bool found (Parm, OutParm, ZeroConstructor, IsPlainOldData)
void UAIStateWanderOnLand_C::FindTargetAreas(bool* found)
{
static auto fn = UObject::FindObject<UFunction>("Function AIStateWanderOnLand.AIStateWanderOnLand_C.FindTargetAreas");
UAIStateWanderOnLand_C_FindTargetAreas_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
if (found != nullptr)
*found = params.found;
}
// Function AIStateWanderOnLand.AIStateWanderOnLand_C.OnCanUseStateEvent
// ()
// Parameters:
// bool ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData)
bool UAIStateWanderOnLand_C::OnCanUseStateEvent()
{
static auto fn = UObject::FindObject<UFunction>("Function AIStateWanderOnLand.AIStateWanderOnLand_C.OnCanUseStateEvent");
UAIStateWanderOnLand_C_OnCanUseStateEvent_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
return params.ReturnValue;
}
// Function AIStateWanderOnLand.AIStateWanderOnLand_C.OnEndEvent
// ()
void UAIStateWanderOnLand_C::OnEndEvent()
{
static auto fn = UObject::FindObject<UFunction>("Function AIStateWanderOnLand.AIStateWanderOnLand_C.OnEndEvent");
UAIStateWanderOnLand_C_OnEndEvent_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function AIStateWanderOnLand.AIStateWanderOnLand_C.OnTickEvent
// ()
// Parameters:
// float* DeltaSeconds (Parm, ZeroConstructor, IsPlainOldData)
void UAIStateWanderOnLand_C::OnTickEvent(float* DeltaSeconds)
{
static auto fn = UObject::FindObject<UFunction>("Function AIStateWanderOnLand.AIStateWanderOnLand_C.OnTickEvent");
UAIStateWanderOnLand_C_OnTickEvent_Params params;
params.DeltaSeconds = DeltaSeconds;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function AIStateWanderOnLand.AIStateWanderOnLand_C.UpgradePawnAcceleration
// ()
// Parameters:
// bool Upgrade (Parm, ZeroConstructor, IsPlainOldData)
void UAIStateWanderOnLand_C::UpgradePawnAcceleration(bool Upgrade)
{
static auto fn = UObject::FindObject<UFunction>("Function AIStateWanderOnLand.AIStateWanderOnLand_C.UpgradePawnAcceleration");
UAIStateWanderOnLand_C_UpgradePawnAcceleration_Params params;
params.Upgrade = Upgrade;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function AIStateWanderOnLand.AIStateWanderOnLand_C.GetRandomTarget
// ()
// Parameters:
// class ATargetArea* returnTarget (Parm, OutParm, ZeroConstructor, IsPlainOldData)
void UAIStateWanderOnLand_C::GetRandomTarget(class ATargetArea** returnTarget)
{
static auto fn = UObject::FindObject<UFunction>("Function AIStateWanderOnLand.AIStateWanderOnLand_C.GetRandomTarget");
UAIStateWanderOnLand_C_GetRandomTarget_Params params;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
if (returnTarget != nullptr)
*returnTarget = params.returnTarget;
}
// Function AIStateWanderOnLand.AIStateWanderOnLand_C.OnBeginEvent
// ()
// Parameters:
// class UPrimalAIState** InParentState (Parm, ZeroConstructor, IsPlainOldData)
void UAIStateWanderOnLand_C::OnBeginEvent(class UPrimalAIState** InParentState)
{
static auto fn = UObject::FindObject<UFunction>("Function AIStateWanderOnLand.AIStateWanderOnLand_C.OnBeginEvent");
UAIStateWanderOnLand_C_OnBeginEvent_Params params;
params.InParentState = InParentState;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function AIStateWanderOnLand.AIStateWanderOnLand_C.ExecuteUbergraph_AIStateWanderOnLand
// ()
// Parameters:
// int EntryPoint (Parm, ZeroConstructor, IsPlainOldData)
void UAIStateWanderOnLand_C::ExecuteUbergraph_AIStateWanderOnLand(int EntryPoint)
{
static auto fn = UObject::FindObject<UFunction>("Function AIStateWanderOnLand.AIStateWanderOnLand_C.ExecuteUbergraph_AIStateWanderOnLand");
UAIStateWanderOnLand_C_ExecuteUbergraph_AIStateWanderOnLand_Params params;
params.EntryPoint = EntryPoint;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| 27.489011 | 140 | 0.728763 | 2bite |
3f15e00d26b36a61117962310d3d3f10965be55c | 2,777 | cpp | C++ | krypto/krypto_main.cpp | unigoetheradaw/prg2-pr_milestone1-master | a376d4f2fe5b830a6d1b04ebe50088c506599270 | [
"MIT"
] | null | null | null | krypto/krypto_main.cpp | unigoetheradaw/prg2-pr_milestone1-master | a376d4f2fe5b830a6d1b04ebe50088c506599270 | [
"MIT"
] | null | null | null | krypto/krypto_main.cpp | unigoetheradaw/prg2-pr_milestone1-master | a376d4f2fe5b830a6d1b04ebe50088c506599270 | [
"MIT"
] | null | null | null | //
// Created by Niels Heissel on 30.10.18.
//
#include <iostream>
#include <fstream>
#include <vector>
#include <tuple>
//#include "file_handler_class.h"
#include "NBild.h"
#include "CBild.h"
#include "interface.h"
#include <random>
#include <iostream>
using namespace std;
void create_rand_key(int height, int width){
CBild canvas_char;
canvas_char.export_file("/Users/nielsheissel/CLionProjects/prg2-pr/krypto/key_a.txt", canvas_char.create_rand_picture(height, width));
}
void aufgabe_f(){
Interface inter;
CBild canvas_char;
NBild canvas_int;
// Save a second picture and a random key
//canvas_char.export_file("/Users/nielsheissel/CLionProjects/prg2-pr/krypto/beispiel_f_pic2.txt", canvas_int.create_rand_picture(89,303));
//canvas_char.export_file("/Users/nielsheissel/CLionProjects/prg2-pr/krypto/beispiel_f_key.txt", canvas_char.create_rand_picture(89, 303));
// Encrypt the first picture : "beispielbild_1.txt"
inter.encrypt("/Users/nielsheissel/CLionProjects/prg2-pr/krypto/2f_approval.txt",
"/Users/nielsheissel/CLionProjects/prg2-pr/krypto/key_f.txt",
"/Users/nielsheissel/CLionProjects/prg2-pr/krypto/aproval_enc.txt", false);
// Encrypt the first picture : "beispiel_f_pic2.txt"
inter.encrypt("/Users/nielsheissel/CLionProjects/prg2-pr/krypto/2f_bugaspicture.txt",
"/Users/nielsheissel/CLionProjects/prg2-pr/krypto/key_f.txt",
"/Users/nielsheissel/CLionProjects/prg2-pr/krypto/2f_bugaspicture_enc.txt", false);
// Overlay both pictures and save result as "result_f.txt"
inter.overlay("/Users/nielsheissel/CLionProjects/prg2-pr/krypto/aproval_enc.txt", "/Users/nielsheissel/CLionProjects/prg2-pr/krypto/2f_bugaspicture_enc.txt",
"/Users/nielsheissel/CLionProjects/prg2-pr/krypto/result_f.txt", false);
}
int main(int argc, char *argv[]) {
if(argc == 5) {
string program = argv[1];
string arg1 = argv[2];
string arg2 = argv[3];
string arg3 = argv[4];
Interface interf;
cout << "You passed " << argc << " arguments: " << argv[1] << endl;
if (program == "encode") {
cout << "Encoding your source." << endl;
interf.encrypt(arg1, arg2, arg3, false);
} else if (program == "decode") {
cout << "Decoding your source." << endl;
interf.decrypt(arg1, arg2, arg3, false);
} else if (program == "overlay") {
cout << "Overlaying your sources." << endl;
interf.overlay(arg1, arg2, arg3, false);
}
}
else{
cerr << "You need to pass four arguments: ... you passed " << argc << endl;
}
//aufgabe_f();
//create_rand_key(10, 10);
return 0;
}
| 34.7125 | 161 | 0.655384 | unigoetheradaw |
3f16a2fcc89d143e6a8b430eaca6dd672bb7932a | 1,453 | cpp | C++ | CsPlugin/Source/CsCore/Public/Library/Script/CsScriptLibrary_StaticMesh.cpp | closedsum/core | c3cae44a177b9684585043a275130f9c7b67fef0 | [
"Unlicense"
] | 2 | 2019-03-17T10:43:53.000Z | 2021-04-20T21:24:19.000Z | CsPlugin/Source/CsCore/Public/Library/Script/CsScriptLibrary_StaticMesh.cpp | closedsum/core | c3cae44a177b9684585043a275130f9c7b67fef0 | [
"Unlicense"
] | null | null | null | CsPlugin/Source/CsCore/Public/Library/Script/CsScriptLibrary_StaticMesh.cpp | closedsum/core | c3cae44a177b9684585043a275130f9c7b67fef0 | [
"Unlicense"
] | null | null | null | // Copyright 2017-2021 Closed Sum Games, LLC. All Rights Reserved.
#include "Library/Script/CsScriptLibrary_StaticMesh.h"
#include "CsCore.h"
// Types
#include "Types/CsTypes_Macro.h"
// Library
#include "Library/CsLibrary_StaticMesh.h"
// Cached
#pragma region
namespace NCsScriptLibraryStaticMesh
{
namespace NCached
{
namespace Str
{
CS_DEFINE_CACHED_FUNCTION_NAME_AS_STRING(UCsScriptLibrary_StaticMesh, LoadBySoftObjectPath);
CS_DEFINE_CACHED_FUNCTION_NAME_AS_STRING(UCsScriptLibrary_StaticMesh, LoadByStringPath);
}
}
}
#pragma endregion Cached
UCsScriptLibrary_StaticMesh::UCsScriptLibrary_StaticMesh(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}
// Load
#pragma region
UStaticMesh* UCsScriptLibrary_StaticMesh::LoadBySoftObjectPath(const FString& Context, const FSoftObjectPath& Path)
{
using namespace NCsScriptLibraryStaticMesh::NCached;
const FString& Ctxt = Context.IsEmpty() ? Str::LoadBySoftObjectPath : Context;
typedef NCsStaticMesh::FLibrary StaticMeshLibrary;
return StaticMeshLibrary::SafeLoad(Ctxt, Path);
}
UStaticMesh* UCsScriptLibrary_StaticMesh::LoadByStringPath(const FString& Context, const FString& Path)
{
using namespace NCsScriptLibraryStaticMesh::NCached;
const FString& Ctxt = Context.IsEmpty() ? Str::LoadByStringPath : Context;
typedef NCsStaticMesh::FLibrary StaticMeshLibrary;
return StaticMeshLibrary::SafeLoad(Ctxt, Path);
}
#pragma endregion Load | 25.491228 | 115 | 0.80936 | closedsum |