Example #1
0
// Computes sum of the values of a unitary blob on grid points. The blob is
// supposed to be at the origin of the absolute coordinate system
double sum_blob_SimpleGrid(const struct blobtype &blob, const SimpleGrid &grid,
                           const Matrix2D<double> *D)
{
    SPEED_UP_temps012;
    Matrix1D<double> gr(3), ur(3), corner1(3), corner2(3);
    double         actual_radius;
    int          i, j, k;
    double        sum = 0.0;

    // Compute the limits of the blob in the grid coordinate system
    grid.universe2grid(vectorR3(-blob.radius, -blob.radius, -blob.radius), corner1);
    grid.universe2grid(vectorR3(blob.radius, blob.radius, blob.radius), corner2);
    if (D != NULL)
        box_enclosing(corner1, corner2, *D, corner1, corner2);

    // Compute the sum in the points inside the grid
    // The integer part of the vectors is taken for not picking points
    // just in the border of the blob, which we know they are 0.
    for (i = (int)XX(corner1); i <= (int)XX(corner2); i++)
        for (j = (int)YY(corner1); j <= (int)YY(corner2); j++)
            for (k = (int)ZZ(corner1); k <= (int)ZZ(corner2); k++)
            {
                VECTOR_R3(gr, i, j, k);
                grid.grid2universe(gr, ur);
                if (D != NULL)
                    M3x3_BY_V3x1(ur, *D, ur);
                actual_radius = ur.module();
                if (actual_radius < blob.radius)
                    sum += kaiser_value(actual_radius,
                                        blob.radius, blob.alpha, blob.order);
            }
    return sum;
}
Example #2
0
static PyObject *extract_list(struct pointerlist *root, int values)
{
    PyObject *retval;
    int i;
    unsigned int *kdata;
    import_array();
    MARK();
    XX(print_pointerlist(root));
    if (root->size > 0) {
	quicksort(root->lst, 0, root->size-1);
    }
    MARK();
    if (values) {
	retval = PyList_New(0);
	for (i = 0; i < root->size; i++) {
	    PyList_Append(retval, root->lst[i]->self);
	    XX(PyObject_Print(root->lst[i]->self, stdout, 0));
	    XX(printf(" at address %p\n", root->lst[i]->self));
	}
	MARK();
	return retval;
    }
    retval = PyArray_FromDims(1, (int*)&(root->size), PyArray_INT);
    kdata = (unsigned int *) ((PyArrayObject*) retval)->data;
    for (i = 0; i < root->size; i++) {
	kdata[i] = root->lst[i]->key;
    }
    MARK();
    return PyArray_Return((PyArrayObject*) retval);
}
Example #3
0
void actualPhaseFlip(MultidimArray<double> &I, CTFDescription ctf)
{
    // Perform the Fourier transform
    FourierTransformer transformer;
    MultidimArray< std::complex<double> > M_inFourier;
    transformer.FourierTransform(I,M_inFourier,false);

    Matrix1D<double> freq(2); // Frequencies for Fourier plane
    int yDim=YSIZE(I);
    int xDim=XSIZE(I);
    double iTm=1.0/ctf.Tm;
    for (size_t i=0; i<YSIZE(M_inFourier); ++i)
    {
    	FFT_IDX2DIGFREQ(i, yDim, YY(freq));
    	YY(freq) *= iTm;
        for (size_t j=0; j<XSIZE(M_inFourier); ++j)
        {
        	FFT_IDX2DIGFREQ(j, xDim, XX(freq));
        	XX(freq) *= iTm;
            ctf.precomputeValues(XX(freq),YY(freq));
            if (ctf.getValuePureWithoutDampingAt()<0)
                DIRECT_A2D_ELEM(M_inFourier,i,j)*=-1;
        }
    }

    // Perform inverse Fourier transform and finish
    transformer.inverseFourierTransform();
}
Example #4
0
double spatial_Bspline03_integralf(double alpha)
{
    XX(global_aux) = XX(global_r) + alpha * XX(global_u);
    YY(global_aux) = YY(global_r) + alpha * YY(global_u);
    ZZ(global_aux) = ZZ(global_r) + alpha * ZZ(global_u);
    return spatial_Bspline03LUT(global_aux);
}
Example #5
0
/*
 * Take the full line (lf) including the command and split it into a
 * sub-line (returned) and a completion context (cmplarray).
 */
