int main () { std::pair <std::string, double> product1; // default constructor std::pair <std::string, double> product2("tomatoes", 2.30); // value init std::pair <std::string, double> product3(product2); // copy constructor product1 = std::make_pair(std::string("lightbulbs"), 0.99); // using make_pair (move) product2.first = "shoes"; // the type of first is string product2.second = 39.90; // the type of second is double std::cout << "The price of " << product1.first << " is $" << product1.second << '\n'; std::cout << "The price of " << product2.first << " is $" << product2.second << '\n'; std::cout << "The price of " << product3.first << " is $" << product3.second << '\n'; return 0; }
NativeView(JNIEnv *_env, jobject _obj, unsigned _width, unsigned _height, unsigned _sdk_version, jstring _product) :env(_env), obj(env, _obj), width(_width), height(_height), sdk_version(_sdk_version) { Java::String product2(env, _product); product2.CopyTo(env, product, sizeof(product)); Java::Class cls(env, "org/xcsoar/NativeView"); init_surface_method = env->GetMethodID(cls, "initSurface", "()Z"); deinit_surface_method = env->GetMethodID(cls, "deinitSurface", "()V"); setRequestedOrientationID = env->GetMethodID(cls, "setRequestedOrientation", "(I)Z"); swap_method = env->GetMethodID(cls, "swap", "()V"); load_resource_texture_method = env->GetMethodID(cls, "loadResourceTexture", "(Ljava/lang/String;[I)Z"); load_file_texture_method = env->GetMethodID(cls, "loadFileTexture", "(Ljava/lang/String;[I)Z"); }
VEC *iter_lanczos2(ITER *ip, VEC *evals, VEC *err_est) #endif { VEC *a; STATIC VEC *b=VNULL, *a2=VNULL, *b2=VNULL; Real beta, pb_mant, det_mant, det_mant1, det_mant2; int i, pb_expt, det_expt, det_expt1, det_expt2; if ( ! ip ) error(E_NULL,"iter_lanczos2"); if ( ! ip->Ax || ! ip->x ) error(E_NULL,"iter_lanczos2"); if ( ip->k <= 0 ) error(E_RANGE,"iter_lanczos2"); a = evals; a = v_resize(a,(unsigned int)ip->k); b = v_resize(b,(unsigned int)(ip->k-1)); MEM_STAT_REG(b,TYPE_VEC); iter_lanczos(ip,a,b,&beta,MNULL); /* printf("# beta =%g\n",beta); */ pb_mant = 0.0; if ( err_est ) { pb_mant = product(b,(double)0.0,&pb_expt); /* printf("# pb_mant = %g, pb_expt = %d\n",pb_mant, pb_expt); */ } /* printf("# diags =\n"); v_output(a); */ /* printf("# off diags =\n"); v_output(b); */ a2 = v_resize(a2,a->dim - 1); b2 = v_resize(b2,b->dim - 1); MEM_STAT_REG(a2,TYPE_VEC); MEM_STAT_REG(b2,TYPE_VEC); for ( i = 0; i < a2->dim - 1; i++ ) { a2->ve[i] = a->ve[i+1]; b2->ve[i] = b->ve[i+1]; } a2->ve[a2->dim-1] = a->ve[a2->dim]; trieig(a,b,MNULL); /* sort evals as a courtesy */ qsort((void *)(a->ve),(int)(a->dim),sizeof(Real),(int (*)())dbl_cmp); /* error estimates */ if ( err_est ) { err_est = v_resize(err_est,(unsigned int)ip->k); trieig(a2,b2,MNULL); /* printf("# a =\n"); v_output(a); */ /* printf("# a2 =\n"); v_output(a2); */ for ( i = 0; i < a->dim; i++ ) { det_mant1 = product2(a,i,&det_expt1); det_mant2 = product(a2,(double)a->ve[i],&det_expt2); /* printf("# det_mant1=%g, det_expt1=%d\n", det_mant1,det_expt1); */ /* printf("# det_mant2=%g, det_expt2=%d\n", det_mant2,det_expt2); */ if ( det_mant1 == 0.0 ) { /* multiple e-val of T */ err_est->ve[i] = 0.0; continue; } else if ( det_mant2 == 0.0 ) { err_est->ve[i] = HUGE_VAL; continue; } if ( (det_expt1 + det_expt2) % 2 ) /* if odd... */ det_mant = sqrt(2.0*fabs(det_mant1*det_mant2)); else /* if even... */ det_mant = sqrt(fabs(det_mant1*det_mant2)); det_expt = (det_expt1+det_expt2)/2; err_est->ve[i] = fabs(beta* ldexp(pb_mant/det_mant,pb_expt-det_expt)); } } #ifdef THREADSAFE V_FREE(b); V_FREE(a2); V_FREE(b2); #endif return a; }