Ejemplo n.º 1
0
Surface::Surface(const QString &equation, qreal a, QObject *parent)
  : QObject(parent), privateMemberLock(QReadWriteLock::Recursive)
{
  construct();
  setEquation(equation);
  setA(a);
}
Ejemplo n.º 2
0
void control::event2() {
    setA(false);
    setC(true);
    qDebug() << "Plastic Bottling Size Reached";
    qDebug() << "Molding Bottle";
    QTimer::singleShot(500, this, SLOT(event3()));
}
Ejemplo n.º 3
0
int main() {
  double dr = 1.0 / (double) R;
  double dt = 0.0001;
  double mu = 0.5 * dt / (dr*dr);
  int i = 0;
  
  double U[(R+1)*(R+1)];
  double b[(R+1)*(R+1)];

  double du[R];
  double dc[R+1];
  double dl[R];

  printf("mu = %.5lf\n", mu);
  
  setInitialCondition(U, (R+1), (R+1), dr);
  setA(du, dc, dl, (R+1), (R+1), mu);
  dumpMatrix(U, (R+1), (R+1), dr, 0);

  while (i++ < 5) {
    diffuse(U, b, (R+1), (R+1), du, dc, dl, mu);
    dumpMatrix(U, (R+1), (R+1), dr, i);
  }
  
}
Ejemplo n.º 4
0
// Set from Botan representation
void BotanEDPublicKey::setFromBotan(const Botan::Public_Key* inEDKEY)
{
	Botan::OID oid;
	std::vector<uint8_t> pub;

	for (;;)
	{
		const Botan::Curve25519_PublicKey* x25519 = dynamic_cast<const Botan::Curve25519_PublicKey*>(inEDKEY);
		if (x25519) {
			oid = x25519_oid;
			pub = x25519->public_value();
			break;
		}
		const Botan::Ed25519_PublicKey* ed25519 = dynamic_cast<const Botan::Ed25519_PublicKey*>(inEDKEY);
		if (ed25519) {
			oid = ed25519_oid;
			pub = ed25519->get_public_key();
			break;
		}
		return;
	}
	ByteString inEC = BotanUtil::oid2ByteString(oid);
	setEC(inEC);
	ByteString inA;
	inA.resize(pub.size());
	memcpy(&inA[0], &pub[0], pub.size());
	setA(DERUTIL::raw2Octet(inA));
}
Ejemplo n.º 5
0
//------------------------------------------------------------------------------
// Slot functions
//------------------------------------------------------------------------------
bool EarthModel::setSlotA(const Distance* const msg)
{
   bool ok = false;
   if (msg != nullptr) {
      ok = setA( Meters::convertStatic( *msg ) );
   }
   return ok;
}
Ejemplo n.º 6
0
bool EarthModel::setSlotA(const Number* const msg)
{
   bool ok = false;
   if (msg != nullptr) {
      ok = setA( msg->getDouble() );
   }
   return ok;
}
Ejemplo n.º 7
0
Quaternion::Quaternion() :
	Vector(4)
{
	setA(1.0f);
	setB(0.0f);
	setC(0.0f);
	setD(0.0f);
}
TransformationMatrix::TransformationMatrix(const CGAffineTransform& t)
{
    setA(t.a);
    setB(t.b);
    setC(t.c);
    setD(t.d);
    setE(t.tx);
    setF(t.ty);
}
Ejemplo n.º 9
0
Quaternion::Quaternion(float a, float b,
		       float c, float d) :
	Vector(4)
{
	setA(a);
	setB(b);
	setC(c);
	setD(d);
}
Ejemplo n.º 10
0
int main(void)
{
	if (b == 0)
		setB();
	if (a == 0)
		setA();

	assert(a == 1);
	return 0;
}
Ejemplo n.º 11
0
Quaternion::Quaternion(const Dcm &dcm) :
	Vector(4)
{
	setA(0.5f * sqrtf(1 + dcm(0, 0) +
			  dcm(1, 1) + dcm(2, 2)));
	setB((dcm(2, 1) - dcm(1, 2)) /
	     (4 * getA()));
	setC((dcm(0, 2) - dcm(2, 0)) /
	     (4 * getA()));
	setD((dcm(1, 0) - dcm(0, 1)) /
	     (4 * getA()));
}
Ejemplo n.º 12
0
MEvent::MEvent(unsigned tick, int port, int channel, const Event& e, MidiTrack* trk)
{
    m_track = trk;
    m_source = SystemSource;
    setChannel(channel);
    setTime(tick);
    setPort(port);
    setLoopNum(0);
    switch (e.type())
    {
        case Note:
            setType(ME_NOTEON);
            setA(e.dataA());
            setB(e.dataB());
            break;
        case Controller:
            setType(ME_CONTROLLER);
            setA(e.dataA()); // controller number
            setB(e.dataB()); // controller value
            break;
        case PAfter:
            setType(ME_POLYAFTER);
            setA(e.dataA());
            setB(e.dataB());
            break;
        case CAfter:
            setType(ME_AFTERTOUCH);
            setA(e.dataA());
            setB(0);
            break;
        case Sysex:
            setType(ME_SYSEX);
            setData(e.eventData());
            break;
        default:
            printf("MEvent::MEvent(): event type %d not implemented\n",
                    type());
            break;
    }
}
Ejemplo n.º 13
0
 void Triangle::configure(const std::string& parameters) {
     if (parameters.empty()) return;
     std::vector<std::string> values = Op::split(parameters, " ");
     std::size_t required = 3;
     if (values.size() < required) {
         std::ostringstream ex;
         ex << "[configuration error] term <" << className() << ">"
                 << " requires <" << required << "> parameters";
         throw fl::Exception(ex.str(), FL_AT);
     }
     setA(Op::toScalar(values.at(0)));
     setB(Op::toScalar(values.at(1)));
     setC(Op::toScalar(values.at(2)));
 }