static LineInfo *
split_line(const char **cmplarray, const LineInfo *lf)
{
	static LineInfo li;
	const struct cmd *c;
	char *cmdname;
	char line[LINESIZE];
	char *cp;
	size_t len;

	len = lf->cursor - lf->buffer;
	if (len + 1 > sizeof(line))
		return NULL;

	(void)strlcpy(line, lf->buffer, len + 1);

	li.cursor   = line + len;
	li.lastchar = line + len;

	cp = skip_WSP(line);
	cmdname = get_cmdname(cp);
	cp += strlen(cmdname);

	if (cp == li.cursor) {
		*cmplarray = "c";
		li.buffer = cmdname;
		return &li;
	}

	c = lex(cmdname);
	if (c == NULL)
		return NULL;

	*cmplarray = c->c_complete;
	if (c->c_pipe) {
		char *cp2;
		if ((cp2 = shellpr(cp)) != NULL) {
			cp = cp2;
# define XX(a)  ((a) + ((a)[1] == '>' ? 2 : 1))
			while ((cp2 = shellpr(XX(cp))) != NULL)
				cp = cp2;

			if (*cp == '|') {
				*cmplarray = "xF";
				cp = skip_WSP(cp + 1);
			}
			else {
				assert(*cp == '>');
				cp = skip_WSP(XX(cp));
				*cmplarray = "f";
			}
# undef XX
		}
	}
	li.buffer = cp;
	return &li;
}
// Apply transformation ---------------------------------------------------
void applyTransformation(const MultidimArray<double> &V2,
                         MultidimArray<double> &Vaux,
                         double *p)
{
    Matrix1D<double> r(3);
    Matrix2D<double> A, Aaux;

    double greyScale = p[0];
    double greyShift = p[1];
    double rot       = p[2];
    double tilt      = p[3];
    double psi       = p[4];
    double scale     = p[5];
    ZZ(r)            = p[6];
    YY(r)            = p[7];
    XX(r)            = p[8];

    Euler_angles2matrix(rot, tilt, psi, A, true);
    translation3DMatrix(r,Aaux);
    A = A * Aaux;
    scale3DMatrix(vectorR3(scale, scale, scale),Aaux);
    A = A * Aaux;

    applyGeometry(LINEAR, Vaux, V2, A, IS_NOT_INV, WRAP);
    if (greyScale!=1 || greyShift!=0)
        FOR_ALL_DIRECT_ELEMENTS_IN_MULTIDIMARRAY(Vaux)
        DIRECT_MULTIDIM_ELEM(Vaux,n)=DIRECT_MULTIDIM_ELEM(Vaux,n)*greyScale+greyShift;
}
Example #7
0
static void linear_filter_reflect( int ntap, float *wt, int npt, float *x )
{
   int ii , nt2=(ntap-1)/2 , jj , np1=npt-1 , np2=2*(npt-1) ;
   register float sum ;
   static int nfar=0 ;
   static float *far=NULL ;

   if( ntap >= npt || wt == NULL || x == NULL ) return ;

   if( npt > nfar ){
     if( far != NULL ) free(far) ;
     far = (float *)malloc(sizeof(float)*npt) ; nfar = npt ;
   }

#undef  XX
#define XX(i) ( ((i)<0) ? far[-(i)] : ((i)>np1) ? far[np2-(i)] : far[(i)] )

   memcpy( far , x , sizeof(float)*npt ) ;

   for( ii=0 ; ii < npt ; ii++ ){
     for( sum=0.0f,jj=0 ; jj < ntap ; jj++ ) sum += wt[jj] * XX(ii-nt2+jj) ;
     x[ii] = sum ;
   }

   return ;
}
Example #8
0
// 解析 & 更新
// 并将发生变化的行,打印出来
bool mktdt_file::Parse(char* src, const int32_t src_len, mktdt_file_data& data) {
	int32_t pos = 0;
	int32_t len = 0;
	int32_t i_header = 0, i_md001 = 0, i_md002 = 0, i_md003 = 0, i_md004 = 0, i_trailer = 0;
	int32_t CheckSumLine; // 用来存储每行的校验码
	mktdt_line dtline;
	// header
	XX(HEADER, _header);
	// 6 为标识符长度
	while (pos + 6 < src_len) {
		XX(MD001, _md001)
else XX(MD002, _md002)
else XX(MD003, _md003)
		else XX(MD004, _md004)
		else XX(TRAILER, _trailer)
		else {
		char pbuf[32];
		snprintf(pbuf, sizeof(pbuf) - 1, "%s", src + pos);
		fprintf(stdout, "err: %s \n", pbuf);
		dtline.find_end(src, len);
		}
	}

	return true;
}
Example #9
0
void linear_filter_trend( int ntap , float *wt , int npt , float *x )
{
   int ii , nt2=(ntap-1)/2 , jj ;
   float sum ;
   static int nfar=0 ;
   static float *far=NULL ;
   float a=0.0,b=0.0 ;

   if( npt > nfar ){
      if(far != NULL) free(far) ;
      far = (float *)malloc(sizeof(float)*npt) ; nfar = npt ;
   }

#undef XX
#define XX(i) ( ((i)<0 || (i)>npt-1) ? (a+b*(i)) : far[i] )

   memcpy( far , x , sizeof(float)*npt ) ;

   get_linear_trend( npt,far , &a,&b ) ; /* cf. thd_detrend.c */

   for( ii=0 ; ii < npt ; ii++ ){
      for( sum=0.0,jj=0 ; jj < ntap ; jj++ ) sum += wt[jj] * XX(ii-nt2+jj) ;
      x[ii] = sum ;
   }

   return ;
}
Example #10
0
int XX(int n){
	if (n == 0){
	   	   return 0;
		   }else{
		   		  return XX (n/3+1) + n;
                 }
				 }
