Exemple #1
0
void SMat<CoeffRing>::column2by2(size_t c1,
                                 size_t c2,
                                 elem a1,
                                 elem a2,
                                 elem b1,
                                 elem b2)
/* column(c1) <- a1 * column(c1) + a2 * column(c2),
   column(c2) <- b1 * column(c1) + b2 * column(c2)
*/
{
  // Make first column: v1 = a1*c1+a2*c2
  sparsevec *v1 = vec_copy(columns_[c1]);
  sparsevec *v2 = vec_copy(columns_[c2]);
  vec_scale(v1, a1);
  vec_scale(v2, a2);
  vec_add_to(v1, v2);

  // Second column: w1 = b1*c1 + b2*c2
  sparsevec *w1 = columns_[c1];
  sparsevec *w2 = columns_[c2];
  vec_scale(w1, b1);
  vec_scale(w2, b2);
  vec_add_to(w1, w2);

  // Set the matrices:
  columns_[c1] = v1;
  columns_[c2] = w1;
}
Exemple #2
0
// draw a line from a to b
void POV3DisplayDevice::line(float *a, float*b) {
  int i, j, test;
  float dirvec[3], unitdirvec[3];
  float from[3], to[3], tmp1[3], tmp2[3];

  if (lineStyle == ::SOLIDLINE) {
    // transform the world coordinates
    (transMat.top()).multpoint3d(a, from);
    (transMat.top()).multpoint3d(b, to);

//    write_materials();

    // Draw the line
    fprintf(outfile, "VMD_line(<%.4f,%.4f,%.4f>,<%.4f,%.4f,%.4f>,",
            from[0], from[1], -from[2], to[0], to[1], -to[2]);
    fprintf(outfile, "rgbt<%.3f,%.3f,%.3f,%.3f>)\n",
      matData[colorIndex][0], matData[colorIndex][1], matData[colorIndex][2],
      1 - mat_opacity);

  } 
  else if (lineStyle == ::DASHEDLINE) {
    // transform the world coordinates
    (transMat.top()).multpoint3d(a, tmp1);
    (transMat.top()).multpoint3d(b, tmp2);

    // how to create a dashed line
    vec_sub(dirvec, tmp2, tmp1);  // vector from a to b
    vec_copy(unitdirvec, dirvec);
    vec_normalize(unitdirvec);    // unit vector from a to b
    test = 1;
    i = 0;
    while (test == 1) {
      for (j=0; j<3; j++) {
        from[j] = (float) (tmp1[j] + (2*i)*DASH_LENGTH*unitdirvec[j]);
        to[j] =   (float) (tmp1[j] + (2*i + 1)*DASH_LENGTH*unitdirvec[j]);
      }
      if (fabsf(tmp1[0] - to[0]) >= fabsf(dirvec[0])) {
        vec_copy(to, tmp2);
        test = 0;
      }

//      write_materials();

      // Draw the line
      fprintf(outfile, "VMD_line(<%.4f,%.4f,%.4f>,<%.4f,%.4f,%.4f>,",
              from[0], from[1], -from[2], to[0], to[1], -to[2]);
      fprintf(outfile, "rgbt<%.3f,%.3f,%.3f,%.3f>)\n",
        matData[colorIndex][0], matData[colorIndex][1], matData[colorIndex][2],
        1 - mat_opacity);

      i++;
    }
  } 
  else {
    msgErr << "POV3DisplayDevice: Unknown line style " << lineStyle << sendmsg;
  }
}
Exemple #3
0
static void get_camera(vector eye, vector at, vector up)
{
	vector x, y, z;

	get_camera_frame(x, y, z);
	vec_copy(at, center);
	vec_copy(eye, center);
	vec_mad(eye, focal_len, z);
	vec_copy(up, y);
}
Exemple #4
0
void orthonormal_basis(const float b[9], float e[9]) {
  float ob[3*3];
  vec_copy(ob+0, b+0);
  vec_copy(e+0, ob+0);
  vec_normalize(e+0);
  vec_triad(ob+3, b+3, -dot_prod(e+0, b+3), e+0);
  vec_copy(e+3, ob+3);
  vec_normalize(e+3);
  vec_triad(ob+6,  b+6, -dot_prod(e+0, b+6), e+0);
  vec_triad(ob+6, ob+6, -dot_prod(e+3, b+6), e+3);
  vec_copy(e+6, ob+6);
  vec_normalize(e+6);
}
Exemple #5
0
int MoleculeGraphics::add_line(const float *x1, const float *x2, int style, int width) {
  ShapeClass s(LINE, 8, next_id);
  float *data = s.data;
  vec_copy(data+0, x1);
  vec_copy(data+3, x2);
  data[6] = float(style) + 0.1f;
  data[7] = float(width) + 0.1f;
  if (next_index < num_elements())
    shapes[next_index] = s;
  else
    shapes.append(s);
  return added();
}
// draw a line (cylinder) from a to b
void TachyonDisplayDevice::line(float *a, float*b) {
  int i, j, test;
  float dirvec[3], unitdirvec[3];
  float from[3], to[3], tmp1[3], tmp2[3];
    
  if (lineStyle == ::SOLIDLINE) {
    // transform the world coordinates
    (transMat.top()).multpoint3d(a, from);
    (transMat.top()).multpoint3d(b, to);
    
    // draw the cylinder
    fprintf(outfile, "FCylinder\n"); // flat-ended cylinder
    fprintf(outfile, "  Base %g %g %g\n", from[0], from[1], -from[2]); 
    fprintf(outfile, "  Apex %g %g %g\n", to[0], to[1], -to[2]);
    fprintf(outfile, "  Rad %g \n", float(lineWidth)*DEFAULT_RADIUS);
    write_cindexmaterial(colorIndex, materialIndex);

  } else if (lineStyle == ::DASHEDLINE) {
     // transform the world coordinates
    (transMat.top()).multpoint3d(a, tmp1);
    (transMat.top()).multpoint3d(b, tmp2);

    // how to create a dashed line
    vec_sub(dirvec, tmp2, tmp1);  // vector from a to b
    vec_copy(unitdirvec, dirvec);
    vec_normalize(unitdirvec);    // unit vector from a to b
    test = 1;
    i = 0;
    while (test == 1) {
      for (j=0; j<3; j++) {
        from[j] = (float) (tmp1[j] + (2*i    )*DASH_LENGTH*unitdirvec[j]);
          to[j] = (float) (tmp1[j] + (2*i + 1)*DASH_LENGTH*unitdirvec[j]);
      }
      if (fabsf(tmp1[0] - to[0]) >= fabsf(dirvec[0])) {
        vec_copy(to, tmp2);
        test = 0;
      }
    
      // draw the cylinder
      fprintf(outfile, "FCylinder\n"); // flat-ended cylinder
      fprintf(outfile, "  Base %g %g %g\n", from[0], from[1], -from[2]); 
      fprintf(outfile, "  Apex %g %g %g\n", to[0], to[1], -to[2]);
      fprintf(outfile, "  Rad %g \n", float(lineWidth)*DEFAULT_RADIUS);
      write_cindexmaterial(colorIndex, materialIndex);
      i++;
    }
  } else {
    msgErr << "TachyonDisplayDevice: Unknown line style " 
           << lineStyle << sendmsg;
  }
}
Exemple #7
0
int MoleculeGraphics::add_triangle(const float *x1, const float *x2, const float *x3) {
  // save the points
  ShapeClass s(TRIANGLE, 9, next_id);
  float *data = s.data;
  vec_copy(data+0, x1);
  vec_copy(data+3, x2);
  vec_copy(data+6, x3);
  
  // new one goes at next_id
  if (next_index < num_elements())
    shapes[next_index] = s;
  else
    shapes.append(s);
  return added();
}
// draw a line from a to b
void MayaDisplayDevice::line(float *a, float*b) {
  int i, j, test;
  float dirvec[3], unitdirvec[3];
  float from[3], to[3], tmp1[3], tmp2[3];
   
  if (lineStyle == ::SOLIDLINE) {
    // transform the world coordinates
    (transMat.top()).multpoint3d(a, from);
    (transMat.top()).multpoint3d(b, to);

    // draw the solid line
    fprintf(outfile, "// XXX lines not supported yet\n");
    fprintf(outfile, "// v %5f %5f %5f\n", from[0], from[1], -from[2]);
    fprintf(outfile, "// v %5f %5f %5f\n", to[0], to[1], -to[2]);
    fprintf(outfile, "// l -1 -2\n");
  } else if (lineStyle == ::DASHEDLINE) {
     // transform the world coordinates
    (transMat.top()).multpoint3d(a, tmp1);
    (transMat.top()).multpoint3d(b, tmp2);

    // how to create a dashed line
    vec_sub(dirvec, tmp2, tmp1);  // vector from a to b
    vec_copy(unitdirvec, dirvec);
    vec_normalize(unitdirvec);    // unit vector from a to b
    test = 1;
    i = 0;
    while (test == 1) {
      for (j=0; j<3; j++) {
        from[j] = (float) (tmp1[j] + (2*i    )*DASH_LENGTH*unitdirvec[j]);
          to[j] = (float) (tmp1[j] + (2*i + 1)*DASH_LENGTH*unitdirvec[j]);
      }
      if (fabsf(tmp1[0] - to[0]) >= fabsf(dirvec[0])) {
        vec_copy(to, tmp2);
        test = 0;
      }

      // draw the solid line dash
      fprintf(outfile, "// XXX lines not supported yet\n");
      fprintf(outfile, "// v %5f %5f %5f\n", from[0], from[1], -from[2]);
      fprintf(outfile, "// v %5f %5f %5f\n", to[0], to[1], -to[2]);
      fprintf(outfile, "// l -1 -2\n");
      i++;
    }
  } else {
    msgErr << "MayaDisplayDevice: Unknown line style "
           << lineStyle << sendmsg;
  }
}
Exemple #9
0
void SMat<CoeffRing>::vec_column_op(sparsevec *&v, const elem &a, sparsevec *w) const
    // v := v + a*w
{
  sparsevec *w1 = vec_copy(w);
  vec_scale(w1, a);
  vec_add_to(v, w1);
}
Exemple #10
0
void CDanBattleSys::AutoMoveDanMember()
{
	int				userIdx;
	int				zoneIdx;
	typedef std::list<int>		TEAM_LIST;
	typedef TEAM_LIST::iterator	TEAM_ITOR;

	TEAM_ITOR	iLoop;

	for (int TeamCount = 0; TeamCount < 2; TeamCount ++)
	{	
		for (iLoop=m_BattleTeam[TeamCount].begin();iLoop!=m_BattleTeam[TeamCount].end();iLoop++)
		{
			userIdx=(*iLoop);			
			
			vec_copy( g_logic.danbattlePortal[DANBATTLE_ATEAM_PORTAL +TeamCount].TargetPos, g_pc[userIdx].position );
			zoneIdx = GTH_Zone_UpdateCurrentZone(ENTITY_PC, g_pc[userIdx].idx, g_pc[userIdx].worldIdx, g_pc[userIdx].zoneIdx, g_pc[userIdx].position);
			g_pc[userIdx].zoneIdx = zoneIdx;
			
			GTH_SendPCEventMessage_Respawn( &g_pc[userIdx] );
			GTH_SendMessage_SyncItemObject( &g_pc[userIdx] );				
			
			
		}
	}
}
Exemple #11
0
GRAPH *
CopyGraph(GRAPH *graph)
{
    GRAPH *ret;
    struct _keyed *k;
    struct dveclist *link, *newlink;

    ret = NewGraph();
    bcopy(graph, ret, sizeof(GRAPH)); /* va: compatible pointer types */

    ret->graphid = RunningId - 1;   /* restore id */

    /* copy keyed */
    for (ret->keyed = NULL, k = graph->keyed; k; k = k->next)
        SaveText(ret, k->text, k->x, k->y);

    /* copy dvecs */
    ret->plotdata = NULL;
    for (link = graph->plotdata; link; link = link->next) {
        newlink = TMALLOC(struct dveclist, 1);
        newlink->next = ret->plotdata;
        newlink->vector = vec_copy(link->vector);
        /* vec_copy doesn't set v_color or v_linestyle */
        newlink->vector->v_color = link->vector->v_color;
        newlink->vector->v_linestyle = link->vector->v_linestyle;
        newlink->vector->v_flags |= VF_PERMANENT;
        ret->plotdata = newlink;
    }

    ret->commandline = copy(graph->commandline);
    ret->plotname = copy(graph->plotname);

    return (ret);
}
Exemple #12
0
/* add_particle() inserts a particle at a given position to the end of the 
 * frame, along with associated targets.
 * 
 * Arguments:
 * frame *frm - the frame to store the particle.
 * vec3d pos - position of inserted particle in the global coordinates.
 * int cand_inds[][MAX_CANDS] - indices of candidate targets for association
 *    with this particle.
 */
