void BlockLocalPositionEstimator::updateSSStates()
{
	// derivative of velocity is accelerometer acceleration
	// (in input matrix) - bias (in body frame)
	_A(X_vx, X_bx) = -_R_att(0, 0);
	_A(X_vx, X_by) = -_R_att(0, 1);
	_A(X_vx, X_bz) = -_R_att(0, 2);

	_A(X_vy, X_bx) = -_R_att(1, 0);
	_A(X_vy, X_by) = -_R_att(1, 1);
	_A(X_vy, X_bz) = -_R_att(1, 2);

	_A(X_vz, X_bx) = -_R_att(2, 0);
	_A(X_vz, X_by) = -_R_att(2, 1);
	_A(X_vz, X_bz) = -_R_att(2, 2);
}
Example #2
0
/**
@brief plugin initialization function, called by main program

@param mode flags enumerating what sort of init to perform

@return Plugin*, with refcount 1 if @a mode included runtime setup and that succeeded
*/
Plugin *init_plugin (E2PInit mode)
{
	const gchar *aname2 = _("selmatchpart");

	PLUGINIT_INTRO
	PLUGINIT_NUMBERED_ALLOCATE(2)

	PLUGINIT_NUMBERED_ACTION(1,_A(7),_("selmatch"),_e2p_select_same,
		_("_Select same"),
		_("Select items whose whole name matches a selected item in the other pane"),
		"plugin_"ANAME E2ICONTB)
	PLUGINIT_NUMBERED_ACTION(2,_A(7),aname2,_e2p_select_like,
		_("Select _like"),
		_("Select items whose name partially matches a selected item in the other pane"),
		NULL)

	//if the above included init, and it succeeded, more init needed
	if (iface.refcount == 1)
	{
		E2_OptionSetupExtra ex;
		gchar *group = g_strconcat(_C(34),".",_C(27),":",aname2,NULL); //_("plugins.options:selmatchpart"
		memset (&ex, 0, sizeof (E2_OptionSetupExtra));
		ex.exbool = TRUE;
		E2_OptionSet *set = e2_plugins_option_register (E2_OPTION_TYPE_BOOL, "selmatch-start",
			group, _("match to first separator"),
			_("If enabled, name matching stops at the first instance of any specified separator, otherwise, at the last instance"),
			NULL, &ex, E2_OPTION_FLAG_FREEGROUP | E2_OPTION_FLAG_ADVANCED);
		//because plugins are loaded after config data, config options need to
		//get any data from unknown-options data
		e2_option_transient_value_get (set);

		ex.exstr = ".";
		set = e2_plugins_option_register (E2_OPTION_TYPE_STR, "selmatch-separators",
			group, _("separator character(s)"),
			_("String comprising all chars considered to be a 'separator'"),
			NULL, &ex, E2_OPTION_FLAG_ADVANCED);
		e2_option_transient_value_get (set);
	}

	PLUGINIT_NUMBERED_END

}
Example #3
0
void probe_fini (void *arg)
{
        _A((void *)arg == (void *)&__filehash_probe_mutex);

        /*
         * Destroy mutex.
         */
        (void) pthread_mutex_destroy (&__filehash_probe_mutex);

        return;
}
void BlockLocalPositionEstimator::initSS()
{
	initP();

	// dynamics matrix
	_A.setZero();
	// derivative of position is velocity
	_A(X_x, X_vx) = 1;
	_A(X_y, X_vy) = 1;
	_A(X_z, X_vz) = 1;

	// input matrix
	_B.setZero();
	_B(X_vx, U_ax) = 1;
	_B(X_vy, U_ay) = 1;
	_B(X_vz, U_az) = 1;

	// update components that depend on current state
	updateSSStates();
	updateSSParams();
}
 /// \brief Update the design variable.
 void MatrixTransformation::updateImplementation(const double * dp, int size)
 {
   static_cast<void>(size); // used depending on NDEBUG
   SM_ASSERT_EQ_DBG(aslam::Exception, size, _UpdateDimension , "Incorrect update size");
   _A_a = _A;
   Eigen::Matrix3d dA;
   int j=0;
   for (int i=0; i<9; i++){
 	  _A(i%3,floor(static_cast<double>(i/3))) += _UpdatePattern(i%3,floor(static_cast<double>(i/3)))*dp[j];
 	  if (_UpdatePattern(i%3,floor(static_cast<double>(i/3)))==1){j++; }
   }
 }