Example #11
0
/* \def kernelRBF
* RBF kernel for support vector machine.
*/
Array SVM::kernelRBF(Array &X1, Array &X2, double sigma)
{
	int n1 = X1.rows;
	int n2 = X2.rows;
	int step = X1.cols;
	
	Array XX(n1, n2);
	
	double *_X1 = X1.getData();
	double *_X2 = X2.getData();
	double *_XX = XX.getData();

	double Z = 1 / sqrt(2 * M_PI * sigma * sigma);
	for(int i = 0;i < n1;i++)
	{
		for(int j = 0;j < n2;j++)
		{
			double dist = 0;
			for(int k = 0;k < step;k++)
				dist += ( _X1[i * step + k] - _X2[j * step + k] ) * ( _X1[i * step + k] - _X2[j * step + k] );
			
			_XX[i * n2 + j ] = Z * exp( -dist / (2 * sigma * sigma));
		}
	}
	return XX;
}
Example #12
0
static int bloch_jacobian(long int N, realtype t,
        N_Vector M, N_Vector fM, DlsMat J, void *user_data,
        N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
{
    struct bloch_sim *bs = (struct bloch_sim*)user_data;

    int i;
    for (i=0; i < bs->num_cells; ++i)
    {
        realtype dw = bs->cell_frequencies[i] - bs->w_avg;
        realtype w_1 = bs->rf_on ? bs->w_1 : 0.0;

        XX(J,i) = -1 / bs->T_2;
        XY(J,i) = dw;
        XZ(J,i) = 0.0;
        YX(J,i) = -dw;
        YY(J,i) = -1 / bs->T_2;
        YZ(J,i) = w_1;
        ZX(J,i) = 0.0;
        ZY(J,i) = -w_1;
        ZZ(J,i) = -1 / bs->T_1;
    }

    return 0;
}
Example #13
0
static PyObject * add_to_pointerlist(struct pointerlist *n, struct key_thing *other)
{
    HEX(n);
    HEX(other);
    INT(other->key);
    HEX(other->self);
    XX(print_pointerlist(n));
    if (n == NULL) {
	PyErr_SetString(PyExc_RuntimeError,
			"add_to_pointerlist: null list??");
	return NULL;
    }
    if (other == NULL) {
	PyErr_SetString(PyExc_RuntimeError,
			"add_to_pointerlist: second arg is NULL");
	return NULL;
    }
    if (other->key == 0) {
	printf("BADNESS: ");
	PyObject_Print(other->self, stdout, 0);
	printf("\n");

	PyErr_SetString(PyExc_RuntimeError,
			"add_to_pointerlist: key is zero");
	return NULL;
    }
    /* we already have somebody with the same key, so remove it */
    if (has_key(n, other->key) != NULL) {
	if (remove_from_pointerlist(n, other->key) == NULL)
	    return NULL;
    }
	n->size++;
    if (n->size > n->arraysize) {
	printf("GROW LIST FROM %d to %d\n", n->arraysize, 2 * n->arraysize);
	n->arraysize *= 2;
	n->lst = (struct key_thing **)
	    realloc(n->lst, n->arraysize * sizeof(struct key_thing *));
    }
	n->lst[n->size-1] = other;
	Py_INCREF(other->self);

    MARK();
    XX(print_pointerlist(n));
    Py_INCREF(Py_None);
    return Py_None;
}
std::string Ioss::Sym_Tensor_10::label(int which, const char) const
{
  assert(which > 0 && which <= component_count());
  switch(which) {
  case 1:  return XX();
  default: return "";
  }
}
Example #15
0
int ds_abort(const char * msg, const char * exp, const char * file, int line)
{
	int len;
	char buf[2048];
	char * pslash = NULL;
	PROCESS_MEMORY_COUNTERS pmc;

	DWORD error = GetLastError();
	DWORD wsa_error = WSAGetLastError();
	
	len = GetModuleFileName(NULL, buf, sizeof(buf));
	if (len > 0 && len < sizeof(buf)) {
		FILE * exception;
		pslash = strstr(buf, ".exe");
		if (pslash && !pslash[4]) {
			*pslash = 0;
		}
		strncat(buf, ".exception", sizeof(buf));
		
		exception = fopen(buf, "a");

		if (exception != NULL) {
			pmc.cb = sizeof(pmc);
			XP_GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc));
			fprintf(exception, "msg: %s\n", msg);
			fprintf(exception, "exp: %s\n", exp);
			fprintf(exception, "time: %ld\n", time(NULL));
			fprintf(exception, "error: %d, [%d]\n", error, wsa_error);
			fprintf(exception, "file %s, line %d\n", file, line);

#define XX(f) fprintf(exception, "%s: %uK %u\n", #f, pmc.f / 1024, pmc.f);
			XX(PageFaultCount);
			XX(WorkingSetSize);
			XX(QuotaPagedPoolUsage);
			XX(QuotaNonPagedPoolUsage);
			XX(PagefileUsage);
			XX(PeakWorkingSetSize);
			XX(QuotaPeakPagedPoolUsage);
			XX(QuotaPeakNonPagedPoolUsage);
			XX(PeakPagefileUsage);
#undef XX
			fclose(exception);
		}
	}

	RaiseException(EXCEPTION_BREAKPOINT, 0, 0, 0);
	abort();
	return 0;
}
Example #16
0
/* Makes fingerprint of file contents (all or part of it of fixed size).
 * Returns the fingerprint as a string, which is empty or NULL on error. */
