本文整理汇总了C++中G函数的典型用法代码示例。如果您正苦于以下问题:C++ G函数的具体用法?C++ G怎么用?C++ G使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了G函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: luaS_freeall
#include "lmem.h"
#include "lobject.h"
#include "lstate.h"
#include "lstring.h"
void luaS_freeall (lua_State *L) {
lua_assert(G(L)->strt.nuse==0);
luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size, TString *);
}
void luaS_resize (lua_State *L, int newsize) {
GCObject **newhash = luaM_newvector(L, newsize, GCObject *);
stringtable *tb = &G(L)->strt;
int i;
for (i=0; i<newsize; i++) newhash[i] = NULL;
/* rehash */
for (i=0; i<tb->size; i++) {
GCObject *p = tb->hash[i];
while (p) { /* for each node in the list */
GCObject *next = p->gch.next; /* save next */
lu_hash h = gcotots(p)->tsv.hash;
int h1 = lmod(h, newsize); /* new position */
lua_assert(cast(int, h%newsize) == lmod(h, newsize));
p->gch.next = newhash[h1]; /* chain it */
newhash[h1] = p;
p = next;
}
}
示例2: ASJ
#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
ASJ( jmp, 5, f)
ASL(4) // non-SSE2
#endif
AS2( add [AS_REG_7+0*4], ecx) // A
AS2( add [AS_REG_7+4*4], edi) // E
AS2( mov eax, B(0))
AS2( mov ebx, C(0))
AS2( mov ecx, D(0))
AS2( add [AS_REG_7+1*4], eax)
AS2( add [AS_REG_7+2*4], ebx)
AS2( add [AS_REG_7+3*4], ecx)
AS2( mov eax, F(0))
AS2( mov ebx, G(0))
AS2( mov ecx, H(0))
AS2( add [AS_REG_7+5*4], eax)
AS2( add [AS_REG_7+6*4], ebx)
AS2( add [AS_REG_7+7*4], ecx)
AS2( mov ecx, AS_REG_7d)
AS2( cmp WORD_REG(dx), DATA_END)
ASJ( jb, 2, b)
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE
ASL(5)
#endif
#endif
AS_POP_IF86(sp)
AS_POP_IF86(bp)
#if !defined(_MSC_VER) || (_MSC_VER < 1400)
示例3: lua_close
LUA_API void lua_close (lua_State *L) {
L = G(L)->mainthread; /* only the main thread can be closed */
lua_lock(L);
close_state(L);
}
示例4: luaC_sweep
void luaC_sweep (lua_State *L, int all) {
if (all) all = 256; /* larger than any mark */
sweeplist(L, &G(L)->rootudata, all);
sweepstrings(L, all);
sweeplist(L, &G(L)->rootgc, all);
}
示例5: Kou_Ap_Am
static int Kou_Ap_Am(double S0,NumFunc_1 *P,double T,double r,double divid,double sigma,double lambda,double lambdap,double lambdam,double p,double *ptPrice,double *ptDelta)
{
double K=P->Par[0].Val.V_DOUBLE;
long double x[12]={sigma,lambda,p,lambdap,lambdam,S0,K,r,T,divid,0,0},temp,eps1=1e-6,un=1.0L,q=1-p;
if ((P->Compute)==&Call)
{
//On utilise la dualité (Farjado & Mordecki)
temp=x[7];
x[7]=x[9];
x[9]=temp;
temp=x[2];
x[2]=(1-x[2])*x[4]/(1+x[4]);
q=temp*x[3]/(x[3]-1);
temp=x[3];
x[3]=x[4]+1;
x[4]=temp-1;
temp=x[5];
x[5]=x[6];
x[6]=temp;
}
long double
ksi=x[2]*x[3]/(x[3]-1)+q*x[4]/(x[4]+1)-1,
nu=(x[7]-x[9])-sigma*sigma/2-lambda*ksi,
eps=1e-16;
long double y[8]={nu,sigma,lambda,x[2],x[3],x[4],x[7]/(1-exp(-x[7]*T)),q}, beta3,beta4;
KCE G(y);
dichotomie solG(G,-x[4]+eps,-eps,eps1);
beta3=solG.racine()[0];
newton solG1(G,beta3,eps);
beta3=-solG1.racine()[0];
long double x0=-x[4]-10;
while(G.f(x0)<0)
x0=x0-10;
dichotomie solG2(G,x0,-x[4]-eps,eps1);
beta4=solG2.racine()[0];
newton solG3(G,beta4,eps);
beta4=-solG3.racine()[0];
long double C=beta3*beta4*(1+x[4]);
long double D=x[4]*(1+beta3)*(1+beta4);
x[10]=C;
x[11]=D;
//for(i=0;i<12;i++)
//cout << x[i] <<endl;
amer_eq f(x);
long double x1, x2;
x1=x[6]/2;
x2=x[6]/(2+eps);
if(f.f(x1)*f.f(x2)>0)
{
int i=1;
long double temp;
if(f.f(x1)>0)
{
x2=(1+un*i/100.)*x[6]/2.;
while(f.f(x2)>0)
{
temp=x2;
x2=(1+un*i/100.)*x[6];
x1=temp;
i++;
}
}
else
{
x1=(1+eps-un*i/100.)*x[6]/(2.+eps);
while(f.f(x1)<0)
{
temp=x1;
x1=(1+eps-un*i/100.)*x[6]/(2.+eps);
x2=temp;
i++;
}
}
}
dichotomie solf(f,x1,x2,1e-1);
long double v0=solf.racine()[0];
long double EuP, dEuP, EuP0, dEuP0, cst1, cst2,dcst1,dcst2, cst11, cst21, dcst11, dcst21;
long double z[8];
z[0]=nu;
z[1]=sigma;
z[2]=lambda;
z[3]=x[2];
z[4]=x[3];
z[5]=x[4];
z[6]=log(x[6]/v0);
//.........这里部分代码省略.........
示例6: chisq
/*p.d.f of Chi-square*/
double chisq(int df, double x)
{
return ( pow(x/2, (df-2)/2.)*exp(-x/2)/(2*G(df/2.)) );
}
示例7: GO
void Executable::init(STATE) {
GO(executable).set(ontology::new_class(state, "Executable", G(object), G(rubinius)));
G(executable)->set_object_type(state, ExecutableType);
G(executable)->name(state, state->symbol("Rubinius::Executable"));
}
示例8: ConnectBDPT
Spectrum ConnectBDPT(const Scene &scene, Vertex *lightVertices,
Vertex *cameraVertices, int s, int t,
const Distribution1D &lightDistr, const Camera &camera,
Sampler &sampler, Point2f *pRaster, Float *misWeightPtr) {
Spectrum L(0.f);
// Ignore invalid connections related to infinite area lights
if (t > 1 && s != 0 && cameraVertices[t - 1].type == VertexType::Light)
return Spectrum(0.f);
// Perform connection and write contribution to _L_
Vertex sampled;
if (s == 0) {
// Interpret the camera subpath as a complete path
const Vertex &pt = cameraVertices[t - 1];
if (pt.IsLight()) L = pt.Le(scene, cameraVertices[t - 2]) * pt.beta;
} else if (t == 1) {
// Sample a point on the camera and connect it to the light subpath
const Vertex &qs = lightVertices[s - 1];
if (qs.IsConnectible()) {
VisibilityTester vis;
Vector3f wi;
Float pdf;
Spectrum Wi = camera.Sample_Wi(qs.GetInteraction(), sampler.Get2D(),
&wi, &pdf, pRaster, &vis);
if (pdf > 0 && !Wi.IsBlack()) {
// Initialize dynamically sampled vertex and _L_ for $t=1$ case
sampled = Vertex::CreateCamera(&camera, vis.P1(), Wi / pdf);
L = qs.beta * qs.f(sampled) * vis.Tr(scene, sampler) *
sampled.beta;
if (qs.IsOnSurface()) L *= AbsDot(wi, qs.ns());
}
}
} else if (s == 1) {
// Sample a point on a light and connect it to the camera subpath
const Vertex &pt = cameraVertices[t - 1];
if (pt.IsConnectible()) {
Float lightPdf;
VisibilityTester vis;
Vector3f wi;
Float pdf;
int lightNum =
lightDistr.SampleDiscrete(sampler.Get1D(), &lightPdf);
const std::shared_ptr<Light> &light = scene.lights[lightNum];
Spectrum lightWeight = light->Sample_Li(
pt.GetInteraction(), sampler.Get2D(), &wi, &pdf, &vis);
if (pdf > 0 && !lightWeight.IsBlack()) {
EndpointInteraction ei(vis.P1(), light.get());
sampled =
Vertex::CreateLight(ei, lightWeight / (pdf * lightPdf), 0);
sampled.pdfFwd = sampled.PdfLightOrigin(scene, pt, lightDistr);
L = pt.beta * pt.f(sampled) * vis.Tr(scene, sampler) *
sampled.beta;
if (pt.IsOnSurface()) L *= AbsDot(wi, pt.ns());
}
}
} else {
// Handle all other bidirectional connection cases
const Vertex &qs = lightVertices[s - 1], &pt = cameraVertices[t - 1];
if (qs.IsConnectible() && pt.IsConnectible()) {
L = qs.beta * qs.f(pt) * pt.f(qs) * pt.beta;
if (!L.IsBlack()) L *= G(scene, sampler, qs, pt);
}
}
// Compute MIS weight for connection strategy
Float misWeight =
L.IsBlack() ? 0.f : MISWeight(scene, lightVertices, cameraVertices,
sampled, s, t, lightDistr);
L *= misWeight;
if (misWeightPtr) *misWeightPtr = misWeight;
return L;
}
示例9: GO
void Dir::init(STATE) {
GO(dir).set(ontology::new_class(state, "Dir", G(object)));
G(dir)->set_object_type(state, DirType);
}
示例10: main
int main(int , char* [])
{
typedef boost::adjacency_list<
boost::mapS, boost::vecS, boost::bidirectionalS,
boost::property<boost::vertex_color_t, boost::default_color_type,
boost::property<boost::vertex_degree_t, int,
boost::property<boost::vertex_in_degree_t, int,
boost::property<boost::vertex_out_degree_t, int> > > >
> Graph;
Graph G(5);
boost::add_edge(0, 2, G);
boost::add_edge(1, 1, G);
boost::add_edge(1, 3, G);
boost::add_edge(1, 4, G);
boost::add_edge(2, 1, G);
boost::add_edge(2, 3, G);
boost::add_edge(2, 4, G);
boost::add_edge(3, 1, G);
boost::add_edge(3, 4, G);
boost::add_edge(4, 0, G);
boost::add_edge(4, 1, G);
typedef Graph::vertex_descriptor Vertex;
Graph G_copy(5);
// Array to store predecessor (parent) of each vertex. This will be
// used as a Decorator (actually, its iterator will be).
std::vector<Vertex> p(boost::num_vertices(G));
// VC++ version of std::vector has no ::pointer, so
// I use ::value_type* instead.
typedef std::vector<Vertex>::value_type* Piter;
// Array to store distances from the source to each vertex . We use
// a built-in array here just for variety. This will also be used as
// a Decorator.
boost::graph_traits<Graph>::vertices_size_type d[5];
std::fill_n(d, 5, 0);
// The source vertex
Vertex s = *(boost::vertices(G).first);
p[s] = s;
boost::breadth_first_search
(G, s,
boost::visitor(boost::make_bfs_visitor
(std::make_pair(boost::record_distances(d, boost::on_tree_edge()),
std::make_pair
(boost::record_predecessors(&p[0],
boost::on_tree_edge()),
copy_graph(G_copy, boost::on_examine_edge())))) ));
boost::print_graph(G);
boost::print_graph(G_copy);
if (boost::num_vertices(G) < 11) {
std::cout << "distances: ";
#ifdef BOOST_OLD_STREAM_ITERATORS
std::copy(d, d + 5, std::ostream_iterator<int, char>(std::cout, " "));
#else
std::copy(d, d + 5, std::ostream_iterator<int>(std::cout, " "));
#endif
std::cout << std::endl;
std::for_each(boost::vertices(G).first, boost::vertices(G).second,
print_parent<Piter>(&p[0]));
}
return 0;
}
示例11: request_raw_connection
void request_raw_connection(Promise<std::unique_ptr<mtproto::RawConnection>> promise) override {
send_closure(G()->connection_creator(), &ConnectionCreator::request_raw_connection, dc_id_, allow_media_only_,
is_media_, std::move(promise), hash_);
}
示例12: video_thread
int video_thread(SceSize args, void *argp) {
// Pixel coordinates: first = first luminant pixel to breach threshhold, last = ..., mid = ...
Coord first, last, mid;
int bufsize; int threshold = 200; // Luminance threshold.
int showvideo = 0; // Show the actual video input? 0: No, 1: Yes
// Camera buffers.
PspUsbCamSetupVideoParam videoparam;
static u8 buffer[MAX_STILL_IMAGE_SIZE] __attribute__((aligned(64)));
static u8 work[68*1024] __attribute__((aligned(64)));
static u32 framebuffer[480*272] __attribute__((aligned(64)));
// Startup cursor position.
cursor.x = 237, cursor.y = 50; old.x = 237, old.y = 50;
// Setup the screenmap size and position.
screenmap.x = 20; screenmap.y = 200;
screenmap.w = 60; screenmap.h = 60;
screenmap.gridcolor = 0xFFC09090;
screenmap.fillcolor = 0xFFF0F0F0;
screenmap.selcolor = 0xFFC0FFFF;
// Create a start button.
Button btnStart;
btnStart.x = 420; btnStart.y = 250;
btnStart.w = 50; btnStart.h = 12;
btnStart.fillcolor = 0xFF00FFFF;
btnStart.textcolor = 0xFF000000;
btnStart.bordercolor = 0xFF000000;
btnStart.shadowcolor = 0xFF888888;
btnStart.bordersize = 1;
btnStart.borderbevel = 0;
btnStart.shadowsize = 0;
btnStart.shadowdistance = 0;
strcpy(btnStart.text, "Start");
strcpy(btnStart.name, "btnStart");
// Wait for camera to be connected.
while (!connected) {
clearScreen(0xFFF0F0F0);
printTextScreenCenter(132, "Please connect the camera and press any button.", 0xFF009900);
flipScreen(); sceDisplayWaitVblankStart();
sceKernelDelayThread(20000);
}
// Load the camera modules and start the decoder.
if (LoadModules() < 0) sceKernelSleepThread();
if (StartUsb() < 0) sceKernelSleepThread();
if (sceUsbActivate(PSP_USBCAM_PID) < 0) sceKernelSleepThread();
if (InitJpegDecoder() < 0) sceKernelSleepThread();
while (1) {
if ((sceUsbGetState() & 0xF) == PSP_USB_CONNECTION_ESTABLISHED) break;
sceKernelDelayThread(50000);
}
//Setup video parameters and start video capture.
memset(&videoparam, 0, sizeof(videoparam));
videoparam.size = sizeof(videoparam);
videoparam.resolution = PSP_USBCAM_RESOLUTION_480_272;
videoparam.framerate = PSP_USBCAM_FRAMERATE_30_FPS;
videoparam.wb = PSP_USBCAM_WB_INCANDESCENT;
videoparam.saturation = 125;
videoparam.brightness = 100;
videoparam.contrast = 64;
videoparam.sharpness = 0;
videoparam.effectmode = PSP_USBCAM_EFFECTMODE_NORMAL;
videoparam.framesize = MAX_VIDEO_FRAME_SIZE;
videoparam.evlevel = PSP_USBCAM_EVLEVEL_0_0;
if (sceUsbCamSetupVideo(&videoparam, work, sizeof(work)) < 0) sceKernelExitDeleteThread(0);
sceUsbCamAutoImageReverseSW(1);
if (sceUsbCamStartVideo() < 0) sceKernelExitDeleteThread(0);
while (running) {
int i, j, lum = 0, tracking = 0;
first.x = 0; first.y = 0; last.x = 0; last.y = 0; mid.x = old.x; mid.y = old.y;
clearScreen(0xFFFFFFFF);
// Capture the camera image into the framebuffer.
bufsize = sceUsbCamReadVideoFrameBlocking(buffer, MAX_VIDEO_FRAME_SIZE);
if (bufsize > 0) sceJpegDecodeMJpeg(buffer, bufsize, framebuffer, 0);
// Analyze the camera image.
for (i = 0; i < 272; i++) {
for (j = 0; j < 480; j++) {
if (showvideo) putPixelScreen(framebuffer[i * CAM_LINE_SIZE + j], j, i); // Show video input.
// Calculate luminance (brightness as perceived by the eye) and compare versus threshhold.
lum = (299 * R(framebuffer[i * CAM_LINE_SIZE + j]) + 587 * G(framebuffer[i * CAM_LINE_SIZE + j]) + 114 * B(framebuffer[i * CAM_LINE_SIZE + j])) / 1000;
if (lum > threshold) {
tracking = 1; if (aligned) putPixelScreen(0xFF0000FF, j, i);
if ((first.x == 0) || (j < first.x)) first.x = j;
if ((first.y == 0) || (i < first.y)) first.y = i;
if ((last.x == 0) || (j > last.x)) last.x = j;
if ((last.y == 0) || (i > last.y)) last.y = i;
}
}
}
if (tracking) {
// Calculate directional movement and determine cursor position.
mid.x = first.x + (abs((last.x - first.x)) / 2); mid.y = first.y + (abs((last.y - first.y)) / 2);
//.........这里部分代码省略.........
示例13: main
main()
{
int i,k,j;
int nbArcs =0;
double eval=0;
double nimp =0;
Graphe G(72000,8760,0,0,nimp);
// cout<< "sommet créé"<<endl;
G.genererArcs();
int nbSommets =G.getNbSommet();
cout<< "Arbre créé de " <<nbSommets<<" sommets \n";
// nombre arcs:
//for(i=0; i<G.getNbSommet(); i++)
/* {
nbArcs= nbArcs + G.getListeSommets()[i].getNbSuccesseurs();
}
cout <<"et de " << nbArcs << " arcs \n";*/
//Algorithme de Bellman
//G.getSommet(0)->setPoids(0);
//cout <<G.getSommet(0)->getPoids() << " le poids \n" ;
/*for(i=0; i<nbSommets-1; i++)
{
for(j=1; j<nbSommets; j++)
{
Sommet* s =G.getSommet(j);
double poids= s->getPoids();
for(k=0;k<s->getNbSuccesseurs();k++)
{
//on regarde tt les ars kj
double poidsK = s->getPredecesseurs(k)->getPoids();
double valArc = s->getValeurArc(k);
if( poidsK + valArc>=poids)
{
s->setPred(k);
//cout << s->getPredecesseurs(k)->getPoids() <<"\n\n";
s->setPoids(poidsK + valArc);
poids= s->getPoids();
}
}
}
}
//Calcul valeur :
Sommet s=G.getListeSommets()[nbSommets-1];
//cout <<"debut evaluation \n";
for(i=0;i<168;i++)
{
//cout << "heure :" << s.getHeure()<<":\n";
int pred = s.getPred();
eval= eval+ s.getValeurArc(pred);
s = *(s.getPredecesseurs(pred));
}*/
eval=G.plusCourtChemin();
cout << eval << "\n";
}
示例14: test_allocate
void test_allocate() {
Class* sub = ontology::new_class(state, "ArraySub", G(array), 0);
Array* ary = Array::allocate(state, sub);
TS_ASSERT_EQUALS(ary->klass(), sub);
}
示例15: init_main_0
//.........这里部分代码省略.........
for (short i = 0; i<A; ++i) {
myfile_1<< Corpi.CORPI(i)<< " ";
myfile_tabella<< Corpi.CORPI(i)<< " ";
myfile_tabella_p<< Corpi.CORPI(i)<< " ";
myfile_tabella_d<< Corpi.CORPI(i)<< " ";
myfile_livelli<< Corpi.CORPI(i)<< " ";
}
myfile_1 << std::endl;
myfile_tabella << std::endl;
myfile_tabella_p << std::endl;
myfile_tabella_d << std::endl;
myfile_livelli << std::endl;
myfile_1 << " m_max = " << m_max << " K_max = " << K_max << " S_tot = " << S_tot <<"/2" << std::endl;
myfile_tabella << " m_max = " << m_max << " K_max = " << K_max << " S_tot = " << S_tot <<"/2"<< std::endl;
myfile_tabella_p << " m_max = " << m_max << " K_max = " << K_max << " S_tot = " << S_tot <<"/2"<< std::endl;
myfile_tabella_d << " m_max = " << m_max << " K_max = " << K_max << " S_tot = " << S_tot <<"/2"<< std::endl;
myfile_livelli << " m_max = " << m_max << " K_max = " << K_max << " S_tot = " << S_tot <<"/2"<< std::endl;
}
if(Corpi.M_u() && A==3) {
myfile_tabella << "K_max N_hh Parita' E E_ppp E_ppn E_nnp E_nnn E_c" << std::endl;
myfile_tabella_p << "K_max N_hh Parita' E E_ppp E_ppn E_nnp E_nnn E_c" << std::endl;
myfile_tabella_d << "K_max N_hh Parita' E E_ppp E_ppn E_nnp E_nnn E_c" << std::endl;
}
else{
myfile_tabella << "K_max N_hh Parita' E E_c" << std::endl;
myfile_tabella_p << "K_max N_hh Parita' E E_c" << std::endl;
myfile_tabella_d << "K_max N_hh Parita' E E_c" << std::endl;
}
boost::timer t6;
unsigned short incremento = 2;
Gauss_Laguerre G(ordine);
HyperInt HI(ordine/2);
Integrazioni_3_P INT_3P(N);
Accoppiamenti_Spinoriali_S SS (Corpi.D_s(),clus,S_tot,Corpi.D_Z_min());
Accoppiamenti_Iperangolari_K_max KK (N, 0, 0, K_min,P,clus,0);
// Energia_radiale_spin ER ( SS, N, G, HI, K_min, m_max, Corpi.C(), Corpi.M(), Corpi.M_R(),clus);
// Energia_spin EN ( HI, &INT_3P, ER, KK );
//lancsoz
VETTORI mygen(m_max + 1);
VETTORI mygen_c(m_max + 1);
VETTORI mygen1(m_max + 1);
VETTORI mygen1_c(m_max + 1);
VETTORI mygen2(m_max + 1);
VETTORI mygen2_c(m_max + 1);
typedef boost::lagged_fibonacci607 Gen_i;
typedef ietl::vectorspace<VETTORI> Vecspace;
Gen_i mygen_i;
bool primopasso = true;
bool primopasso1 = true;
bool primopasso2 = true;
bool primopasso_c = true;
bool primopasso1_c = true;
bool primopasso2_c = true;
tipo_matrici rel_tol = 500000000*std::numeric_limits<double>::epsilon();
tipo_matrici abs_tol = 1000000*std::pow(std::numeric_limits<double>::epsilon(),2./3);
int n_lowest_eigenval = 1;
//lancsoz
for (unsigned short K_max_temp = K_min; K_max_temp <= K_max; K_max_temp+=incremento) {