Example #6
0
    Parser::Parser(const vector<Production>& productions, const string& parserTablePath) : BasicParser(productions), parserTablePath(parserTablePath)
    {
#ifdef _DEBUG
        stream.open("ParserResult.txt", fstream::out | fstream::binary);
#endif
        // String Begin
        Rule quotationMarks = Rule('\"', &context);
        Rule ruleString = quotationMarks + *!quotationMarks + quotationMarks;
        ruleString.buildDFA();
        ruleString.setShowName("\"{String}\"");
        Production::Item itemString(ruleString);
        // String End

        // Digit Start
        Rule _0('0', &context);
        Rule _9('9', &context);
        Rule _0_9  = _0 - _9;
        Rule ruleDigit = +_0_9;
        ruleDigit.buildDFA();
        ruleDigit.setShowName("\"{Digit}\"");
        Production::Item itemDigit(ruleDigit);
        // Digit End

        // Real Start
        Rule _point('.', &context);
        Rule ruleReal = *_0_9 + _point + +_0_9;
        ruleReal.buildDFA();
        ruleReal.setShowName("\"{Real}\"");
        Production::Item itemReal(ruleReal);
        // Real End

        // Letter Start
        Rule _('_', &context);
        Rule _a('a', &context);
        Rule _z('z', &context);
        Rule _A('A', &context);
        Rule _Z('Z', &context);
        Rule _a_z = _a - _z;
        Rule _A_Z = _A - _Z;
        Rule ruleLetter = ((+_ + ruleDigit) |
            (+(_ | _a_z | _A_Z))) +
            *(_ | ruleDigit | _a_z | _A_Z);
        ruleLetter.buildDFA();
        ruleLetter.setShowName("\"{Letter}\"");
        Production::Item itemLetter(ruleLetter);
        // Letter End

        vts.push_back(pair<string, Production::Item>("{String}", itemString));
        vts.push_back(pair<string, Production::Item>("{Digit}",  itemDigit));
        vts.push_back(pair<string, Production::Item>("{Real}",   itemReal));
        vts.push_back(pair<string, Production::Item>("{Letter}", itemLetter));
    }