Ejemplo n.º 14
0
Quaternion::Quaternion(const Dcm &dcm) :
	Vector(4)
{
	// avoiding singularities by not using
	// division equations
	setA(0.5 * sqrt(1.0 +
			double(dcm(0, 0) + dcm(1, 1) + dcm(2, 2))));
	setB(0.5 * sqrt(1.0 +
			double(dcm(0, 0) - dcm(1, 1) - dcm(2, 2))));
	setC(0.5 * sqrt(1.0 +
			double(-dcm(0, 0) + dcm(1, 1) - dcm(2, 2))));
	setD(0.5 * sqrt(1.0 +
			double(-dcm(0, 0) - dcm(1, 1) + dcm(2, 2))));
}
Ejemplo n.º 15
0
	/*
	 * What is the mean of your score if N=SOMETHING
	 * What is the standard deviation of your score if N=SOMETHING
	 */
	void play_optimize(int nTrial){
		const int nT = nTrial;
		const int original_valA = cards[0];
		setA(1);
		T totalScore =0;
		for(; nTrial > 0 ; nTrial--){
			//drawn cards using A=1
			std::vector<int> trialCard;
			T point_one=0;
			T numC_one = 0;
			T num_aces=0;
			for(; point_one < N ; numC_one++){
				uint c = getCard();
				point_one+=c;
				trialCard.push_back(c);
				if(c==1)
					num_aces++;
			}
			//print(trialCard.begin(),trialCard.end());
			//printf("\tnum_extractions %i, num_aces = %i, point %i\n",numC_one,num_aces,point_one);
			int bestVal = computeBestScore(trialCard,0,0);

			T trialScore = (bestVal-N);
			data.push_back(trialScore);
			totalScore+=trialScore;
			//printf("BEST VALUE %i score = %i \n",bestVal,trialScore);
			//printf("%i,",trialScore);
		}//for trials

		mean = (double)totalScore/(double)nT;
		stdev= std::sqrt(computeVariance(data));

		printf("\tN=%i , mean = %.10f , stdev = %.10f\n",N,mean,stdev);

		setA(original_valA);
	}
	// 0x53
	// Increment Register A
	void R34HC22::incrementRegisterA(int address){

		if((address + 1) < getMemSize()){
			// increare the value of A
			setA(getA() + 1);

			// move the program counter to the next byte
			setProgCounter(address + 1);
			executeFromLocation(address + 1);
			cout << complete_mess << endl;
		} else {
			cerr << error_mess << endl;
			haltOpcode();
		}
	}