static char *
get_contents_fingerprint(const char path[], const dir_entry_t *entry)
{
#if INTPTR_MAX == INT64_MAX
#define XX_BITS 64
#else
#define XX_BITS 32
#endif
#define XX__(name, bits) XXH ## bits ## _ ## name
#define XX_(name, bits) XX__(name, bits)
#define XX(name) XX_(name, XX_BITS)

	XX(state_t) st;
	char block[BLOCK_SIZE];
	size_t to_read = PREFIX_SIZE;
	FILE *in = os_fopen(path, "rb");
	if(in == NULL)
	{
		return strdup("");
	}

	XX(reset)(&st, 0U);
	while(to_read != 0U)
	{
		const size_t portion = MIN(sizeof(block), to_read);
		const size_t nread = fread(&block, 1, portion, in);
		if(nread == 0U)
		{
			break;
		}

		XX(update)(&st, block, nread);
		to_read -= nread;
	}
	fclose(in);

	return format_str("%" PRINTF_ULL "|%" PRINTF_ULL,
			(unsigned long long)entry->size, (unsigned long long)XX(digest)(&st));

#undef XX_BITS
#undef XX__
#undef XX_
#undef XX
}
Example #17
0
main() {
  setlocale(LC_ALL,"Portuguese");
  int n;
  int x;
  printf("Entre com um numero inteiro positivo: ");
  scanf("%d",&n);
  x = XX(n);
  printf("%d",x);
  getch();
}
std::string Ioss::Matrix_22::label(int which, const char) const
{
  assert(which > 0 && which <= component_count());
  switch(which) {
  case 1:  return XX();
  case 2:  return XY();
  case 3:  return YX();
  case 4:  return YY();
  default: return "";
  }
}
std::string Ioss::Sym_Tensor_33::label(int which, const char) const
{
  assert(which > 0 && which <= component_count());
  switch(which) {
  case 1:  return XX();
  case 2:  return YY();
  case 3:  return ZZ();
  case 4:  return XY();
  case 5:  return YZ();
  case 6:  return ZX();
  default: return "";
  }
}
Example #20
0
static PyObject *remove_from_pointerlist(struct pointerlist *head, unsigned int otherkey)
{
    int i;
    MARK();
    XX(printf("\n"));
    INT(otherkey);
    XX(print_pointerlist(head));
    if (head == NULL) {
	PyErr_SetString(PyExc_RuntimeError,
			"remove_from_pointerlist: empty list");
	return NULL;
    }
    MARK();
    /* find item to be removed, if it's here */
    for (i = 0; i < head->size; i++) {
	if (otherkey == head->lst[i]->key)
	    break;
    }
    MARK();
    if (i == head->size) {
	PyErr_SetString(PyExc_RuntimeError,
			"remove_from_pointerlist: no such entry");
	return NULL;
    }
    MARK();
    if (head->lst[i]->self == NULL) {
	PyErr_SetString(PyExc_RuntimeError,
			"remove_from_pointerlist: object to be removed is null");
	return NULL;
    }
    Py_DECREF(head->lst[i]->self);
    memmove(&head->lst[i], &head->lst[i+1],
	    (head->size - 1 - i) * sizeof(void*));
    head->size--;
    MARK();
    XX(print_pointerlist(head));
    Py_INCREF(Py_None);
    return Py_None;
}
Example #21
0
/* Sum spline on a grid ---------------------------------------------------- */
double sum_spatial_Bspline03_SimpleGrid(const SimpleGrid &grid)
{
    Matrix1D<double> gr(3), ur(3), corner1(3), corner2(3);
    int          i, j, k;
    double        sum = 0.0;

// Compute the limits of the spline in the grid coordinate system
    grid.universe2grid(vectorR3(-2.0, -2.0, -2.0), corner1);
    grid.universe2grid(vectorR3(2.0, 2.0, 2.0), corner2);

// Compute the sum in the points inside the grid
// The integer part of the vectors is taken for not picking points
// just in the border of the spline, which we know they are 0.
    for (i = (int)XX(corner1); i <= (int)XX(corner2); i++)
        for (j = (int)YY(corner1); j <= (int)YY(corner2); j++)
            for (k = (int)ZZ(corner1); k <= (int)ZZ(corner2); k++)
            {
                VECTOR_R3(gr, i, j, k);
                grid.grid2universe(gr, ur);
                sum += spatial_Bspline03(ur);
            }
    return sum;
}
Example #22
0
void				do_the_thing(t_env *e, float angle, int length, int change)
{
	(void)change;
	while (e->inc < 13)
	{
		// length = LY - e->yn;
		length = e->b;
		draw_polar(e->xn, e->yn, 270, length, e, VIOLET);
		length = e->mp - e->xn;
		e->mp = e->xn;
		draw_polar(XO, YO, 180, length, e, BLUE);
		length = get_both(XX(1), YY(1), LX, LY, e);
		draw_polar(XO, YO, angle, length, e, ORANGE);
	}
}
Example #23
0
/* Transform all coordinates ---------------------------------------------- */
void Micrograph::transform_coordinates(const Matrix2D<double> &M)
{
    Matrix1D<double> m(3);
    SPEED_UP_temps012;

    int imax = coords.size();
    for (int i = 0; i < imax; i++)
    {
        if (coords[i].valid)
        {
            VECTOR_R3(m, coords[i].X, coords[i].Y, 1);
            M3x3_BY_V3x1(m, M, m);
            coords[i].X = (int) XX(m);
            coords[i].Y = (int) YY(m);
        }
    }
}
Example #24
0
/* Passing to tilted ------------------------------------------------------- */
void TiltPairAligner::passToUntilted(int _mtX, int _mtY, int &_muX, int &_muY)
{
    if (Nu > 3)
    {
        SPEED_UP_temps012;

        VECTOR_R3(m, _mtX, _mtY, 1);
        M3x3_BY_V3x1(m, Ptu, m);
        _muX = (int) XX(m);
        _muY = (int) YY(m);
    }
    else
    {
        _muX = _mtX;
        _muY = _mtY;
    }
}
Example #25
0
static BOOL
PxImageView_OpenFileDialog(PxImageViewObject* self)
{
	OPENFILENAME ofn;
	wchar_t szFilter[] = L"Bitmap (*.BMP)\0*.bmp\0";
	wchar_t szOpenFileNamePath[MAX_PATH];

	ofn.lStructSize = sizeof(OPENFILENAME);
	ofn.hwndOwner = g.hWin;
	ofn.hInstance = NULL;
	ofn.lpstrFilter = szFilter;
	ofn.lpstrCustomFilter = NULL;
	ofn.nMaxCustFilter = 0;
	ofn.nFilterIndex = 0;
	ofn.lpstrFile = szOpenFileNamePath;
	ofn.nMaxFile = MAX_PATH;
	ofn.lpstrFileTitle = NULL;
	ofn.nMaxFileTitle = MAX_PATH;
	ofn.lpstrInitialDir = NULL;
	ofn.lpstrTitle = NULL; //L"Select File"
	ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; //OFN_HIDEREADONLY | OFN_CREATEPROMPT ;
	ofn.nFileOffset = 0;
	ofn.nFileExtension = 0;
	ofn.lpstrDefExt = L"bmp";
	ofn.lCustData = 0L;
	ofn.lpfnHook = NULL;
	ofn.lpTemplateName = NULL;

	OutputDebugString(L"PxImageView_OpenFileDialog\n");
	if (GetOpenFileNameW(&ofn)) {
		OutputDebugString(L"iv4!\n");
		LPCSTR sOpenFileNamePath = toU8(szOpenFileNamePath);
		MessageBoxA(NULL, sOpenFileNamePath, "jj", NULL);
		PyObject* pyArgs = Py_BuildValue("s", sOpenFileNamePath);
		PyObject* pyImage;
		PxASSIGN(pyImage = PyObject_CallObject((PyObject*)&PxImageType, pyArgs));
		XX(pyImage);
		Py_DECREF(pyArgs);
		PyMem_RawFree(sOpenFileNamePath);
		PxImageView_SetData(self, pyImage);
		Py_DECREF(pyImage);
	}
	return TRUE;
}
Example #26
0
/* \def kernelLinear
* Linear kernel for support vector machine.
*/
Array SVM::kernelLinear(Array &X1, Array &X2)
{
	int n1 = X1.rows;
	int n2 = X2.rows;
	
	Array XX(n1, n2);
	
	double *_X1 = X1.getData();
	double *_X2 = X2.getData();
	double *_XX = XX.getData();

	int step = XX.cols;
	for(int i = 0;i < XX.rows;i++)
	{
		for(int j = 0;j < XX.cols;j++)
			_XX[i * step + j ] = _X1[i] * _X2[j];
	}
	return XX;
}
Example #27
0
int main(int argc, char **argv){
    ros::init(argc,argv,"observer");
    ros::NodeHandle n;
    ros::Subscriber drone_sub = n.subscribe<visualization_msgs::Marker>("/drone",1000,callback_drone);
    ros::Subscriber est_sub = n.subscribe<visualization_msgs::Marker>("/drone_estimation",1000,callback_estim);
    ros::Publisher pub = n.advertise<std_msgs::Float64MultiArray>("/errors", 1000);

    ros::Rate loop_rate(100);
    std_msgs::Float64MultiArray msg;
    msg.layout.dim.push_back(std_msgs::MultiArrayDimension());
    msg.layout.dim[0].size = 3;
    msg.layout.dim[0].stride = 1;
    msg.layout.dim[0].label = "errors";

    D_VCT XXd(3,0);
    D_VCT XX(3,0);
    D_VCT::iterator i1 = XXd.begin();
    D_VCT::iterator i2 = XX.begin();
    Xd.assign(i1,XXd.end());
    X.assign(i2,XX.end());

    std::cout << Xd[0] << std::endl;

    std::cout << X[1] << std::endl;

    D_VCT Y(3,0);

    std::cout << "hello" << std::endl;

    while(ros::ok()){
        msg.data.clear();
        Y[0] = Xd[0]-X[0];
        Y[1] = Xd[1]-X[1];
        Y[2] = Xd[2]-X[2];
        std::cout << "hello" << std::endl;
        msg.data.insert(msg.data.end(),Y.begin(),Y.end());
        pub.publish(msg);

        ros::spinOnce();
        loop_rate.sleep();
    }
}
Example #28
0
void * resfunc_fixup(const char  * name)
{
#define XX(f) \
	if (strcmp(name, #f) == 0) { \
		printf("name: %s\n", name); \
		return (void *)f##fixup; \
	}

    XX(LoadIconW);
    XX(LoadIconA);
    XX(LoadAcceleratorsA);
    XX(LoadCursorA);
    XX(LoadCursorW);
    XX(LoadStringW);
    XX(LoadStringA);
#undef XX
    return NULL;
};
Example #29
0
  MVTR::MvtRegModel(const Mat &X,const Mat &Y, bool add_intercept)
    : ParamPolicy(new MatrixParams(X.ncol() + add_intercept,Y.ncol()),
		  new SpdParams(Y.ncol()),
		  new UnivParams(default_df))
  {
    Mat XX(add_intercept? cbind(1.0,X) : X);
    QR qr(XX);
    Mat Beta(qr.solve(qr.QtY(Y)));
    Mat resid = Y - XX* Beta;
    uint n = XX.nrow();
    Spd Sig = resid.t() * resid/n;

    set_Beta(Beta);
    set_Sigma(Sig);

    for(uint i=0; i<n; ++i){
      Vec y = Y.row(i);
      Vec x = XX.row(i);
      NEW(MvRegData, dp)(y,x);
      DataPolicy::add_data(dp);
    }
  }
SVECTORf BackPropagation::predict(const SVECTORf& X0)
{
	if ( options.get("mapping_type", "linear") == "linear")
	{
		size_t D = W.cols();
		SVECTORf XX(D);
		XX << X0, 1.0f;
		SVECTORf Yout = W * XX;
		return Yout;
	}
	else
	{
		SVECTORf logX0_ = X0.array().log();
		SVECTORf log_one_minux_X0_ = (1.0f-X0.array()).log();
		SVECTORf Yout = A.array() - (W * logX0_ + Q * log_one_minux_X0_).array();
		Yout = Yout.array() / (Yout.array() + B.array() - (S * logX0_ + T * log_one_minux_X0_).array() );
		return Yout;
	}

	std::cerr << "Internal error: BackPropagation::predict: specified method " << options.get("mapping_type", "") << " is not supported." << std::endl;
	exit(-1);

}