Example #7
0
void genPredModel::init(double paramA, double paramB) {
    rowA = 3;
    colA = 3;
    Matrix _A(3,3);
    Matrix _B(3,3);
    Matrix _H(3,3);
    A = _A;
    B = _B;   
    H = _H;
    A.zero();
    B.zero();
    H.zero();
}
void probe_fini (void *arg)
{
        _A((void *)arg == (void *)&__file_probe_mutex);

	if (!SEXP_emptyp(&gr_lastpath))
		SEXP_free_r(&gr_lastpath);

        /*
         * Destroy mutex.
         */
        (void) pthread_mutex_destroy (&__file_probe_mutex);

        return;
}
Example #9
0
SEXP_t *SEXP_list_new_rv (SEXP_t *sexp_mem, SEXP_t *memb, va_list alist)
{
        SEXP_val_t v_dsc;
        SEXP_t    *s_ptr[32];
        size_t     s_cur;
        uint8_t    b_exp;

        s_cur = 0;
        s_ptr[s_cur] = memb;

        while (s_ptr[s_cur] != NULL) {
                _A(s_cur < (sizeof s_ptr / sizeof (SEXP_t *)));
                SEXP_VALIDATE(s_ptr[s_cur]);

                s_ptr[++s_cur] = va_arg (alist, SEXP_t *);
        }

        if (SEXP_val_new (&v_dsc, sizeof (void *) + sizeof (uint16_t),
                          SEXP_VALTYPE_LIST) != 0)
        {
                /* TODO: handle this */
                return (NULL);
        }

        if (s_cur > 0) {
                for (b_exp = 0; (size_t)(1 << b_exp) < s_cur; ++b_exp);

                SEXP_LCASTP(v_dsc.mem)->offset = 0;
                SEXP_LCASTP(v_dsc.mem)->b_addr = (void *)SEXP_rawval_lblk_new (b_exp);

                if (SEXP_rawval_lblk_fill ((uintptr_t)SEXP_LCASTP(v_dsc.mem)->b_addr,
                                           s_ptr, s_cur) != ((uintptr_t)SEXP_LCASTP(v_dsc.mem)->b_addr))
                {
                        /* TODO: handle this */
                        return (NULL);
                }
        } else {
                SEXP_LCASTP(v_dsc.mem)->offset = 0;
                SEXP_LCASTP(v_dsc.mem)->b_addr = NULL;
        }

        SEXP_init(sexp_mem);
        sexp_mem->s_type = NULL;
        sexp_mem->s_valp = v_dsc.ptr;

        SEXP_VALIDATE(sexp_mem);

        return (sexp_mem);
}
Example #10
0
LipmConstHeightPlanner::LipmConstHeightPlanner(double z, double dt)
  : _height(z)
  , _dt(dt)
  , _lqr(LqrController<2,1>())
{
  _Q.setIdentity();
  _R.setIdentity();
  _Q *= 1e-6;

  _A(0,0) = 1;
  _A(0,1) = _dt;
  _A(1,0) = _dt*GRAVITY/_height;
  _A(1,1) = 1;

  _B(0,0) = 0;
  _B(1,0) = -_dt*GRAVITY/_height;

  _lqr.setQ(_Q);
  _lqr.setR(_R);
  _lqr.infTimeLQR(_A, _B);

  _K = _lqr.getK();
  _Quu_inv = (_B.transpose()*_lqr.getV()*_B + _R).inverse();
}
static SEAP_cmdrec_t *Stable_get (Stable_t *t, SEAP_cmdcode_t c)
{
        Stable_rec_t *t_r;
        size_t i;

        _A(t != NULL);
        
        t_r = &(t->t_recs[c % t->t_size]);
        
        for (i = 0; i < t_r->c_size; ++i)
                if (t_r->c_recs[i]->code == c)
                        return (t_r->c_recs[i]);
        
        return (NULL);
}
static Stable_t *Stable_new (size_t capacity)
{
        Stable_t *t;
        size_t    i;
        
        _A(capacity > 0 &&
           capacity < SEAP_COMMAND_BACKENDS_MAXCAPACITY);
        
	t = malloc(sizeof(Stable_t));
        t->t_size = Stable_prime_gt (capacity);
	t->t_recs = calloc(t->t_size, sizeof(Stable_rec_t));
        
        for (i = 0; i < t->t_size; ++i)
                t->t_recs[i].c_recs = NULL;
        
        return (t);
}
Example #13
0
	void Matrix3x3::SVD(double* U, double* s, double* VT, const double* A)
  {
#ifndef OPEN3DMOTION_LINEAR_ALGEBRA_EIGEN
    long three(3);
    Matrix3x3 Acpy(A);
    long lwork(256);
    double work[256];
    long info(0);

    // use lapack routine
    // - note U and VT are swapped
    // - this is because of the fortran column-major
    //   ordering for matrices - it turns out that
    //   using a row major matrix here corresponds to
    //   swapping U and VT
    dgesvd_(
      "A",  // all of U
      "A",  // all of VT
      &three, // rows
      &three, // cols
      Acpy,   // input/output matrix
      &three, // leading dimension of Acpy
      s,      // singular values
      VT,      // left orthonormal matrix
      &three, // leading dimension of left
      U,      // right orthonormal matrix
      &three, // leading dimension of right 
      work,   // workspace
      &lwork, // size of workspace
      &info);   // returned error codes
    
#else
		Eigen::Map< const Eigen::Matrix<double, 3, 3, Eigen::RowMajor> > _A(A, 3, 3);
    Eigen::Map< Eigen::Matrix<double, 3, 3, Eigen::RowMajor> > _U(U, 3, 3);
    Eigen::Map< Eigen::Matrix<double, 3, 3, Eigen::RowMajor> > _VT(VT, 3, 3);
    Eigen::Map< Eigen::Matrix<double, 3, 1> > _s(s, 3, 1);
    Eigen::JacobiSVD< Eigen::Matrix<double, 3, 3, Eigen::RowMajor> > svd(_A, Eigen::ComputeFullU | Eigen::ComputeFullV);
    _U = svd.matrixU();
    _VT = svd.matrixV().transpose();
    _s = svd.singularValues();
#endif

  }