void add_particle(frame *frm, vec3d pos, int cand_inds[][MAX_CANDS]) {
    int num_parts, cam, _ix;
    P *ref_path_inf;
    corres *ref_corres;
    target **ref_targets;
    
    num_parts = frm->num_parts;
    ref_path_inf = &(frm->path_info[num_parts]);
    vec_copy(ref_path_inf->x, pos);
    reset_links(ref_path_inf);
    
    ref_corres = &(frm->correspond[num_parts]);
    ref_targets = frm->targets;
    for (cam = 0; cam < frm->num_cams; cam++) {
        ref_corres->p[cam] = CORRES_NONE;
        
        /* We always take the 1st candidate, apparently. Why did we fetch 4? */
        if(cand_inds[cam][0] != PT_UNUSED) {
            _ix = cand_inds[cam][0];
            ref_targets[cam][_ix].tnr = num_parts;
            ref_corres->p[cam] = _ix;
            ref_corres->nr = num_parts;
        }
    }
    frm->num_parts++;
}
Exemple #13
0
// draw a point
void X3DDisplayDevice::point(float * xyz) {
  float txyz[3];

  // transform the coordinates
  (transMat.top()).multpoint3d(xyz, txyz);

  // ugly and wasteful, but it will work
  fprintf(outfile, "<Shape>\n");
  fprintf(outfile, "  ");

  // Emit the point material properties
  fprintf(outfile, "<Appearance><Material ");
  fprintf(outfile, "ambientIntensity='%g' ", mat_ambient);
  fprintf(outfile, "diffuseColor='0 0 0' ");

  const float *rgb = matData[colorIndex];
  fprintf(outfile, "emissiveColor='%g %g %g' ",
          mat_diffuse * rgb[0], mat_diffuse * rgb[1], mat_diffuse * rgb[2]);
  fprintf(outfile, "/>");
  fprintf(outfile, "</Appearance>\n");

  fprintf(outfile, "  <PointSet>\n");
  fprintf(outfile, "    <Coordinate point='%g %g %g'/>\n",
          txyz[0], txyz[1], txyz[2]);
  
  float col[3];
  vec_copy(col, matData[colorIndex]);
  fprintf(outfile, "    <Color color='%g %g %g'/>\n", 
          col[0], col[1], col[2]);
  fprintf(outfile, "  </PointSet>\n");
  fprintf(outfile, "</Shape>\n");
}
void hotcold_gradient_lerp(float pucker_sum, float *rgb) {
  vec_zero(rgb); // set default color to black

  // hot to cold color map
  // Red (1, 0, 0) -> Yellow (1, 1, 0) -> Green (0, 1, 0) -> Cyan (0, 1, 1) -> blue (0, 0, 1)
  float     red[3] = {1.0f, 0.0f, 0.0f};
  float  yellow[3] = {1.0f, 1.0f, 0.0f};
  float yellow2[3] = {0.8f, 1.0f, 0.0f};
  float   green[3] = {0.0f, 1.0f, 0.0f};
  float  green2[3] = {0.6f, 1.0f, 0.0f};
  float    cyan[3] = {0.0f, 1.0f, 1.0f};
  float   cyan2[3] = {0.0f, 1.0f, 0.8f};
  float    blue[3] = {0.0f, 0.0f, 1.0f};

  if (pucker_sum < 0.25f) {
    lerp_color_range(rgb, pucker_sum, 0.00f, 0.25f, red, yellow);
  } else if (pucker_sum < 0.45f) {
    vec_copy(rgb, yellow);
  } else if (pucker_sum < 0.55f) {
    lerp_color_range(rgb, pucker_sum, 0.45f, 0.55f, yellow, green2);
  } else if (pucker_sum < 0.75f) {
    lerp_color_range(rgb, pucker_sum, 0.55f, 0.75f, green, cyan2);
  } else {
    lerp_color_range(rgb, pucker_sum, 0.75f, 1.00f, cyan, blue);
  }

  clamp_color(rgb); // clamp color values to legal range
}
// Calculates the position at point t along the spline with co-efficients
// A, B, C and D.
// spline(t) = ((A * t + B) * t + C) * t + D
void ribbon_spline(float *pos, const float * const A, const float * const B,
                   const float * const C, const float * const D, const float t) {
  vec_copy(pos,D);
  vec_scaled_add(pos,t,C);
  vec_scaled_add(pos,t*t,B);
  vec_scaled_add(pos,t*t*t,A);
}
Exemple #16
0
VrArrayPtrCF32 BlasComplexSingle::transpose(VrArrayPtrCF32 A) {
	 VrArrayPtrCF32 B;
	 int dims[2];
	 if(VR_GET_DIMS_CF32(A)[0]==1 || VR_GET_DIMS_CF32(A)[1]==1) {
	 
	      B=vec_copy(VR_GET_NDIMS_CF32(A),A);
	      dim_type temp= VR_GET_DIMS_CF32(B)[0];
	      VR_GET_DIMS_CF32(B)[0] =VR_GET_DIMS_CF32(B)[1];
	      VR_GET_DIMS_CF32(B)[1] = temp;
	      return B;
	 }
	 dims[1]=VR_GET_DIMS_CF32(A)[0];
	 dims[0]=VR_GET_DIMS_CF32(A)[1];
	 B= vrAllocArrayF32CM(2,0,dims);
	 int row= VR_GET_DIMS_CF32(A)[0];
	 int col= VR_GET_DIMS_CF32(A)[1];
	 float complex *out =VR_GET_DATA_CF32(B);
	 float complex *in =VR_GET_DATA_CF32(A);
	 for(int i=0;i<row;i++){
	   for(int j=0;j<col;j++) {
	   
	     out[i*col+j] = conj(in[j*row +i]);
	  }
	  
	 }
	return B;
}
Exemple #17
0
folge_p
folge_copy( folge_p f) {
	folge_p  back;
	int  k, size;
	vec_p  start, lang;

	start = vec_copy( f->start );
	lang = vec_copy( f->lang );
	size = vec_size( lang );
	back = folge_new( start, lang );
	for(k=0;k<size;k++) {
		back->glied[k] = f->glied[k];
	}

	return back;
}
Exemple #18
0
int MoleculeGraphics::add_cone(const float *x1, const float *x2, float rad, float radsq, int n) {
  // save the points
  ShapeClass s(CONE, 9, next_id);
  float *data = s.data;
  vec_copy(data+0, x1);
  vec_copy(data+3, x2);
  data[6] = rad;
  data[7] = float(n) + 0.1f;
  data[8] = radsq;
  
  // new one goes at next_id
  if (next_index < num_elements())
    shapes[next_index] = s;
  else
    shapes.append(s);
  return added();
}
void CHelperManager_Encoder::PC_SetSummonsInfo(
	playerCharacter_t *pHelper, char *name, int worldIdx, vec3_t position)
{
	strcpy(pHelper->summonsInfo.summoner, name);
	pHelper->summonsInfo.worldIdx = worldIdx;
	vec_copy(position, pHelper->summonsInfo.position);
	
}
Exemple #20
0
int MoleculeGraphics::add_cylinder(const float *x1, const float *x2, float rad,
                                   int n, int filled) {
  ShapeClass s(CYLINDER, 9, next_id);
  float *data = s.data;
  vec_copy(data+0, x1);
  vec_copy(data+3, x2);
  data[6] = rad;
  data[7] = float(n) + 0.1f;
  data[8] = float(filled) + 0.1f;
  
  // new one goes at next_id
  if (next_index < num_elements())
    shapes[next_index] = s;
  else
    shapes.append(s);
  return added();
}
Exemple #21
0
static void
gr_start_internal(struct dvec *dv, bool copyvec)
{
    struct dveclist *link;

    /* Do something special with poles and zeros.  Poles are 'x's, and
     * zeros are 'o's.  */
    if (dv->v_type == SV_POLE) {
        dv->v_linestyle = 'x';
        return;
    } else if (dv->v_type == SV_ZERO) {
        dv->v_linestyle = 'o';
        return;
    }

    /* Find a (hopefully) new line style and color. */
    if (currentgraph->plottype == PLOT_POINT) {
        if (pointchars[cur.linestyle - 1])
            cur.linestyle++;
        else
            cur.linestyle = 2;
    } else if ((cur.linestyle > 0) && (++cur.linestyle == dispdev->numlinestyles)) {
        cur.linestyle = 2;
    }

    if ((cur.color > 0) && (++cur.color == dispdev->numcolors))
        cur.color = (((currentgraph->grid.gridtype == GRID_SMITH ||
                      currentgraph->grid.gridtype == GRID_SMITHGRID) &&
                     (dispdev->numcolors > 3)) ? 4 : 2);

    if (currentgraph->plottype == PLOT_POINT)
        dv->v_linestyle = pointchars[cur.linestyle - 2];
    else
        dv->v_linestyle = cur.linestyle;

    dv->v_color = cur.color;

    /* save the data so we can refresh */
    link = TMALLOC(struct dveclist, 1);
    link->next = currentgraph->plotdata;

    if (copyvec) {
        link->vector = vec_copy(dv);
        /* vec_copy doesn't set v_color or v_linestyle */
        link->vector->v_color = dv->v_color;
        link->vector->v_linestyle = dv->v_linestyle;
        link->vector->v_flags |= VF_PERMANENT;
    } else {
        link->vector = dv;
    }

    currentgraph->plotdata = link;

    /* Put the legend entry on the screen. */
    drawlegend(currentgraph, cur.plotno, dv);

    cur.plotno++;
}
Exemple #22
0
END_TEST

