您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ x2函数代码示例

51自学网 2021-06-03 10:13:16
  C++
这篇教程C++ x2函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中x2函数的典型用法代码示例。如果您正苦于以下问题:C++ x2函数的具体用法?C++ x2怎么用?C++ x2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了x2函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: TEUCHOS_UNIT_TEST

//---------------------------------------------------------------------------//TEUCHOS_UNIT_TEST( WuBasis, wu_basis_order_2 ){    typedef DataTransferKit::WuBasis<2> BasisType;    typedef DataTransferKit::RadialBasisPolicy<BasisType> BP;    int dim = 3;    Teuchos::Array<double> x1(dim, 0.5);    Teuchos::Array<double> x2(dim, 0.75);    double radius_1 = 1.0;    Teuchos::RCP<BasisType> basis_1 = BP::create();    double dist = DataTransferKit::EuclideanDistance<3>::distance( 	x1.getRawPtr(), x2.getRawPtr() );    double basis_value = BP::evaluateValue( *basis_1, radius_1, dist );    double basis_grad = BP::evaluateGradient( *basis_1, radius_1, dist );    double x = 0.0;    for ( int i = 0; i < dim; ++i )    {	x += (x2[i]-x1[i])*(x2[i]-x1[i]);    }    x = std::sqrt(x);    double test_value = (1.0-x)*(1.0-x)*(1.0-x)*(1.0-x)*(1.0-x) *			( 5.0*x*x*x*x+25.0*x*x*x+48.0*x*x+40.0*x+8.0 );    double test_grad = -9.0*(x-1.0)*(x-1.0)*(x-1.0)*(x-1.0)*x *		       ( 5.0*x*x*x+20.0*x*x+29.0*x+16.0 );    TEST_EQUALITY( test_value, basis_value );    TEST_FLOATING_EQUALITY( test_grad, basis_grad, epsilon );    double radius_2 = 0.1;    BasisType basis_2;    basis_value = BP::evaluateValue( basis_2, radius_2, dist );    basis_grad = BP::evaluateGradient( basis_2, radius_2, dist );    TEST_EQUALITY( 0.0, basis_value );    TEST_EQUALITY( 0.0, basis_grad );}
开发者ID:Tech-XCorp,项目名称:DataTransferKit,代码行数:42,


示例2: probability_x_less_than_y

  double probability_x_less_than_y(const std::valarray<double>& x, const std::valarray<double>& y)  {    vector<double> x2(x.size());    for(int i=0;i<x2.size();i++)      x2[i] = x[i];    sort(x2.begin(),x2.end());    vector<double> y2(y.size());    for(int i=0;i<y2.size();i++)      y2[i] = y[i];    sort(y2.begin(),y2.end());    valarray<double> FX(y.size());    int dx=0;    for(int dy=0;dy<FX.size();dy++) {      while((dx<x2.size()) and (x2[dx]<y2[dy]))	dx++;      FX[dy] = double(dx)/x2.size();    }    return FX.sum()/FX.size();  }
开发者ID:sibonli,项目名称:BAli-Phy,代码行数:21,


示例3: luaX_loadstring

LUALIB_API int luaX_loadstring(lua_State* L, LPCTSTR code, LPCTSTR name){	CString x1(code);	int sz = x1.GetLength();	int bs = WideCharToMultiByte(CP_THREAD_ACP, 0, x1, sz + 1, NULL, 0, NULL, NULL);	char* b1 = new char[bs];	int rs = WideCharToMultiByte(CP_THREAD_ACP, 0, x1, sz + 1, b1, bs, NULL, NULL);	CString x2(name);	x2 = CString("=String-") + x2;	sz = x2.GetLength();	bs = WideCharToMultiByte(CP_THREAD_ACP, 0, x2, sz + 1, NULL, 0, NULL, NULL);	char* b2 = new char[bs];	WideCharToMultiByte(CP_THREAD_ACP, 0, x2, sz + 1, b2, bs, NULL, NULL);	int r = luaL_loadbuffer(L, b1, rs - 1, b2);	delete b1;	delete b2;	return r;}
开发者ID:radioflash,项目名称:Winsh.lua,代码行数:21,


示例4: DrawVisibility

void DrawVisibility(QPainter *p,pigalePaint *paint)  {TopologicalGraph G(paint->GCP);  Prop<Tpoint> P1(G.Set(tedge()),PROP_DRAW_POINT_1);  Prop<Tpoint> P2(G.Set(tedge()),PROP_DRAW_POINT_2);  Prop<int> x1(G.Set(tvertex()),PROP_DRAW_INT_1);  Prop<int> x2(G.Set(tvertex()),PROP_DRAW_INT_2);  Prop<int> y(G.Set(tvertex()),PROP_DRAW_INT_5);  Prop<short> ecolor(G.Set(tedge()),PROP_COLOR);  Prop<short> vcolor(G.Set(tvertex()),PROP_COLOR);  double alpha=0.35;  p->setFont(QFont("sans",Min((int)(1.8*alpha * Min(paint->xscale,paint->yscale) + .5),13)));  Tpoint a,b;  for(tvertex v=1;v<=G.nv();v++)      paint->DrawText(p,x1[v]-alpha,y[v]+alpha, x2[v]-x1[v]+2*alpha,2*alpha,v,vcolor[v]);  for (tedge e = 1;e <= G.ne();e++)      {a.x() = P1[e].x(); a.y() = P1[e].y() + alpha;      b.x() = P1[e].x();  b.y() = P2[e].y() - alpha;      paint->DrawSeg(p,a,b,ecolor[e]);      }  }
开发者ID:beauby,项目名称:pigale,代码行数:21,


示例5: main

main(){   Punct x1(10, 10), x2(100, 200);   Dreptunghi d1(x1, x2), d2(10, 20, 14, 50);   clrscr();   d1.List();   getch();   cout<<'/n';   d2.List();   getch();   cout<<'/n';   if (d1 == d2)      cout<<"d1 = d2";   else      cout<<"d1 != d2";   getch();   cout<<'/n';   cout<<d1.Lung_lat1()<<' '<<d1.Lung_lat2();   getch();   cout<<'/n';   cout<<d2.Lung_lat1()<<' '<<d2.Lung_lat2();   getch();   cout<<'/n';   cout<<"Perimetrul d1: "<<d1.Perimetru();   getch();   cout<<'/n';   cout<<"Perimetrul d2: "<<d2.Perimetru();   getch();   cout<<'/n';   cout<<"d1, colt stanga sus : "<<d1.Colt_st_sus();   getch();   cout<<'/n';   cout<<"d1, colt dreapta jos : "<<d1.Colt_dr_jos();   getch();   cout<<'/n';   return 0;}
开发者ID:bdumitriu,项目名称:playground,代码行数:40,