Ejemplo n.º 17
0
int main(void)
{
	while(c) {
		if (b == 0)
			goto L;

		if (check()) {
			c = 0;
L:
			setA();
			setB();
		}
	}

	return 0;
}
Ejemplo n.º 18
0
Quaternion::Quaternion(const EulerAngles &euler) :
	Vector(4)
{
	float cosPhi_2 = cosf(euler.getPhi() / 2.0f);
	float cosTheta_2 = cosf(euler.getTheta() / 2.0f);
	float cosPsi_2 = cosf(euler.getPsi() / 2.0f);
	float sinPhi_2 = sinf(euler.getPhi() / 2.0f);
	float sinTheta_2 = sinf(euler.getTheta() / 2.0f);
	float sinPsi_2 = sinf(euler.getPsi() / 2.0f);
	setA(cosPhi_2 * cosTheta_2 * cosPsi_2 +
	     sinPhi_2 * sinTheta_2 * sinPsi_2);
	setB(sinPhi_2 * cosTheta_2 * cosPsi_2 -
	     cosPhi_2 * sinTheta_2 * sinPsi_2);
	setC(cosPhi_2 * sinTheta_2 * cosPsi_2 +
	     sinPhi_2 * cosTheta_2 * sinPsi_2);
	setD(cosPhi_2 * cosTheta_2 * sinPsi_2 +
	     sinPhi_2 * sinTheta_2 * cosPsi_2);
}
Ejemplo n.º 19
0
Quaternion::Quaternion(const EulerAngles &euler) :
	Vector(4)
{
	double cosPhi_2 = cos(double(euler.getPhi()) / 2.0);
	double sinPhi_2 = sin(double(euler.getPhi()) / 2.0);
	double cosTheta_2 = cos(double(euler.getTheta()) / 2.0);
	double sinTheta_2 = sin(double(euler.getTheta()) / 2.0);
	double cosPsi_2 = cos(double(euler.getPsi()) / 2.0);
	double sinPsi_2 = sin(double(euler.getPsi()) / 2.0);
	setA(cosPhi_2 * cosTheta_2 * cosPsi_2 +
	     sinPhi_2 * sinTheta_2 * sinPsi_2);
	setB(sinPhi_2 * cosTheta_2 * cosPsi_2 -
	     cosPhi_2 * sinTheta_2 * sinPsi_2);
	setC(cosPhi_2 * sinTheta_2 * cosPsi_2 +
	     sinPhi_2 * cosTheta_2 * sinPsi_2);
	setD(cosPhi_2 * cosTheta_2 * sinPsi_2 -
	     sinPhi_2 * sinTheta_2 * cosPsi_2);
}
Ejemplo n.º 20
0
void TGAImage::initFirstLOD( unsigned char* srcData)
{

	lodData[0] = new unsigned char[ getLODwidth(0) * getLODheight(0) * BPP ] ;
	
	for( int i = 0 ; i < getLODwidth(0) ; i++ )
		for( int j = 0 ; j < getLODheight(0) ; j++ )
		{
			unsigned char r, g, b, a ;
			if( srcData ) getRGBA( srcData, i, getLODheight(0) - 1 - j, r, g, b, a ) ;
			else r = g = b = a = 0 ;

			setR( 0, i, j, r ) ;
			setG( 0, i, j, g ) ;
			setB( 0, i, j, b ) ;
			setA( 0, i, j, a ) ;
		}
	goodLOD = 0 ;
}
Ejemplo n.º 21
0
void TGAImage::generateLOD( int lod )
{
	int dstW = getLODwidth(lod) ;
	int dstH = getLODheight(lod);

	if( lodData[lod] == NULL ) lodData[lod] = new unsigned char[ dstW * dstH * BPP ] ;

	int s = getLODwidth(0) / dstW ;
	int t = getLODheight(0) / dstH ;

	for( int i = 0 ; i < dstW ; i++ )
		for( int j = 0 ; j < dstH ; j++ )
		{
			
			int r = 0, g = 0, b = 0, a = 0 ;

			for( int k = 0 ; k < s ; k++ )
				for( int l = 0 ; l < t ; l++ )
				{
					r += getR( 0, i * s + k, j * t + l ) ;
					g += getG( 0, i * s + k, j * t + l ) ;
					b += getB( 0, i * s + k, j * t + l ) ;
					a += getA( 0, i * s + k, j * t + l ) ;
				}

			r /= s * t ;
			g /= s * t ;
			b /= s * t ;
			a /= s * t ;
			
			setR( lod, i, j, r ) ;
			setG( lod, i, j, g ) ;
			setB( lod, i, j, b ) ;
			setA( lod, i, j, a ) ;
		}

	goodLOD = lod ;
}
	// 0x37
	// Load A with Value
	void R34HC22::loadRegisterWithValue(int address, string r)
	{
		if((address + 2) < getMemSize())
		{
			if(r.compare("A") == 0)
			{
				// load value from the first byte after the opcode to A
				setA(getMemoryValueAtLocation(address + 1));
			}
			else if(r.compare("B") == 0)
			{
				// load value from the first byte after the opcode to B
				setB(getMemoryValueAtLocation(address + 1));
			}
			// set the program counter the the second byte after opcode
			setProgCounter(address + 2);
			executeFromLocation(address + 2);
			cout << complete_mess << endl;
		} else {
			cerr << error_mess << endl;
			haltOpcode();
		}
	}