static uint16_t Stable_prime_gt (uint16_t n) {
        size_t w, s;
        
        w = (sizeof Stable_primes) / sizeof (uint16_t);
        s = 0;
        
        while (w > 0) {
                if (n > Stable_primes[s + w/2]) {
                        s += w/2 + 1;
                        w  = w - w/2 - 1;
                } else if (n < Stable_primes[s + w/2]) {
                        w = w/2;
                } else
                        break;
        }
        
        _A(s + w/2 < (sizeof Stable_primes) / sizeof (uint16_t));
        
        return (Stable_primes[s + w/2]);
}
Example #15
0
linVelModel::linVelModel() {
    valid = true;
    type = "constVelocity";
    rowA = 2;
    colA = 2;
    printf("initialisation matrix A,B,H with main dimension %d \n", rowA, colA);
    Matrix _A(2,2);
    Matrix _B(2,1);
    Matrix _H(2,2);
    A = _A;
    B = _B;
    H = _H;   
    A.zero();
    B.zero();
    H.zero();    
       
    A(0,0) = 1; 
    A(1,1) = 1;
    B(0,0) = 0.01;   
    H(1,1) = 1;
}
Example #16
0
int eigen_decomposition(const dgematrix &A, dgematrix & P, dgematrix &D)
{
      int N= A.n;
      vector<double> wr, wi;
      vector<dcovector > vr, vi;
      dgematrix _A(A);
      int i,j;
      if(A.n != A.m)
            {
                  cerr<<"BFilt :: Matrix must be square"<<endl;
                  return 1;
            }
      D.resize(N,N);
      P.resize(N,N);

      if(_A.dgeev(wr,wi,vr,vi))
            return 1;
      P.zero();
      for(j=0; j<P.m; j++)
            { 
                  for(i=0; i<P.n; i++)
                        {
                              P(i,j) = vr[j](i);
                        }
            }
      D.zero();
      for(i=0;i<N;i++)
            {
                  if(wi[i] != 0)
                        {
                              cerr<<"BFilt :: Matrix must be real"<<endl;
                              return 1;
                        }

                  D(i,i) = wr[i];
            }
      return 0;
}
Example #17
0
int matvec(int nx, int ny, real* A, real* x, real* y)
{
#if defined(_OPENACC)
	size_t szarray = (size_t)nx * ny;
	#pragma acc kernels loop independent present(A[0:szarray], x[0:nx], y[0:ny])
#endif
#if defined(_OPENMP) || defined(_MIC)
	#pragma omp parallel for
#endif
	for (int j = 0; j < ny; j++)
	{
		y[j] = 0;
#if defined(_OPENACC)
		#pragma acc loop seq
#endif
		for (int i = 0; i < nx; i++)
		{
			y[j] += _A(A, i, j) * x[i];
		}
	}

	return 0;
}
Example #18
0
/* find the cathode sheath thickness in m */
double _d ( long plasmatype, double Ti, double Nn, double gamma, double j ) {
  double d, dtilde, relerr, abserr, dtildemin, dtildemax, Pdmin, P;
  long IFLAG;
  arg_t arg;

/*
  d=0.01; 
  dd=1e-8; 
  do {
    res= (j-_j(Ti,Nn,gamma,d)) ;
    dddj=dd/(_j(Ti,Nn,gamma,d+dd)-_j(Ti,Nn,gamma,d));
    d=max(0.01,d+dd);
    dd=dddj*res;
    printf("d=%E  j=%E  res=%E\n",d,j,res);
  } while(fabs(res/j)>1e-10);
*/

  arg.gamma = gamma;
  arg.Nn = Nn;
  arg.Ti = Ti;
  arg.j = j;
  arg.plasmatype = plasmatype;
  dtildemin = 1.0 / ebar;
  dtildemax = 2000.0;
  relerr = 1e-10;
  abserr = 1e-100;
  dtilde = EXM_find_root_zero_in ( &_jres, &arg, dtildemin, dtildemax, relerr, abserr, &IFLAG );
  if ( IFLAG != 1 )
    printf ( "a root for dtilde has not been found (IFLAG=%ld)\n", IFLAG );
  P = Nn * Ti * kB / 133.0;     /* Torr */
  Pdmin = ebar / _A ( plasmatype ) * ( 1.0 / gamma + 1.0 );     /* Torr cm */

  d = dtilde * Pdmin / P * 0.01;

  return ( d );
}
Example #19
0
int wave13pt(int nx, int ny, int ns,
	const real c0, const real c1, const real c2,
	real* w0, real* w1, real* w2)
{
	int i, j, k;
	unsigned int szarray = (unsigned int)nx * ny * ns;
#pragma acc data present(w0[0:szarray], w1[0:szarray], w2[0:szarray])
{
  #pragma acc kernels
  {
	#pragma acc loop independent vector(2)
	for (k = 2; k < ns - 2; k++)
	{
		#pragma acc loop independent gang(31) vector(4)
		for (j = 2; j < ny - 2; j++)
		{
			#pragma acc loop independent gang(2) vector(64)
			for (i = 2; i < nx - 2; i++)
			{
				_A(w2, k, j, i) =  c0 * _A(w1, k, j, i) - _A(w0, k, j, i) +

					c1 * (
						_A(w1, k, j, i+1) + _A(w1, k, j, i-1)  +
						_A(w1, k, j+1, i) + _A(w1, k, j-1, i)  +
						_A(w1, k+1, j, i) + _A(w1, k-1, j, i)) +
					c2 * (
						_A(w1, k, j, i+2) + _A(w1, k, j, i-2)  +
						_A(w1, k, j+2, i) + _A(w1, k, j-2, i)  +
						_A(w1, k+2, j, i) + _A(w1, k-2, j, i));
			}
		}
	}
  }
}
	return 0;
}
FE_TMPL std::complex<float> FE_SYS::_I(int n,int m,glm::vec3 x){
	glm::vec3 s = cart2sph(x);
	return std::pow(std::complex<float>(0,-1),-std::abs(m)) * _A(n,m) * std::pow(s.x,n) * _Y(n,m,s.y,s.z);
}
Example #21
0
// first element is NOT filled right now, doesn't matter, BRK will fill that position.
// Now, fill used entries with actual jump addresses.
#include "jump_table.h"
	blr
}