示例6: run

    void run() {/** * note: this test will deadlock if the code breaks */#if defined(__linux__) || defined(__APPLE__)        // create        pthread_rwlock_t lk;        verify(pthread_rwlock_init(&lk, 0) == 0);        // read lock        verify(pthread_rwlock_rdlock(&lk) == 0);        AtomicUInt32 x1(0);        stdx::thread t1(stdx::bind(worker1, &lk, &x1));        while (!x1.load())            ;        verify(x1.load() == 1);        sleepmillis(500);        verify(x1.load() == 1);        AtomicUInt32 x2(0);        stdx::thread t2(stdx::bind(worker2, &lk, &x2));        t2.join();        verify(x2.load() == 1);        pthread_rwlock_unlock(&lk);        for (int i = 0; i < 2000; i++) {            if (x1.load() == 2)                break;            sleepmillis(1);        }        verify(x1.load() == 2);        t1.join();#endif    }
开发者ID:AlexOreshkevich,项目名称:mongo,代码行数:40,


示例7: testCosineTransform

double testCosineTransform (long n) {	try {		autoNUMvector<double> x (1, n);		autoNUMvector<double> y (1, n);		autoNUMvector<double> x2 (1, n);		autoNUMmatrix<double> cosinesTable (NUMcosinesTable (n), 1, 1);		for (long i = 1 ; i <= n; i++) {			x[i] = NUMrandomUniform (0, 70);		}		NUMcosineTransform (x.peek(), y.peek(), n, cosinesTable.peek());		NUMinverseCosineTransform (y.peek(), x2.peek(), n, cosinesTable.peek());		double delta = 0;		for (long i =1 ; i <= n; i++) {			double dif = x[i] - x2[i];			delta += dif * dif;		}		delta = sqrt (delta);		return delta;	} catch (MelderError) {		Melder_throw ("Test cosine transform error");	}}
开发者ID:arizona-phonological-imaging-lab,项目名称:ultrapraat,代码行数:22,


示例8: TEUCHOS_UNIT_TEST

//---------------------------------------------------------------------------//// Tests.//---------------------------------------------------------------------------//TEUCHOS_UNIT_TEST( WendlandBasis, dim_1_order_0 ){    typedef DataTransferKit::WendlandBasis<0> BasisType;    typedef DataTransferKit::RadialBasisPolicy<BasisType> BP;    int dim = 1;    Teuchos::Array<double> x1(dim, 0.5);    Teuchos::Array<double> x2(dim, 0.75);    double radius_1 = 1.0;    Teuchos::RCP<BasisType> basis_1 = BP::create( radius_1 );    double dist = DataTransferKit::EuclideanDistance<1>::distance( 	x1.getRawPtr(), x2.getRawPtr() );    double basis_value = BP::evaluateValue( *basis_1, dist );    double basis_grad = BP::evaluateGradient( *basis_1, dist );    double x = 0.0;    for ( int i = 0; i < dim; ++i )    {	x += (x2[i]-x1[i])*(x2[i]-x1[i]);    }    x = std::sqrt(x);    double test_value = (1.0-x)*(1.0-x);    double test_grad = 2.0*x-2.0;    TEST_EQUALITY( test_value, basis_value );    TEST_EQUALITY( test_grad, basis_grad );    double radius_2 = 0.1;    BasisType basis_2( radius_2 );    basis_value = BP::evaluateValue( basis_2, dist );    basis_grad = BP::evaluateGradient( basis_2, dist );    TEST_EQUALITY( 0.0, basis_value );    TEST_EQUALITY( 0.0, basis_grad );}
开发者ID:amccaskey,项目名称:DataTransferKit,代码行数:42,


示例9: interpolate

// Interpolates between the click pointsstatic void interpolate (const dataVec& dataIn, dataVec& dataOut){	const size_t nSteps = 10;	const size_t interpolatedSize = (dataIn.size() - 1) * nSteps;	dataOut.resize(interpolatedSize);	std::vector<double> x(dataIn.size()), y(dataIn.size());	std::transform(begin(dataIn), end(dataIn), begin(x), [](lk::trackDatum d){ return std::get<1>(d).x; });	std::transform(begin(dataIn), end(dataIn), begin(y), [](lk::trackDatum d){ return std::get<1>(d).y; });	std::vector<size_t> frameIndices(interpolatedSize);	std::iota(begin(frameIndices), end(frameIndices), 0);	std::vector<double> x2(interpolatedSize), y2(interpolatedSize);	interpolation::cubic(begin(x), end(x), begin(x2), nSteps);	interpolation::cubic(begin(y), end(y), begin(y2), nSteps);	for (size_t i = 0; i < interpolatedSize; i++)	{		dataOut[i] = lk::trackDatum(frameIndices[i], cv::Point2d(x2[i], y2[i]));	}}
开发者ID:cbowdon,项目名称:Computer-Vision-Theremin,代码行数:23,


示例10: createMeshLaplacianLM

boost::shared_ptr<Mesh<Simplex<2> > >createMeshLaplacianLM(){    typedef Mesh<Simplex<2> > mesh_type;    double meshSize = option("gmsh.hsize").as<double>();    GeoTool::Node x1(-2,-1);    GeoTool::Node x2(2,1);    GeoTool::Rectangle R( meshSize ,"OMEGA",x1,x2);    //R.setMarker(_type="line",_name="Paroi",_marker3=true);    R.setMarker(_type="line",_name="gamma",_markerAll=true);    R.setMarker(_type="surface",_name="Omega",_markerAll=true);    GeoTool::Node x3(0,0); //center    GeoTool::Node x4(1);//majorRadiusParam    GeoTool::Node x5(0.7);//minorRadiusParam    GeoTool::Node x6(0.1);//penautRadiusParam    GeoTool::Peanut P( meshSize ,"OMEGA2",x3,x4,x5,x6);    P.setMarker(_type="line",_name="peanut",_markerAll=true);    P.setMarker(_type="surface",_name="Omega2",_markerAll=true);    auto mesh = (R-P).createMesh(_mesh=new mesh_type,_name="mymesh.msh");    return mesh;}
开发者ID:LANTZT,项目名称:feelpp,代码行数:22,


示例11: cos

Foliage::Fixed Foliage::FastMath::cos(const Foliage::Fixed x){	if (x < Sint16(0))	{		return cos(x.opposite());	}		if (x > F_TWOPI)	{		return cos(x - F_TWOPI);	}	if (x > F_PI)	{		return cos(x - F_PI).opposite();	}	if (x > F_PI_2)	{		return cos(F_PI - x).opposite();	}	Fixed x2(x);	x2 *= F_2000_OVER_PI;	Sint16 i = Sint16(x2);	return Foliage::FastMath::cos_t[i];}
开发者ID:mguillemot,项目名称:kamaku.foliage,代码行数:23,


示例12: main

int main(int argc, char *argv[]) {    // Los vectores en C++ son escencialmente arreglos en C con una interfaz    // más conveniente. Donde sea que se pueda usar arreglos, se puede usar    // vectores. Cuando se necesita la dirección de memoria de un arreglo, hay    // que usar la dirección del primer elemento del vector: &x[0].  x por sí    // solo no sirve ya que es un objeto que encapsula al verdadero arreglo.    std::vector<float> x1;    x1.reserve(N);    x1.resize(N);    // copiar datos del archivo de entrada al vector    std::ifstream input_file(data_file_name, std::ios::binary | std::ios::in);    if (!input_file) {        std::cerr << "No se pudo abrir el archivo " << data_file_name << std::endl;        std::exit(-1);    }    input_file.read((char *) &x1[0], N * sizeof(float));    input_file.close();    // crear una copia del vector, de modo de tener    // uno para mapear en la GPU y otro en la CPU    std::vector<float> x2(x1);    // mapear x1 en la CPU y x2 en la GPU    cpu_map(x1);    gpu_map(&x2[0], x2.size());    // verificar que los resultados son prácticamente iguales    float squared_diff_norm = 0.0;#   define SQUARED(x) ((x) * (x))#   pragma omp parallel reduction(+: squared_diff_norm)    for (unsigned i = 0; i < N; ++i)        squared_diff_norm += SQUARED(x1[i] - x2[i]);    std::cout << "Norma de la diferencia: " << std::sqrt(squared_diff_norm) << std::endl;}
开发者ID:rbonvall,项目名称:hpc-gpu-2010-2,代码行数:37,


示例13: x1

/// return the index of the MHM domain of a fractureint TPZFracSet::MHMDomain(TPZFracture &frac){    TPZManVector<REAL,3> x1(3), x2(3), xmid(3);    fNodeVec[frac.fNodes[0]].GetCoordinates(x1);    fNodeVec[frac.fNodes[1]].GetCoordinates(x2);    std::pair<uint32_t,uint32_t> key0 = NodeKey(frac.fNodes[0]);    std::pair<uint32_t,uint32_t> key1 = NodeKey(frac.fNodes[1]);    if(key0.first == key1.first && key0.first%fMHMSpacingInt[0] == 0)    {        return -1;    }    if(key0.second == key1.second && key0.second%fMHMSpacingInt[1] == 0)    {        return -1;    }    for (int i=0; i<3; i++) {        xmid[i] = (x1[i]+x2[i])*0.5-fLowLeft[i];    }    int numfacex = (fTopRight[0]-fLowLeft[0])/fMHMSpacing[0];    int numx = (xmid[0])/fMHMSpacing[0];    int numy = (xmid[1])/fMHMSpacing[1];    return numy*numfacex+numx;}
开发者ID:labmec,项目名称:neopz,代码行数:25,


示例14: fevec5

int fevec5(Epetra_Comm& Comm, bool verbose){  int NumElements = 4;  Epetra_Map     Map(NumElements, 0, Comm);  Epetra_FEVector x1(Map);  x1.PutScalar (0);        // let all processors set global entry 0 to 1  const int GID = 0;  const double value = 1;  x1.ReplaceGlobalValues(1, &GID, &value);  x1.GlobalAssemble (Insert);  if (Comm.MyPID()==0)    std::cout << "Entry " << GID << " after construct & set: "         << x1[0][0] << std::endl;        // copy vector  Epetra_FEVector x2 (x1);  x2.PutScalar(0);        // re-apply 1 to the vector, but only on the        // owning processor. should be enough to set        // the value (as non-local data in x1 should        // have been eliminated after calling        // GlobalAssemble).  if (Comm.MyPID()==0)    x2.ReplaceGlobalValues(1, &GID, &value);  x2.GlobalAssemble (Insert);  if (Comm.MyPID()==0)    std::cout << "Entry " << GID << " after copy & set:      "         << x2[0][0] << std::endl;  return 0;}
开发者ID:cakeisalie,项目名称:oomphlib_003,代码行数:36,


示例15: TEST

TEST(StanAgradRevInternal, precomp_vv_vari) {  double value, gradient1, gradient2;  AVAR x1(2), x2(3);  AVAR y;    value = 1;  gradient1 = 4;  gradient2 = 5;  AVEC vars = createAVEC(x1, x2);  EXPECT_NO_THROW(y       = stan::math::var(new stan::math::precomp_vv_vari(value,           x1.vi_, x2.vi_, gradient1, gradient2)));  EXPECT_FLOAT_EQ(value, y.val());  VEC g;  EXPECT_NO_THROW(y.grad(vars, g));  ASSERT_EQ(2U, g.size());  EXPECT_FLOAT_EQ(gradient1, g[0]);  EXPECT_FLOAT_EQ(gradient2, g[1]);  stan::math::recover_memory();}
开发者ID:aseyboldt,项目名称:math,代码行数:24,


示例16: RSA_TestInstantiations

void RSA_TestInstantiations(){	RSASS<PKCS1v15, SHA1>::Verifier x1(1, 1);	RSASS<PKCS1v15, SHA1>::Signer x2(NullRNG(), 1);	RSASS<PKCS1v15, SHA1>::Verifier x3(x2);	RSASS<PKCS1v15, SHA1>::Verifier x4(x2.GetKey());	RSASS<PSS, SHA1>::Verifier x5(x3);#ifndef __MWERKS__	RSASS<PSSR, SHA1>::Signer x6 = x2;	x3 = x2;	x6 = x2;#endif	RSAES<PKCS1v15>::Encryptor x7(x2);#ifndef __GNUC__	RSAES<PKCS1v15>::Encryptor x8(x3);#endif	RSAES<OAEP<SHA1> >::Encryptor x9(x2);	x4 = x2.GetKey();	RSASS<PKCS1v15, SHA3_256>::Verifier x10(1, 1);	RSASS<PKCS1v15, SHA3_256>::Signer x11(NullRNG(), 1);	RSASS<PKCS1v15, SHA3_256>::Verifier x12(x11);	RSASS<PKCS1v15, SHA3_256>::Verifier x13(x11.GetKey());}
开发者ID:Mellnik,项目名称:hash-plugin,代码行数:24,


示例17: test1

void test1() {    Y *y1p = new Y;    Y *y2p = new Y;    cout << "X::nx after init: " << X::nx << "(2)" << endl;    cout << "y1p->nreference() after init: " << y1p->nreference() << "(0)" << endl;    X *x1p = y1p;    X *x2p = y2p;    void *vy1p = (void *)y1p;    void *vy2p = (void *)y2p;    void *vx1p = (void *)x1p;    void *vx2p = (void *)x2p;    Ref<Y> y1 = y1p;    Ref<Y> y2 = y2p;    cout << "X::nx after Ref<Y> assignment: " << X::nx << "(2)" << endl;    cout << "y1->nreference() after Ref<Y> assignment: " << y1->nreference() << "(1)"         << endl;    Ref<X> x1(y1);    Ref<X> x2(y2);    cout << "X::nx after Ref<X> assignment: " << X::nx << "(2)" << endl;    cout << "y1->nreference() after Ref<X> assignment: " << y1->nreference() << "(2)"         << endl;    x1 = y1;    x2 = y2;    Ref<Y> yb1, yb2;    yb1 << x1;    yb2 << x2;    cout << "x1 = " << (void *)x1.pointer() << "(" << vx1p << ")" << endl;    cout << "x2 = " << (void *)x2.pointer() << "(" << vx2p << ")" << endl;    cout << "y1 = " << (void *)y1.pointer() << "(" << vy1p << ")" << endl;    cout << "y2 = " << (void *)y2.pointer() << "(" << vy2p << ")" << endl;    cout << "yb1 = " << (void *)yb1.pointer() << "(" << (void *)y1.pointer() << ")"         << endl;    cout << "yb2 = " << (void *)yb2.pointer() << "(" << (void *)y2.pointer() << ")"         << endl;}
开发者ID:pyal,项目名称:eos_cpp,代码行数:36,


示例18: abs_round

voidscrollable_widget_rep::scroll_event_hor (SI& x, SI& bef, SI& af) {  abs_round (x);  if ((x + x1() - ox) < ex1) x = ex1 - x1() + ox;  if ((x + x2() - ox) > ex2) x = ex2 - x2() + ox;  if (attached ()) {    int dx= max (-w, min (w, x- scx));    if ((dx>-w) && (dx<w) && (dx!=0)) {      win->translate (x1(), y1(), x2(), y2(), -dx, 0);    }    if (dx>0) this << emit_invalidate (x2()-ox-dx, y1()-oy, x2()-ox, y2()-oy);    if (dx<0) this << emit_invalidate (x1()-ox, y1()-oy, x1()-ox-dx, y2()-oy);  }  scx      = x;  bef      = ox- x1();  af       = x2()- ox;  a[0]->ox = ox- scx;}
开发者ID:svn2github,项目名称:texmacs,代码行数:20,


示例19: TrsvUN

inline voidTrsvUN( UnitOrNonUnit diag, const DistMatrix<F>& U, DistMatrix<F>& x ){#ifndef RELEASE    PushCallStack("internal::TrsvUN");    if( U.Grid() != x.Grid() )        throw std::logic_error("{U,x} must be distributed over the same grid");    if( U.Height() != U.Width() )        throw std::logic_error("U must be square");    if( x.Width() != 1 && x.Height() != 1 )        throw std::logic_error("x must be a vector");    const int xLength = ( x.Width() == 1 ? x.Height() : x.Width() );    if( U.Width() != xLength )        throw std::logic_error("Nonconformal TrsvUN");#endif    const Grid& g = U.Grid();    if( x.Width() == 1 )    {        // Matrix views         DistMatrix<F> U01(g),                      U11(g);        DistMatrix<F>             xT(g),  x0(g),            xB(g),  x1(g),                    x2(g);        // Temporary distributions        DistMatrix<F,STAR,STAR> U11_STAR_STAR(g);        DistMatrix<F,STAR,STAR> x1_STAR_STAR(g);        DistMatrix<F,MR,  STAR> x1_MR_STAR(g);        DistMatrix<F,MC,  STAR> z_MC_STAR(g);        // Views of z[MC,* ], which will store updates to x        DistMatrix<F,MC,STAR> z0_MC_STAR(g),                              z1_MC_STAR(g);        z_MC_STAR.AlignWith( U );        Zeros( x.Height(), 1, z_MC_STAR );        // Start the algorithm        PartitionUp        ( x, xT,             xB, 0 );        while( xT.Height() > 0 )        {            RepartitionUp            ( xT,  x0,                   x1,             /**/ /**/              xB,  x2 );            const int n0 = x0.Height();            const int n1 = x1.Height();            LockedView( U01, U, 0,  n0, n0, n1 );            LockedView( U11, U, n0, n0, n1, n1 );            View( z0_MC_STAR, z_MC_STAR, 0,  0, n0, 1 );            View( z1_MC_STAR, z_MC_STAR, n0, 0, n1, 1 );            x1_MR_STAR.AlignWith( U01 );            //----------------------------------------------------------------//            if( x2.Height() != 0 )                x1.SumScatterUpdate( F(1), z1_MC_STAR );            x1_STAR_STAR = x1;            U11_STAR_STAR = U11;            Trsv            ( UPPER, NORMAL, diag,              U11_STAR_STAR.LockedLocalMatrix(),              x1_STAR_STAR.LocalMatrix() );            x1 = x1_STAR_STAR;            x1_MR_STAR = x1_STAR_STAR;            Gemv            ( NORMAL, F(-1),               U01.LockedLocalMatrix(),               x1_MR_STAR.LockedLocalMatrix(),              F(1), z0_MC_STAR.LocalMatrix() );            //----------------------------------------------------------------//            x1_MR_STAR.FreeAlignments();            SlidePartitionUp            ( xT,  x0,             /**/ /**/                   x1,              xB,  x2 );        }    }    else    {        // Matrix views         DistMatrix<F> U01(g),                      U11(g);        DistMatrix<F>             xL(g), xR(g),            x0(g), x1(g), x2(g);        // Temporary distributions        DistMatrix<F,STAR,STAR> U11_STAR_STAR(g);        DistMatrix<F,STAR,STAR> x1_STAR_STAR(g);//.........这里部分代码省略.........
开发者ID:jimgoo,项目名称:Elemental,代码行数:101,


示例20: ASSERTL0

        void Forcing::EvaluateFunction(                Array<OneD, MultiRegions::ExpListSharedPtr>       pFields,                LibUtilities::SessionReaderSharedPtr              pSession,                std::string                                       pFieldName,                Array<OneD, NekDouble>&                           pArray,                const std::string&                                pFunctionName,                NekDouble                                         pTime)        {            ASSERTL0(pSession->DefinesFunction(pFunctionName),                     "Function '" + pFunctionName + "' does not exist.");            unsigned int nq = pFields[0]->GetNpoints();            if (pArray.num_elements() != nq)            {                pArray = Array<OneD, NekDouble> (nq);            }            LibUtilities::FunctionType vType;            vType = pSession->GetFunctionType(pFunctionName, pFieldName);            if (vType == LibUtilities::eFunctionTypeExpression)            {                Array<OneD, NekDouble> x0(nq);                Array<OneD, NekDouble> x1(nq);                Array<OneD, NekDouble> x2(nq);                pFields[0]->GetCoords(x0, x1, x2);                LibUtilities::EquationSharedPtr ffunc =                        pSession->GetFunction(pFunctionName, pFieldName);                ffunc->Evaluate(x0, x1, x2, pTime, pArray);            }            else if (vType == LibUtilities::eFunctionTypeFile)            {                std::string filename = pSession->GetFunctionFilename(                                                    pFunctionName,                                                    pFieldName);                std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;                std::vector<std::vector<NekDouble> > FieldData;                Array<OneD, NekDouble> vCoeffs(pFields[0]->GetNcoeffs());                Vmath::Zero(vCoeffs.num_elements(), vCoeffs, 1);                LibUtilities::FieldIOSharedPtr fld =                    MemoryManager<LibUtilities::FieldIO>::AllocateSharedPtr(m_session->GetComm());                fld->Import(filename, FieldDef, FieldData);                int idx = -1;                for (int i = 0; i < FieldDef.size(); ++i)                {                    for (int j = 0; j < FieldDef[i]->m_fields.size(); ++j)                    {                        if (FieldDef[i]->m_fields[j] == pFieldName)                        {                            idx = j;                        }                    }                    if (idx >= 0)                    {                        pFields[0]->ExtractDataToCoeffs(                                                    FieldDef[i],                                                    FieldData[i],                                                    FieldDef[i]->m_fields[idx],                                                    vCoeffs);                    }                    else                    {                        cout << "Field " + pFieldName + " not found." << endl;                    }                }                pFields[0]->BwdTrans_IterPerExp(vCoeffs, pArray);            }        }
开发者ID:gaoak,项目名称:nektar,代码行数:73,


示例21: return

bool SVGLineElement::hasRelativeValues() const{    return (x1().isRelative() || y1().isRelative() ||            x2().isRelative() || y2().isRelative());}
开发者ID:Chingliu,项目名称:EAWebkit,代码行数:5,


示例22: y1

Path SVGLineElement::toPathData() const{    return Path::createLine(FloatPoint(x1().value(), y1().value()),                            FloatPoint(x2().value(), y2().value()));}
开发者ID:Chingliu,项目名称:EAWebkit,代码行数:5,


示例23: font

void MathPlot::setupMultiAxisDemo(QCustomPlot *customPlot){  customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);  customPlot->setLocale(QLocale(QLocale::English, QLocale::UnitedKingdom)); // period as decimal separator and comma as thousand separator  customPlot->legend->setVisible(true);  QFont legendFont = font();  // start out with MainWindow's font..  legendFont.setPointSize(9); // and make a bit smaller for legend  customPlot->legend->setFont(legendFont);  customPlot->legend->setBrush(QBrush(QColor(255,255,255,230)));  // by default, the legend is in the inset layout of the main axis rect. So this is how we access it to change legend placement:  customPlot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignBottom|Qt::AlignRight);  // setup for graph 0: key axis left, value axis bottom  // will contain left maxwell-like function  customPlot->addGraph(customPlot->yAxis, customPlot->xAxis);  customPlot->graph(0)->setPen(QPen(QColor(255, 100, 0)));  customPlot->graph(0)->setBrush(QBrush(QPixmap("://skin/images/balboa.jpg"))); // fill with texture of specified image  customPlot->graph(0)->setLineStyle(QCPGraph::lsLine);  customPlot->graph(0)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 5));  customPlot->graph(0)->setName("Left maxwell function");  // setup for graph 1: key axis bottom, value axis left (those are the default axes)  // will contain bottom maxwell-like function  customPlot->addGraph();  customPlot->graph(1)->setPen(QPen(Qt::red));  customPlot->graph(1)->setBrush(QBrush(QPixmap("://skin/images/balboa.jpg"))); // same fill as we used for graph 0  customPlot->graph(1)->setLineStyle(QCPGraph::lsStepCenter);  customPlot->graph(1)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, Qt::red, Qt::white, 7));  customPlot->graph(1)->setErrorType(QCPGraph::etValue);  customPlot->graph(1)->setName("Bottom maxwell function");  // setup for graph 2: key axis top, value axis right  // will contain high frequency sine with low frequency beating:  customPlot->addGraph(customPlot->xAxis2, customPlot->yAxis2);  customPlot->graph(2)->setPen(QPen(Qt::blue));  customPlot->graph(2)->setName("High frequency sine");  // setup for graph 3: same axes as graph 2  // will contain low frequency beating envelope of graph 2  customPlot->addGraph(customPlot->xAxis2, customPlot->yAxis2);  QPen blueDotPen;  blueDotPen.setColor(QColor(30, 40, 255, 150));  blueDotPen.setStyle(Qt::DotLine);  blueDotPen.setWidthF(4);  customPlot->graph(3)->setPen(blueDotPen);  customPlot->graph(3)->setName("Sine envelope");  // setup for graph 4: key axis right, value axis top  // will contain parabolically distributed data points with some random perturbance  customPlot->addGraph(customPlot->yAxis2, customPlot->xAxis2);  customPlot->graph(4)->setPen(QColor(50, 50, 50, 255));  customPlot->graph(4)->setLineStyle(QCPGraph::lsNone);  customPlot->graph(4)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, 4));  customPlot->graph(4)->setName("Some random data around/na quadratic function");  // generate data, just playing with numbers, not much to learn here:  QVector<double> x0(25), y0(25);  QVector<double> x1(15), y1(15), y1err(15);  QVector<double> x2(250), y2(250);  QVector<double> x3(250), y3(250);  QVector<double> x4(250), y4(250);  for (int i=0; i<25; ++i) // data for graph 0  {    x0[i] = 3*i/25.0;    y0[i] = exp(-x0[i]*x0[i]*0.8)*(x0[i]*x0[i]+x0[i]);  }  for (int i=0; i<15; ++i) // data for graph 1  {    x1[i] = 3*i/15.0;;    y1[i] = exp(-x1[i]*x1[i])*(x1[i]*x1[i])*2.6;    y1err[i] = y1[i]*0.25;  }  for (int i=0; i<250; ++i) // data for graphs 2, 3 and 4  {    x2[i] = i/250.0*3*M_PI;    x3[i] = x2[i];    x4[i] = i/250.0*100-50;    y2[i] = sin(x2[i]*12)*cos(x2[i])*10;    y3[i] = cos(x3[i])*10;    y4[i] = 0.01*x4[i]*x4[i] + 1.5*(rand()/(double)RAND_MAX-0.5) + 1.5*M_PI;  }  // pass data points to graphs:  customPlot->graph(0)->setData(x0, y0);  customPlot->graph(1)->setDataValueError(x1, y1, y1err);  customPlot->graph(2)->setData(x2, y2);  customPlot->graph(3)->setData(x3, y3);  customPlot->graph(4)->setData(x4, y4);  // activate top and right axes, which are invisible by default:  customPlot->xAxis2->setVisible(true);  customPlot->yAxis2->setVisible(true);  // set ranges appropriate to show data:  customPlot->xAxis->setRange(0, 2.7);  customPlot->yAxis->setRange(0, 2.6);  customPlot->xAxis2->setRange(0, 3.0*M_PI);  customPlot->yAxis2->setRange(-70, 35);  // set pi ticks on top axis:  QVector<double> piTicks;  QVector<QString> piLabels;//.........这里部分代码省略.........
开发者ID:zhoajianjun,项目名称:QT,代码行数:101,


示例24: createmodel

// This function creates the following model://   Minimize//    obj: x1 + x2 + x3 + x4 + x5 + x6//   Subject To//    c1: x1 + x2      + x5      = 8//    c2:           x3 + x5 + x6 = 10//    q1: [ -x1^2 + x2^2 + x3^2 ] <= 0//    q2: [ -x4^2 + x5^2 ] <= 0//   Bounds//    x2 Free//    x3 Free//    x5 Free//   End// which is a second order cone program in standard form.// The function returns objective, variables and constraints in the// values obj, vars and rngs.// The function also sets up cone so that for a column j we have// cone[j] >= 0               Column j is in a cone constraint and is the//                            cone's head variable.// cone[j] == NOT_CONE_HEAD   Column j is in a cone constraint but is//                            not the cone's head variable..// cone[j] == NOT_IN_CONE     Column j is not contained in any cone constraint.static voidcreatemodel (IloModel& model, IloObjective &obj, IloNumVarArray &vars,             IloRangeArray &rngs, IloIntArray& cone){   // The indices we assign as user objects to the modeling objects.   // We define them as static data so that we don't have to worry about   // dynamic memory allocation/leakage.   static int indices[] = { 0, 1, 2, 3, 4, 5, 6 };   IloEnv env = model.getEnv();   // Create variables.   IloNumVar x1(env,            0, IloInfinity, "x1");   IloNumVar x2(env, -IloInfinity, IloInfinity, "x2");   IloNumVar x3(env, -IloInfinity, IloInfinity, "x3");   IloNumVar x4(env,            0, IloInfinity, "x4");   IloNumVar x5(env, -IloInfinity, IloInfinity, "x5");   IloNumVar x6(env,            0, IloInfinity, "x6");   // Create objective function and immediately store it in return value.   obj = IloMinimize(env, x1 + x2 + x3 + x4 + x5 + x6);   // Create constraints.   IloRange c1(env, 8,  x1 + x2      + x5,       8, "c1");   IloRange c2(env, 10,           x3 + x5 + x6, 10, "c2");   IloRange q1(env, -IloInfinity, -x1*x1 + x2*x2 + x3*x3, 0, "q1");   cone.add(2);             // x1, cone head of constraint at index 2   cone.add(NOT_CONE_HEAD); // x2   cone.add(NOT_CONE_HEAD); // x3   IloRange q2(env, -IloInfinity, -x4*x4 + x5*x5, 0, "q2");   cone.add(3);             // x4, cone head of constraint at index 3   cone.add(NOT_CONE_HEAD); // x5   cone.add(NOT_IN_CONE);   // x6   // Setup model.   model.add(obj);   model.add(obj);   model.add(c1);   model.add(c2);   model.add(q1);   model.add(q2);   // Setup return values.   vars.add(x1);   vars.add(x2);   vars.add(x3);   vars.add(x4);   vars.add(x5);   vars.add(x6);   rngs.add(c1);   rngs.add(c2);   rngs.add(q1);   rngs.add(q2);   // We set the user object for each modeling object to its index in the   // respective array. This makes the code in checkkkt a little simpler.   for (IloInt i = 0; i < vars.getSize(); ++i)      vars[i].setObject(&indices[i]);   for (IloInt i = 0; i < rngs.getSize(); ++i)      rngs[i].setObject(&indices[i]);}
开发者ID:renvieir,项目名称:ioc,代码行数:85,


示例25: trial_slave

// Private methods// determine the slave/master pair in contact, and setup Vectors (N,T1,T2)int ZeroLengthInterface2D::contactDetect(int s, int m1, int m2, int stage){  //+--------------+-----------------+----------------+----------------+---------------+  // NOTES: some methods to get displacements from nodes  //+--------------+-----------------+----------------+----------------+---------------+  // getDisp() :         get commit(k-1) disp, will be commit(k) after commit  // getTrialDisp():     get Trial(k) disp  // getIncrDisp():      get Trial(k)-Commit(k-1), will be 0 after commit  // getIncrDeltaDisp(): get Trial(k)-Trial(k-1),  will be 0 after commit  //+--------------+-----------------+----------------+----------------+--------------  ////////////////////////////// for transient gap ///////////////////////////////////  // DEFINE:  // gap = (U_master-U_slave) / dot(ContactNormal),  // defines overlapped normal distance, always keep positive (+) when contacted  ///*  // get current position and after trial displacement for (slave, master1, master2) nodes  int i;  const Vector &xs = nodePointers[s]->getCrds();  const Vector &uxs = nodePointers[s]->getTrialDisp();  const Vector &x1 = nodePointers[m1]->getCrds();  const Vector &ux1= nodePointers[m1]->getTrialDisp();  const Vector &x2 = nodePointers[m2]->getCrds();  const Vector &ux2= nodePointers[m2]->getTrialDisp();    Vector trial_slave(2), trial_master1(2), trial_master2(2);  for (i = 0; i < 2; i++) {    trial_slave(i) = xs(i) + uxs(i);    trial_master1(i) = x1(i) + ux1(i);    trial_master2(i) = x2(i) + ux2(i);    //opserr << "trial_slave: " << trial_slave(i) << "/n";    //opserr << "trial_master1: " << trial_master1(i) << "/n";    //opserr << "trial_master2: " << trial_master2(i) << "/n";  }    // calculate normal gap for contact  Vector diff(2);  Vector ContactTangent(2);  for (i = 0; i < 2; i++) {    diff(i) = trial_master2(i) - trial_master1(i);    //opserr << "diff: " << diff(i) << "/n";  }  double L  = diff.Norm();  // tangent vector  for (i = 0; i < 2; i++) ContactTangent(i) = (1/L) * (trial_master2(i) - trial_master1(i));  // normal vector  ContactNormal(0) = - ContactTangent(1);  ContactNormal(1) = ContactTangent(0);    normal_gap(s) = 0;  double alpha = 0;  double alpha_bar = 0;  for (i = 0; i < 2; i++) {    alpha += (1/L) * (trial_slave(i) - trial_master1(i)) * ContactTangent(i);    normal_gap(s) += (trial_slave(i) - trial_master1(i)) * ContactNormal(i);    diff(i) = x2(i) - x1(i);  }    double gapgap = normal_gap(s);    double L_bar = diff.Norm();  for (i = 0; i < 2; i++) alpha_bar += (1/L_bar) * (xs(i) - x1(i)) * ContactTangent(i);  shear_gap(s) = (alpha - alpha_bar) * L_bar;  /*    /////////////////////////////// for transient gap ///////////////////////////////    // we have another way to define the gap, can replace previous code block if want    ////////////////////////////// for dynamic gap //////////////////////////////////    const Vector   // get current trial incremental position    &U_slave = nodePointers[0]->getCrds() + nodePointers[0]->getIncrDisp();    const Vector    &U_master= nodePointers[1]->getCrds() + nodePointers[1]->getIncrDisp();    gap=0;    int i;    for (i=0; i<2; i++){    gap += (U_master(i)-U_slave(i))* ContactNormal(i);    }    gap+=gap_n;    ///////////////// for dynamic gap //////////////////////    */  // stage = 0 means searching slave nodes against master segments  // stage = 1 means searching master nodes against slave segments  if ((stage == 0  && normal_gap(s) >= 0 && alpha > 0 && alpha < 1) ||      (stage == 1  && normal_gap(s) >= 0 && alpha >= 0 && alpha <= 1)) { // in contact    N(0) = ContactNormal(0);    N(1) = ContactNormal(1);    N(2) = -(1 - alpha) * N(0);    N(3) = -(1 - alpha) * N(1);    N(4) = -(alpha) * N(0);    N(5) = -(alpha) * N(1);        T(0) = ContactTangent(0);    T(1) = ContactTangent(1);    T(2) = -(1-alpha) * T(0);    T(3) = -(1-alpha) * T(1);    T(4) = -(alpha) * T(0);    T(5) = -(alpha) * T(1);        return 1;  } else {//.........这里部分代码省略.........
开发者ID:DBorello,项目名称:OpenSees,代码行数:101,


示例26: doLagrangianPhase

voidLEPlic :: doLagrangianPhase(TimeStep *atTime){    //Maps element nodes along trajectories using basic Runge-Kutta method (midpoint rule)    int i, ci, ndofman = domain->giveNumberOfDofManagers();    int nsd = 2;    double dt = atTime->giveTimeIncrement();    DofManager *dman;    Node *inode;    IntArray velocityMask;    FloatArray x, x2(nsd), v_t, v_tn1;    FloatMatrix t;#if 1    EngngModel *emodel = domain->giveEngngModel();    int err;#endif    velocityMask.setValues(2, V_u, V_v);    updated_XCoords.resize(ndofman);    updated_YCoords.resize(ndofman);    for ( i = 1; i <= ndofman; i++ ) {        dman = domain->giveDofManager(i);        // skip dofmanagers with no position information        if ( ( dman->giveClassID() != NodeClass ) && ( dman->giveClassID() != RigidArmNodeClass ) && ( dman->giveClassID() != HangingNodeClass ) ) {            continue;        }        inode = ( Node * ) dman;        // get node coordinates        x = * ( inode->giveCoordinates() );        // get velocity field v(tn, x(tn)) for dof manager#if 1        /* Original version */        dman->giveUnknownVector( v_t, velocityMask, EID_MomentumBalance, VM_Total, atTime->givePreviousStep() );        /* Modified version */        //dman->giveUnknownVector(v_t, velocityMask, EID_MomentumBalance, VM_Total, atTime);        // Original version        // compute updated position x(tn)+0.5*dt*v(tn,x(tn))        for ( ci = 1; ci <= nsd; ci++ ) {            x2.at(ci) = x.at(ci) + 0.5 *dt *v_t.at(ci);        }        // compute interpolated velocity field at x2 [ v(tn+1, x(tn)+0.5*dt*v(tn,x(tn))) = v(tn+1, x2) ]        Field *vfield;        vfield = emodel->giveContext()->giveFieldManager()->giveField(FT_Velocity);        if ( vfield == NULL ) {            _error("doLagrangianPhase: Velocity field not available");        }        err = vfield->evaluateAt(v_tn1, x2, VM_Total, atTime);        if ( err == 1 ) {            // point outside domain -> be explicit            v_tn1 = v_t;        } else if ( err != 0 ) {            _error2("doLagrangianPhase: vfield->evaluateAt failed, error code %d", err);        }        // compute final updated position        for ( ci = 1; ci <= nsd; ci++ ) {            x2.at(ci) = x.at(ci) + dt *v_tn1.at(ci);        }#else        // pure explicit version        dman->giveUnknownVector(v_t, velocityMask, EID_MomentumBalance, VM_Total, atTime);        for ( ci = 1; ci <= nsd; ci++ ) {            x2.at(ci) = x.at(ci) + dt *v_t.at(ci);        }#endif        // store updated node position        updated_XCoords.at(i) = x2.at(1);        updated_YCoords.at(i) = x2.at(2);    }}
开发者ID:JimBrouzoulis,项目名称:oofem-1,代码行数:80,


示例27: x1

void VCharUnit::run() {    VChar    x1('x');    VChar    x2(0x78);    VUNIT_ASSERT_EQUAL_LABELED(x1, 'x', "character ctor");    VUNIT_ASSERT_EQUAL_LABELED(x2, 'x', "integer ctor");    VUNIT_ASSERT_EQUAL_LABELED(x1, x2, "ctor equality");    x1 = 'y';    x2 = 0x79;    VUNIT_ASSERT_EQUAL_LABELED(x1, 'y', "character assignment");    VUNIT_ASSERT_EQUAL_LABELED(x2, 'y', "integer assignment");    VUNIT_ASSERT_EQUAL_LABELED(x1, x2, "assignment equality");    x1 = 'a';    VUNIT_ASSERT_TRUE_LABELED(x1.isLowerCase(), "lower case");    VUNIT_ASSERT_TRUE_LABELED(! x1.isUpperCase(), "not upper case");    x2 = 'A';    VUNIT_ASSERT_TRUE_LABELED(! x2.isLowerCase(), "not lower case");    VUNIT_ASSERT_TRUE_LABELED(x2.isUpperCase(), "upper case");    x2.toLowerCase();    VUNIT_ASSERT_TRUE_LABELED(x2.isLowerCase(), "to lower case");    VUNIT_ASSERT_EQUAL_LABELED(x2, x1, "to lower case equality");    x1.toUpperCase();    VUNIT_ASSERT_TRUE_LABELED(x1.isUpperCase(), "to upper case");    VUNIT_ASSERT_EQUAL_LABELED(x1, 'A', "to upper case equality");    x1 = 'b';    VChar bigB = x1.upperCase();    VUNIT_ASSERT_EQUAL_LABELED(bigB, 'B', "return upper case");    VChar littleB = bigB.lowerCase();    VUNIT_ASSERT_EQUAL_LABELED(littleB, 'b', "return lower case");    VUNIT_ASSERT_EQUAL_LABELED(littleB.charValue(), 'b', "char value");    VUNIT_ASSERT_EQUAL_LABELED(littleB.intValue(), 0x62, "int value");    x1.set('c');    VUNIT_ASSERT_EQUAL_LABELED(x1, 'c', "set char");    x1.set(0x64);    VUNIT_ASSERT_EQUAL_LABELED(x1, 'd', "set int");    x1 = 'd';    char littleD = x1;    VUNIT_ASSERT_EQUAL_LABELED(littleD, 'd', "operator char");    VChar    i1('i');    VChar    i2('i');    VChar    j1('j');    VChar    j2('j');    VUNIT_ASSERT_TRUE_LABELED(i1 != j1, "inequality");    VUNIT_ASSERT_TRUE_LABELED(i1 < j1, "LT");    VUNIT_ASSERT_TRUE_LABELED(!(i1 < i2), "not LT");    VUNIT_ASSERT_TRUE_LABELED(j1 > i1, "GT");    VUNIT_ASSERT_TRUE_LABELED(!(j1 > j2), "not GT");    VUNIT_ASSERT_TRUE_LABELED(i1 <= i2, "LTE 1");    VUNIT_ASSERT_TRUE_LABELED(i1 <= j1, "LTE 2");    VUNIT_ASSERT_TRUE_LABELED(j1 >= j2, "GTE 1");    VUNIT_ASSERT_TRUE_LABELED(j1 >= i1, "GTE 2");    VUNIT_ASSERT_TRUE_LABELED(!(j1 <= i1), "not LTE");    VUNIT_ASSERT_TRUE_LABELED(!(i1 >= j1), "not GTE");    VUNIT_ASSERT_TRUE_LABELED(VChar::equalsIgnoreCase(VChar('x'), VChar('X')), "equalsIgnoreCase 1");    VUNIT_ASSERT_TRUE_LABELED(VChar::equalsIgnoreCase('x', VChar('X')), "equalsIgnoreCase 2");    VUNIT_ASSERT_TRUE_LABELED(VChar::equalsIgnoreCase(VChar('x'), 'X'), "equalsIgnoreCase 3");    VUNIT_ASSERT_TRUE_LABELED(VChar::equalsIgnoreCase('x', 'X'), "equalsIgnoreCase 4");    VUNIT_ASSERT_TRUE_LABELED(VChar::equalsIgnoreCase(VChar('5'), VChar('5')), "equalsIgnoreCase 5"); // test numbers    VUNIT_ASSERT_TRUE_LABELED(VChar::equalsIgnoreCase(VChar('!'), VChar('!')), "equalsIgnoreCase 6"); // test punctuation    VUNIT_ASSERT_TRUE_LABELED(VChar::equalsIgnoreCase(VChar(' '), VChar(' ')), "equalsIgnoreCase 7"); // test whitespace    VUNIT_ASSERT_FALSE_LABELED(VChar::equalsIgnoreCase(VChar('x'), VChar('y')), "!equalsIgnoreCase 1");    VUNIT_ASSERT_FALSE_LABELED(VChar::equalsIgnoreCase('x', VChar('y')), "!equalsIgnoreCase 2");    VUNIT_ASSERT_FALSE_LABELED(VChar::equalsIgnoreCase(VChar('x'), 'y'), "!equalsIgnoreCase 3");    VUNIT_ASSERT_FALSE_LABELED(VChar::equalsIgnoreCase('x', 'y'), "!equalsIgnoreCase 4");    VUNIT_ASSERT_FALSE_LABELED(VChar::equalsIgnoreCase(VChar('5'), VChar('6')), "!equalsIgnoreCase 5"); // test numbers    VUNIT_ASSERT_FALSE_LABELED(VChar::equalsIgnoreCase(VChar('!'), VChar('@')), "!equalsIgnoreCase 6"); // test punctuation    VUNIT_ASSERT_FALSE_LABELED(VChar::equalsIgnoreCase(VChar(' '), VChar('/t')), "!equalsIgnoreCase 7"); // test whitespace    // Test the known ranges of alpha/numeric/whitespace values.    for (int i = 0; i < 256; ++i) {        VChar    c(i);        if ((i <= 0x20) || (i == 0x7F)) {            // This is the range VChar considers "whitespace".            this->test(                !c.isLowerCase() &&                !c.isUpperCase() &&                (c.intValue() == i) &&                !c.isAlpha() &&                !c.isNumeric() &&                !c.isAlphaNumeric() &&                c.isWhitespace(),                VSTRING_FORMAT("%d char properties", i));        } else if (i <= 0x2F) {            // This is all punctuation.            this->test(                !c.isLowerCase() &&                !c.isUpperCase() &&                (c.intValue() == i) &&                !c.isAlpha() &&                !c.isNumeric() &&                !c.isAlphaNumeric() &&                !c.isWhitespace(),//.........这里部分代码省略.........
开发者ID:JohnChristman,项目名称:code-vault,代码行数:101,


示例28: ApplyNonMaximumSuppresion

void ApplyNonMaximumSuppresion(std::vector< kstate >& in_source, float in_nms_threshold){	std::vector< kstate > tmp_source = in_source;	if (tmp_source.empty())		return ;	unsigned int size = in_source.size();	std::vector<float> area(size);	std::vector<float> scores(size);	std::vector<int> x1(size);	std::vector<int> y1(size);	std::vector<int> x2(size);	std::vector<int> y2(size);	std::vector<unsigned int> indices(size);	std::vector<bool> is_suppresed(size);	for(unsigned int i = 0; i< in_source.size(); i++)	{		kstate tmp = in_source[i];		area[i] = tmp.pos.width * tmp.pos.height;		indices[i] = i;		is_suppresed[i] = false;		scores[i] = tmp.score;		x1[i] = tmp.pos.x;		y1[i] = tmp.pos.y;		x2[i] = tmp.pos.width + tmp.pos.x;		y2[i] = tmp.pos.height + tmp.pos.y;	}	Sort(scores, indices);//returns indices ordered based on scores	for(unsigned int i=0; i< size; i++)	{		if(!is_suppresed[indices[i]])		{			for(unsigned int j= i+1; j< size; j++)			{				int x1_max = std::max(x1[indices[i]], x1[indices[j]]);				int x2_min = std::min(x2[indices[i]], x2[indices[j]]);				int y1_max = std::max(y1[indices[i]], y1[indices[j]]);				int y2_min = std::min(y2[indices[i]], y2[indices[j]]);				int overlap_width = x2_min - x1_max + 1;				int overlap_height = y2_min - y1_max + 1;				if(overlap_width > 0 && overlap_height>0)				{					float overlap_part = (overlap_width*overlap_height)/area[indices[j]];					if(overlap_part > in_nms_threshold)					{						is_suppresed[indices[j]] = true;					}				}			}		}	}	unsigned int size_out = 0;	for (unsigned int i = 0; i < size; i++)	{		if (!is_suppresed[i])			size_out++;	}	std::vector< kstate > filtered_detections(size_out);	unsigned int index = 0;	for(unsigned int i = 0 ; i < size_out; i++)	{		if(!is_suppresed[indices[i]])		{			filtered_detections[index] = in_source[indices[i]];//x1[indices[i]];			index++;		}	}	in_source = filtered_detections;}
开发者ID:CSL-KU,项目名称:Autoware,代码行数:77,


示例29: printf

//.........这里部分代码省略.........     double zeta = zsize_;     if (zeta == 0) zeta = 1; // zeta scales y, z.     double theta  = beta * zeta;                          // theta scales obj.     // (theta could be anything, but theta = beta*zeta makes     // scaled grad = grad/zeta = 1 approximately if zeta is chosen right.)     for (int k = 0; k < nlow; k++)          bl_elts[low[k]] = bl_elts[low[k]] / beta;     for (int k = 0; k < nupp; k++)          bu_elts[upp[k]] = bu_elts[upp[k]] / beta;     d1     = d1 * ( beta / sqrt(theta) );     d2     = d2 * ( sqrt(theta) / beta );     double beta2  = beta * beta;     b.scale( (1.0 / beta) );     y.scale( (1.0 / zeta) );     x.scale( (1.0 / beta) );     z.scale( (1.0 / zeta) );     //---------------------------------------------------------------------     // Initialize vectors that are not fully used if bounds are missing.     //---------------------------------------------------------------------     CoinDenseVector<double> rL(n, 0.0);     CoinDenseVector<double> cL(n, 0.0);     CoinDenseVector<double> z1(n, 0.0);     CoinDenseVector<double> dx1(n, 0.0);     CoinDenseVector<double> dz1(n, 0.0);     CoinDenseVector<double> r2(n, 0.0);     // Assign upper bd regions (dummy if no UBs)     CoinDenseVector<double> rU(nU, 0.0);     CoinDenseVector<double> cU(nU, 0.0);     CoinDenseVector<double> x2(nU, 0.0);     CoinDenseVector<double> z2(nU, 0.0);     CoinDenseVector<double> dx2(nU, 0.0);     CoinDenseVector<double> dz2(nU, 0.0);     //---------------------------------------------------------------------     // Initialize x, y, z, objective, etc.     //---------------------------------------------------------------------     CoinDenseVector<double> dx(n, 0.0);     CoinDenseVector<double> dy(m, 0.0);     CoinDenseVector<double> Pr(m);     CoinDenseVector<double> D(n);     double *D_elts = D.getElements();     CoinDenseVector<double> w(n);     double *w_elts = w.getElements();     CoinDenseVector<double> rhs(m + n);     //---------------------------------------------------------------------     // Pull out the element array pointers for efficiency     //---------------------------------------------------------------------     double *x_elts  = x.getElements();     double *x2_elts = x2.getElements();     double *z_elts  = z.getElements();     double *z1_elts = z1.getElements();     double *z2_elts = z2.getElements();     for (int k = 0; k < nlow; k++) {          x_elts[low[k]]  = CoinMax( x_elts[low[k]], bl[low[k]]);          x1_elts[low[k]] = CoinMax( x_elts[low[k]] - bl[low[k]], x0min  );          z1_elts[low[k]] = CoinMax( z_elts[low[k]], z0min  );     }     for (int k = 0; k < nupp; k++) {
开发者ID:ebshimizu,项目名称:Lumiverse,代码行数:67,



注:本文中的x2函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ x25_type_trans函数代码示例
C++ x0函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。