START_TEST(test_vec_copy)
{
    vec3d src = {1., 2., 3.}, dst;
    vec_copy(dst, src);

    fail_unless(vec_cmp(dst, src));
}
Exemple #23
0
VrArrayPtrCF64 BlasComplexDouble::mat_ldiv(int matrix_order ,VrArrayPtrCF64 A, VrArrayPtrCF64 B) {

    VrArrayPtrCF64 C = vec_copy(VR_GET_NDIMS_CF64(B),B);
   VrArrayPtrCF64 D = vec_copy(VR_GET_NDIMS_CF64(A),A);
   double complex* data= VR_GET_DATA_CF64(D);
   double complex * out_data=VR_GET_DATA_CF64(C);
   long int lda=(long int)VR_GET_DIMS_CF64(D)[0];
   long int ldb= (long int)VR_GET_DIMS_CF64(C)[0];
   long int n=(long int )VR_GET_DIMS_CF64(D)[1];
   long int nrhs= (long int )VR_GET_DIMS_CF64(C)[1];
  int  *IPIV=(int*)VR_MALLOC(sizeof(int)*n);
  long int info=0;
  
 // dgesv_(&n,&nrhs,data,&lda,IPIV,out_data,&ldb,&info);
    info= LAPACKE_zgesv(LAPACK_COL_MAJOR,n,nrhs,data,lda,IPIV,out_data,ldb);

  
 return C; 
}
Exemple #24
0
folgen_vektor_p
folgen_vektor_projekt(folgen_vektor_p f,folgen_vektor_p g) {
	folgen_vektor_p  back;
	int  k, size_g, test, dim, d, i;
	vec_p  grad, r, n_f, n_g, start, lang, vec_1;

	ASSERT( f->grad->dim == g->grad->dim );
	dim = f->grad->dim;
	vec_1 = vec_one( dim );

	n_g = vec_add( g->grad, vec_1 );
	n_f = vec_add( f->grad, vec_1 );

	size_g = vec_size( n_g );
	grad = vec_copy( g->grad );
	back = folgen_vektor_new( grad );
	for(k=0;k<size_g;k++) {
		r = entry_one2d( k, n_g );
		test = 0;
		for(d=0;d<dim;d++) {
			if( r->array[d] > f->grad->array[d] ) {
				test = test + 1;
			}
		}
		if(test == 0) {
			i = entry_d2one( r, n_f );
			folge_del( back->vektor[k] );
			back->vektor[k] = folge_projekt( f->vektor[i], g->vektor[k] );
		}
		else {
			folge_del( back->vektor[k] );
			start = vec_copy( g->vektor[k]->start );
			lang = vec_copy( g->vektor[k]->lang );
			back->vektor[k] = folge_new( start, lang );
		}
		vec_del( r );
	}
	vec_del( vec_1 );
	vec_del( n_g );
	vec_del( n_f );

	return back;
}
Exemple #25
0
VrArrayPtrCF32 BlasComplexSingle::elem_mult(VrArrayPtrCF32 A, VrArrayPtrCF32 B) {
  if ( !checkdims<VrArrayCF32>(A,B) ) {
    std::cout<<"dimensions do not match. \n Exiting. "<<std::endl;
    exit(0);
  }
  VrArrayPtrCF32 C = vec_copy(VR_GET_NDIMS_CF32(A),A);
  for (int i = 0; i < getNumElem(VR_GET_DIMS_CF32(A),VR_GET_NDIMS_CF32(A)); i++) {
    VR_GET_DATA_CF32(C)[i] *= VR_GET_DATA_CF32(B)[i];
  }
  return C;
}
Exemple #26
0
VrArrayPtrCF32 BlasComplexSingle::scal_mult(int ndims,VrArrayPtrCF32 X,float complex alpha) {
        int N=1;
        for(int i=0;i<ndims;i++){
                N*=VR_GET_DIMS_CF32(X)[i];
        }
	VrArrayPtrCF32 Y;//=(VrArrayPtrCF32)mxMalloc(sizeof(VrArrayPtrCF32));
	Y=vec_copy(ndims,X);
	//mxDuplicateArray(X);
        cblas_cscal(N,reinterpret_cast<float*>(&alpha),(float*)VR_GET_DATA_CF32(Y),1);
	return Y;
}
Exemple #27
0
VrArrayPtrCF64 BlasComplexDouble::scal_mult(int ndims,VrArrayPtrCF64 X,double complex alpha){
        int N=1;
        for(int i=0;i<ndims;i++){
                N*=VR_GET_DIMS_CF64(X)[i];
        }
	//mexPrintf("%d",N);
	double alph[] = {1,0};
	VrArrayPtrCF64 Y=vec_copy(ndims,X);
    cblas_zscal(N,(alph),(double*)VR_GET_DATA_CF64(Y),1);
	return Y;
}
Exemple #28
0
VrArrayPtrCF32 BlasComplexSingle::vec_sub(int ndims, VrArrayPtrCF32 X, VrArrayPtrCF32 Y , const float complex alpha, const int incX, const int incY) {
        VrArrayPtrCF32 X1 =vec_copy(VR_GET_NDIMS_CF32(X),X);
        /*if(cimag(alpha)!=1){
                VrArrayPtrCF32 X1=vrAllocArrayF32CM(ndims,0,(int*)VR_GET_DIMS_CF32(X));
                X1=BlasComplexSingle::scal_mult(ndims,X,alpha);

        }*/
	//float arr[]={-1,0};  
	float complex arr = -1 ; 
        return vec_add(ndims, Y,X1, arr);
}
Exemple #29
0
VrArrayPtrCF32 BlasComplexSingle::mat_ldiv(int matrix_order, VrArrayPtrCF32 A, VrArrayPtrCF32 B) {
VrArrayPtrCF32 C = vec_copy(VR_GET_NDIMS_CF32(B),B);
   VrArrayPtrCF32 D = vec_copy(VR_GET_NDIMS_CF32(A),A);
   float complex * data= VR_GET_DATA_CF32(D);
   float complex * out_data=VR_GET_DATA_CF32(C);
   long int lda=(long int)VR_GET_DIMS_CF32(D)[0];
   long int ldb= (long int)VR_GET_DIMS_CF32(C)[0];
   long int n=(long int )VR_GET_DIMS_CF32(D)[1];
   long int nrhs= (long int )VR_GET_DIMS_CF32(C)[1];
  int  *IPIV=(int*)VR_MALLOC(sizeof(int)*n);
  long int info=0;
  

    info= LAPACKE_cgesv(LAPACK_COL_MAJOR,n,nrhs,data,lda,IPIV,out_data,ldb);
    
    
  
 return C;
  
}
Exemple #30
0
void set_destination(double *v)
{
	int i;
	double dif[MAX_DIM];
	vec_copy(origin, position);
	vec_copy(destination, v);
	tim = 0.0;
	delta_t = feedrate_begin;
	dist = vec_dist(position, v);
	if(dist == 0.0) {
		vec_clear(incvec);
		for(i = 0; i < MAX_DIM; i++)
			amp[i] = amplitude_dc;
		return;
	}
	vec_diff(dif, v, origin);
	for(i = 0; i < MAX_DIM; i++)
		incvec[i] = dif[i] / dist;
	calc_amplitude();
}