// -----------------------------------------------------------------------
// This functions loads the PC with the address stored at 0xFFFC
// and clears registers which effectively resets the CPU.
asm void N6502::_Reset()
{
	li		r4,0						// init registers
	stb		r4,_A(r3)
	stb		r4,_X(r3)
	stb		r4,_Y(r3)
	stw		r4,_CycleBK(r3)
	stw		r4,_IntReq(r3)
	li		r5,R_FLAG|Z_FLAG
	stb		r5,_F(r3)
	li		r6,0xFF
	stb		r6,_SP(r3)

	li		r9,0
	lwz		r7,_MEM_X(r3)				// load PC with reset vector
	ori		r9,r9,RESET_VECTOR
	lwz		r7,ROMSeg4_Ind(r7)
	lhbrx	r8,r9,r7
	sth		r8,_PC(r3)
int probe_main (probe_ctx *ctx, void *mutex)
{
        SEXP_t *path, *filename, *behaviors;
        SEXP_t *filepath, *attribute_, *probe_in;
	int err;
        struct cbargs cbargs;
	OVAL_FTS    *ofts;
	OVAL_FTSENT *ofts_ent;

        if (mutex == NULL)
                return PROBE_EINIT;

        _A(mutex == &__file_probe_mutex);

        probe_in  = probe_ctx_getobject(ctx);

        path       = probe_obj_getent (probe_in, "path",      1);
        filename   = probe_obj_getent (probe_in, "filename",  1);
        behaviors  = probe_obj_getent (probe_in, "behaviors", 1);
        filepath   = probe_obj_getent (probe_in, "filepath", 1);
        attribute_ = probe_obj_getent (probe_in, "attribute_name", 1);

	/* we want either path+filename or filepath */
        if (((path == NULL || filename == NULL) && filepath == NULL)
            || attribute_ == NULL)
        {
                SEXP_free (behaviors);
                SEXP_free (path);
                SEXP_free (filename);
                SEXP_free (filepath);
                SEXP_free (attribute_);

                return PROBE_ENOELM;
        }

	probe_filebehaviors_canonicalize(&behaviors);

        switch (pthread_mutex_lock (&__file_probe_mutex)) {
        case 0:
                break;
        default:
                dI("Can't lock mutex(%p): %u, %s.", &__file_probe_mutex, errno, strerror (errno));

		SEXP_free(path);
		SEXP_free(filename);
		SEXP_free(filepath);
		SEXP_free(behaviors);
                SEXP_free(attribute_);

                return PROBE_EFATAL;
        }

        cbargs.ctx      = ctx;
	cbargs.error    = 0;
        cbargs.attr_ent = attribute_;

	if ((ofts = oval_fts_open(path, filename, filepath, behaviors)) != NULL) {
		while ((ofts_ent = oval_fts_read(ofts)) != NULL) {
			file_cb(ofts_ent->path, ofts_ent->file, &cbargs);
			oval_ftsent_free(ofts_ent);
		}
		oval_fts_close(ofts);
	}

	err = 0;

	SEXP_free(path);
	SEXP_free(filename);
	SEXP_free(filepath);
	SEXP_free(behaviors);
        SEXP_free(attribute_);

        switch (pthread_mutex_unlock (&__file_probe_mutex)) {
        case 0:
                break;
        default:
                dI("Can't unlock mutex(%p): %u, %s.", &__file_probe_mutex, errno, strerror (errno));

                return PROBE_EFATAL;
        }

        return err;
}
Example #23
0
	value_t GeometricCGVariant::solve(const TTOperator *_Ap, TTTensor &_x, const TTTensor &_b, size_t _numSteps, value_t _convergenceEpsilon, PerformanceData &_perfData) const {
		const TTOperator &_A = *_Ap;
		static const Index i,j;
		size_t stepCount=0;
		TTTensor residual;
		TTTangentVector gradient;
		value_t gradientNorm = 1.0;
		value_t lastResidual=1e100;
		value_t currResidual=1e100;
		value_t normB = frob_norm(_b);
		
		if (_Ap != nullptr) {
			_perfData << "Conjugated Gradients for ||A*x - b||^2, x.dimensions: " << _x.dimensions << '\n'
					<< "A.ranks: " << _A.ranks() << '\n';
			if (assumeSymmetricPositiveDefiniteOperator) {
				_perfData << " with symmetric positive definite Operator A\n";
			}
		} else {
			_perfData << "Conjugated Gradients for ||x - b||^2, x.dimensions: " << _x.dimensions << '\n';
		}
		_perfData << "x.ranks: " << _x.ranks() << '\n'
					<< "b.ranks: " << _b.ranks() << '\n'
					<< "maximum number of steps: " << _numSteps << '\n'
					<< "convergence epsilon: " << _convergenceEpsilon << '\n';
		_perfData.start();
		
		auto calculateResidual = [&]()->value_t {
			if (_Ap != nullptr) {
				residual(i&0) = _b(i&0) - _A(i/2,j/2)*_x(j&0);
			} else {
				residual = _b - _x;
			}
			return frob_norm(residual);//normB;
		};
		auto updateGradient = [&]() {
			if (assumeSymmetricPositiveDefiniteOperator || (_Ap == nullptr)) {
				gradient = TTTangentVector(_x, residual);
			} else {
				TTTensor grad;
				grad(i&0) = (*_Ap)(j/2,i/2) * residual(j&0); // grad = A^T * (b - Ax)
				gradient = TTTangentVector(_x, grad);
			}
			gradientNorm = gradient.frob_norm();
		};
		
		currResidual = calculateResidual();
		_perfData.add(stepCount, currResidual, _x);
		
		updateGradient();
		TTTangentVector direction = gradient;
		value_t alpha = 1;
		while ((_numSteps == 0 || stepCount < _numSteps)
			&& currResidual/normB > _convergenceEpsilon
			&& std::abs(lastResidual-currResidual)/normB > _convergenceEpsilon
			&& std::abs(1-currResidual/lastResidual)/normB > _convergenceEpsilon) 
		{
			stepCount += 1;
			size_t stepFlags = 0;
			
			// check the derivative along the current direction
			value_t derivative = gradient.scalar_product(direction) / direction.frob_norm();
			
			// if movement in the given direction would increase the residual rather than decrease it, perform one steepest descent step instead
			if (derivative <= 0) {
				direction = gradient;
				derivative = gradient.frob_norm();
				alpha = 1;
				stepFlags |= 1;
			}
			
			line_search(_x, alpha, direction, derivative, currResidual, retraction, calculateResidual, 0.8);
			
			_perfData.add(stepCount, currResidual, _x, stepFlags);
			
// 			direction(i&0) = residual(i&0) + beta * direction(i&0);
			TTTangentVector oldDirection(direction);
			vectorTransport(_x, oldDirection);
			value_t oldGradNorm = gradientNorm;
			updateGradient();
			
			double beta = gradientNorm / oldGradNorm ;// Fletcher-Reeves update
			direction = gradient;
			direction += oldDirection * beta;
		}
		
		return currResidual;
	}
Example #24
0
static void doBranch( axp_ins opcode, pointer lbl, uint reg ) {

    opcode = _Opcode( opcode ) | _A( reg );
    OutReloc( lbl, OWL_RELOC_BRANCH_REL, 0 );
    ObjBytes( &opcode, sizeof( opcode ) );
}
Example #25
0
int probe_main (probe_ctx *ctx, void *mutex)
{
        SEXP_t *path, *filename, *behaviors, *filepath, *probe_in;

	OVAL_FTS    *ofts;
	OVAL_FTSENT *ofts_ent;
	oval_schema_version_t over;

        if (mutex == NULL) {
		return (PROBE_EINIT);
        }

        _A(mutex == &__filehash_probe_mutex);

        probe_in  = probe_ctx_getobject(ctx);

        path      = probe_obj_getent (probe_in, "path",      1);
        filename  = probe_obj_getent (probe_in, "filename",  1);
        behaviors = probe_obj_getent (probe_in, "behaviors", 1);
        filepath = probe_obj_getent (probe_in, "filepath", 1);
	over = probe_obj_get_platform_schema_version(probe_in);

        /* we want either path+filename or filepath */
        if ( (path == NULL || filename == NULL) && filepath==NULL ) {
                SEXP_free (behaviors);
                SEXP_free (path);
                SEXP_free (filename);
		SEXP_free (filepath);

		return (PROBE_ENOELM);
        }

	probe_filebehaviors_canonicalize(&behaviors);

        switch (pthread_mutex_lock (&__filehash_probe_mutex)) {
        case 0:
                break;
        default:
                dI("Can't lock mutex(%p): %u, %s.", &__filehash_probe_mutex, errno, strerror (errno));

		SEXP_free (behaviors);
		SEXP_free (path);
		SEXP_free (filename);
		SEXP_free (filepath);

		return (PROBE_EFATAL);
        }

	if ((ofts = oval_fts_open(path, filename, filepath, behaviors)) != NULL) {
		while ((ofts_ent = oval_fts_read(ofts)) != NULL) {
			filehash_cb(ofts_ent->path, ofts_ent->file, ctx, over);
			oval_ftsent_free(ofts_ent);
		}

		oval_fts_close(ofts);
	}

        SEXP_free (behaviors);
        SEXP_free (path);
        SEXP_free (filename);
        SEXP_free (filepath);

        switch (pthread_mutex_unlock (&__filehash_probe_mutex)) {
        case 0:
                break;
        default:
                dI("Can't unlock mutex(%p): %u, %s.", &__filehash_probe_mutex, errno, strerror (errno));

		return (PROBE_EFATAL);
        }

	return 0;
}
Example #26
0
 * We use this table twice; once with bootstrap page table, and once
 * with kernel's page table which we build up in initarm().
 *
 * Since we map these registers into the bootstrap page table using
 * pmap_devmap_bootstrap() which calls pmap_map_chunk(), we map
 * registers segment-aligned and segment-rounded in order to avoid
 * using the 2nd page tables.
 */

#define	_A(a)	((a) & ~L1_S_OFFSET)
#define	_S(s)	(((s) + L1_S_SIZE - 1) & ~(L1_S_SIZE-1))

static const struct pmap_devmap devmap[] = {
	{
		/* Map the Texas Instruments Peripheral Bus VA==PA */
		.pd_va = _A(OMAP_TIPB_PBASE),
		.pd_pa = _A(OMAP_TIPB_PBASE),
		.pd_size = _S(OMAP_TIPB_SIZE),
		.pd_prot = VM_PROT_READ|VM_PROT_WRITE,
		.pd_cache = PTE_NOCACHE
	},
	{0}
};

#undef	_A
#undef	_S

/*
 * u_int initarm(...)
 *
 * Initial entry point on startup. This gets called before main() is
Example #27
0
int main (int argc, char *argv[])
{
    char  *input;
    size_t inlen;

    SEXP_psetup_t *psetup;
    SEXP_pstate_t *pstate;
    SEXP_t *s_exp;

    setbuf (stdout, NULL);
    setbuf (stdin,  NULL);

    psetup = SEXP_psetup_new ();
    pstate = NULL;

    if (argc == 1) {
        while (!feof (stdin)) {
            input = NULL;
            inlen = 0;

#if defined(__FreeBSD__)
            input = fgetln (stdin, &inlen);
#elif defined(__linux__) || defined(__GLIBC__)
            getline (&input, &inlen, stdin);
#elif defined(__SVR4) && defined(__sun)
            getline (&input, &inlen, stdin);
#else
# error "FIXME"
#endif
            s_exp = SEXP_parse (psetup, input, inlen, &pstate);

            if (s_exp != NULL) {
                _A(pstate == NULL);
                print_sexp (s_exp);
                SEXP_free (s_exp);
            }

            /* FIXME: getline/fgetln leak */
        }
    } else {
        int i;

        for (i = 0; i < (argc - 1); ++i) {
            s_exp = SEXP_parse (psetup, argv[i + 1], strlen (argv[i + 1]), &pstate);

            if (s_exp != NULL) {
                _A(pstate == NULL);
                print_sexp (s_exp);

                SEXP_free (s_exp);
            }
        }

        if (pstate != NULL)
            return (1);
    }

    SEXP_psetup_free (psetup);

    return (0);
}
Example #28
0
void e2_action_option_actions_register ()
{
	E2_Action action =
	{g_strconcat(_A(9),".",_A(85),NULL),_e2_action_option_set,FALSE,E2_ACTION_TYPE_ITEM,0,NULL,NULL};
	e2_action_register (&action);
}
Example #29
0
struct pv_addr msgbufpv;
struct pv_addr irqstack;
struct pv_addr undstack;
struct pv_addr abtstack;
struct pv_addr kernelstack;