Ejemplo n.º 23
0
Complex& Complex::operator=(const Complex &other){
  setA(other.a);
  setB(other.b);
}
Ejemplo n.º 24
0
void control::event1() {
    setA(true);
    qDebug() << "New Bottle";
    qDebug() << "Bottling Started";
    QTimer::singleShot(5000, this, SLOT(event2()));
}
Ejemplo n.º 25
0
void DirectionalAtom::rotateBy(const RotMat3x3d& m) {
    setA(m *getA());
}
Ejemplo n.º 26
0
/*
 *	s e t u p A u x i l i a r y Q P
 */
returnValue SQProblem::setupAuxiliaryQP ( SymmetricMatrix *H_new, Matrix *A_new,
    const real_t *lb_new, const real_t *ub_new, const real_t *lbA_new, const real_t *ubA_new
)
{

	int i;
	int nV = getNV( );
	int nC = getNC( );
	returnValue returnvalue;

	if ( ( getStatus( ) == QPS_NOTINITIALISED )       ||
		 ( getStatus( ) == QPS_PREPARINGAUXILIARYQP ) ||
		 ( getStatus( ) == QPS_PERFORMINGHOMOTOPY )   )
	{
		return THROWERROR( RET_UPDATEMATRICES_FAILED_AS_QP_NOT_SOLVED );
	}

	status = QPS_PREPARINGAUXILIARYQP;


	/* I) SETUP NEW QP MATRICES AND VECTORS: */
	/* 1) Shift constraints' bounds vectors by (A_new - A)'*x_opt to ensure
	 *    that old optimal solution remains feasible for new QP data. */
	/*    Firstly, shift by -A'*x_opt and ... */
	if ( nC > 0 )
	{
		if ( A_new == 0 )
			return THROWERROR( RET_INVALID_ARGUMENTS );

		for ( i=0; i<nC; ++i )
		{
			lbA[i] = -Ax_l[i];
			ubA[i] =  Ax_u[i];
		}

		/* Set constraint matrix as well as ... */
		setA( A_new );

		/* ... secondly, shift by +A_new'*x_opt. */
		for ( i=0; i<nC; ++i )
		{
			lbA[i] += Ax[i];
			ubA[i] += Ax[i];
		}

		/* update constraint products. */
		for ( i=0; i<nC; ++i )
		{
			Ax_u[i] = ubA[i] - Ax[i];
			Ax_l[i] = Ax[i] - lbA[i];
		}
	}

	/* 2) Set new Hessian matrix, determine Hessian type and
	 *    regularise new Hessian matrix if necessary. */
	/* a) Setup new Hessian matrix and determine its type. */
	if ( H_new != 0 )
	{
		setH( H_new );

		hessianType = HST_UNKNOWN;
		if ( determineHessianType( ) != SUCCESSFUL_RETURN )
			return THROWERROR( RET_SETUP_AUXILIARYQP_FAILED );

		/* b) Regularise new Hessian if necessary. */
		if ( ( hessianType == HST_ZERO ) ||
			 ( hessianType == HST_SEMIDEF ) ||
			 ( usingRegularisation( ) == BT_TRUE ) )
		{
			regVal = 0.0; /* reset previous regularisation */

			if ( regulariseHessian( ) != SUCCESSFUL_RETURN )
				return THROWERROR( RET_SETUP_AUXILIARYQP_FAILED );
		}
	}
	else
	{
		if ( H != 0 )
			return THROWERROR( RET_NO_HESSIAN_SPECIFIED );
	}

	/* 3) Setup QP gradient. */
	if ( setupAuxiliaryQPgradient( ) != SUCCESSFUL_RETURN )
		return THROWERROR( RET_SETUP_AUXILIARYQP_FAILED );


	/* II) SETUP WORKING SETS AND MATRIX FACTORISATIONS: */
	/* 1) Make a copy of current bounds/constraints ... */
	Bounds      oldBounds      = bounds;
	Constraints oldConstraints = constraints;

    /* we're trying to find an active set with positive definite null
     * space Hessian twice:
     * - first for the current active set including all equalities
     * - second after moving all inactive variables to a bound
     *   (depending on Options). This creates an empty null space and
     *   is guaranteed to succeed. Thus this loop will exit after n_try=1.
     */
    int n_try;
    for (n_try = 0; n_try < 2; ++n_try) {

        if (n_try > 0) {
            // the current active set leaves an indefinite null space Hessian
            // move all inactive variables to a bound, creating an empty null space
            for (int ii = 0; ii < nV; ++ii)
                if (oldBounds.getStatus (ii) == ST_INACTIVE)
                    oldBounds.setStatus (ii, options.initialStatusBounds);
        }

        /*    ... reset them ... */
        bounds.init( nV );
        constraints.init( nC );

        /*    ... and set them up afresh. */
        if ( setupSubjectToType(lb_new,ub_new,lbA_new,ubA_new ) != SUCCESSFUL_RETURN )
            return THROWERROR( RET_SETUP_AUXILIARYQP_FAILED );

        if ( bounds.setupAllFree( ) != SUCCESSFUL_RETURN )
            return THROWERROR( RET_SETUP_AUXILIARYQP_FAILED );

        if ( constraints.setupAllInactive( ) != SUCCESSFUL_RETURN )
            return THROWERROR( RET_SETUP_AUXILIARYQP_FAILED );

        /* 2) Setup TQ factorisation. */
        if ( setupTQfactorisation( ) != SUCCESSFUL_RETURN )
            return THROWERROR( RET_SETUP_AUXILIARYQP_FAILED );

		// check for equalities that have become bounds ...
		for (int ii = 0; ii < nC; ++ii) {
			if (oldConstraints.getType (ii) == ST_EQUALITY && constraints.getType (ii) == ST_BOUNDED) {
				if (oldConstraints.getStatus (ii) == ST_LOWER && y[nV+ii] < 0.0)
					oldConstraints.setStatus (ii, ST_UPPER);
				else if (oldConstraints.getStatus (ii) == ST_UPPER && y[nV+ii] > 0.0)
					oldConstraints.setStatus (ii, ST_LOWER);
			}
		}

		// ... and do the same also for the bounds!
		for (int ii = 0; ii < nV; ++ii) {
			if (oldBounds.getType(ii) == ST_EQUALITY
					&& bounds.getType(ii) == ST_BOUNDED) {
				if (oldBounds.getStatus(ii) == ST_LOWER && y[ii] < 0.0)
					oldBounds.setStatus(ii, ST_UPPER);
				else if (oldBounds.getStatus(ii) == ST_UPPER && y[ii] > 0.0)
					oldBounds.setStatus(ii, ST_LOWER);
			}
		}

        /* 3) Setup old working sets afresh (updating TQ factorisation). */
        if ( setupAuxiliaryWorkingSet( &oldBounds,&oldConstraints,BT_TRUE ) != SUCCESSFUL_RETURN )
            return THROWERROR( RET_SETUP_AUXILIARYQP_FAILED );

        /* Factorise projected Hessian
        * this now handles all special cases (no active bounds/constraints, no nullspace) */
        returnvalue = computeProjectedCholesky( );

        /* leave the loop if decomposition was successful, i.e. we have
         * found an active set with positive definite null space Hessian */
        if ( returnvalue == SUCCESSFUL_RETURN )
            break;
    }

    /* adjust lb/ub if we changed the old active set in the second try
     */
    if (n_try > 0) {
		// as per setupAuxiliaryQPbounds assumptions ... oh the troubles
		for (int ii = 0; ii < nC; ++ii)
			Ax_l[ii] = Ax_u[ii] = Ax[ii];
        setupAuxiliaryQPbounds (&bounds, &constraints, BT_FALSE);
	}

	status = QPS_AUXILIARYQPSOLVED;

	return SUCCESSFUL_RETURN;
}
Ejemplo n.º 27
0
Complex::Complex(double a, double b) {
  setA(a);
  setB(b);
}
Ejemplo n.º 28
0
 complex_number::complex_number(double a, double b) {
   setA(a);
   setB(b);
 }
Ejemplo n.º 29
0
Complex::Complex(const Complex &other) {
  setA(other.a);
  setB(other.b);
}
Ejemplo n.º 30
0
int main(void)
{
	setA();
	assert(b == 1);
	return 0;
}