#define	_A(a)	((a) & ~L1_S_OFFSET)
#define	_S(s)	(((s) + L1_S_SIZE - 1) & ~(L1_S_SIZE-1))

/* Static device mappings. */
static const struct arm_devmap_entry s3c24x0_devmap[] = {
	/*
	 * Map the devices we need early on.
	 */
	{
		_A(S3C24X0_CLKMAN_BASE),
		_A(S3C24X0_CLKMAN_PA_BASE),
		_S(S3C24X0_CLKMAN_SIZE),
		VM_PROT_READ|VM_PROT_WRITE,
		PTE_NOCACHE,
	},
	{
		_A(S3C24X0_GPIO_BASE),
		_A(S3C24X0_GPIO_PA_BASE),
		_S(S3C2410_GPIO_SIZE),
		VM_PROT_READ|VM_PROT_WRITE,
		PTE_NOCACHE,
	},
	{
		_A(S3C24X0_INTCTL_BASE),
		_A(S3C24X0_INTCTL_PA_BASE),
Example #30
0
 * Since we map these registers into the bootstrap page table using
 * pmap_devmap_bootstrap() which calls pmap_map_chunk(), we map
 * registers segment-aligned and segment-rounded in order to avoid
 * using the 2nd page tables.
 */

#define _A(a)	((a) & ~L1_S_OFFSET)
#define _S(s)	(((s) + L1_S_SIZE - 1) & ~(L1_S_SIZE-1))

static const struct pmap_devmap devmap[] = {
	{
		/*
		 * Map all of core area, this gets us everything and
		 * it's only 3MB.
		 */
		.pd_va = _A(AWIN_CORE_VBASE),
		.pd_pa = _A(AWIN_CORE_PBASE),
		.pd_size = _S(AWIN_CORE_SIZE),
		.pd_prot = VM_PROT_READ|VM_PROT_WRITE,
		.pd_cache = PTE_NOCACHE
	},
	{
		/*
		 * Map all 1MB of SRAM area.
		 */
		.pd_va = _A(AWIN_SRAM_VBASE),
		.pd_pa = _A(AWIN_SRAM_PBASE),
		.pd_size = _S(AWIN_SRAM_SIZE),
		.pd_prot = VM_PROT_READ|VM_PROT_WRITE,
		.pd_cache = PTE_CACHE
	},