本文整理汇总了C++中read_vector函数的典型用法代码示例。如果您正苦于以下问题:C++ read_vector函数的具体用法?C++ read_vector怎么用?C++ read_vector使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read_vector函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: load_system
/* load a solar system specification from file, return NULL on failure */
System* load_system(FILE* file)
{
int nplanets;
long long steps_to_write;
Float duration, time_step;
fscanf(file, "%d " FLOAT_SCANF_FORMAT " " FLOAT_SCANF_FORMAT " %lld",
&nplanets, &duration, &time_step, &steps_to_write);
System* sys = alloc_system(nplanets);
if(!sys || duration < time_step)
{
free(sys);
return NULL;
}
sys->time_step = time_step;
sys->nplanets = nplanets;
sys->cur_step = 0;
sys->nsteps = ceil(duration / time_step);
if(steps_to_write > sys->nsteps)
steps_to_write = sys->nsteps;
sys->print_period = (long long)((double)sys->nsteps / steps_to_write);
for(int i = 0; i < nplanets; i++)
{
fscanf(file, FLOAT_SCANF_FORMAT, &sys->planets[i].mass);
read_vector(file, sys->planets[i].position);
read_vector(file, sys->planets[i].velocity);
}
return sys;
}
开发者ID:dezgeg,项目名称:PlanetSim,代码行数:31,代码来源:planet.c
示例2: load_data
// Read binary ROM data for basis functions and coefficients
static int load_data(const char dir[], gsl_vector *cvec_amp, gsl_vector *cvec_phi, gsl_matrix *Bamp, gsl_matrix *Bphi, gsl_vector *cvec_amp_pre) {
// Load binary data for amplitude and phase spline coefficients as computed in Mathematica
int ret = XLAL_SUCCESS;
ret |= read_vector(dir, "SEOBNRv1ROM_SS_Amp_ciall.dat", cvec_amp);
ret |= read_vector(dir, "SEOBNRv1ROM_SS_Phase_ciall.dat", cvec_phi);
ret |= read_matrix(dir, "SEOBNRv1ROM_SS_Bamp_bin.dat", Bamp);
ret |= read_matrix(dir, "SEOBNRv1ROM_SS_Bphase_bin.dat", Bphi);
ret |= read_vector(dir, "SEOBNRv1ROM_SS_AmpPrefac_ci.dat", cvec_amp_pre);
return(ret);
}
开发者ID:astrophysicsvivien,项目名称:lalsuite,代码行数:11,代码来源:LALSimIMRSEOBNRv1ROMEffectiveSpin.c
示例3: decodeRig
static bool decodeRig(fsMsgRig &_msg, const std::string &buffer, Size &start) {
bool success = true;
success &= read_vector(_msg.mesh().m_quads,buffer,start); // read quads
success &= read_vector(_msg.mesh().m_tris,buffer,start); // read triangles
success &= read_vector(_msg.mesh().m_vertex_data.m_vertices,buffer,start);// read neutral vertices
success &= read_small_vector(_msg.blendshape_names(),buffer,start); // read names
uint16_t bsize = 0;
success &= read_pod(bsize,buffer,start);
_msg.blendshapes().resize(bsize);
for(uint16_t i = 0;i < bsize; i++)
success &= read_vector(_msg.blendshapes()[i].m_vertices,buffer,start); // read blendshapes
return success;
}
开发者ID:GuillaumeGibert,项目名称:swooz,代码行数:13,代码来源:fsbinarystream.cpp
示例4: f_plane
int f_plane(ULONG *arg)
{
rsiVECTOR vec;
void *plane,*surf,*actor;
rsiResult err;
if (!arg[0])
return ERROR_SURFACE;
surf = FindSurfListItem((char*)arg[0]);
if (!surf)
return rsiERR_SURFACE;
err = rsiCreatePlane(&plane,surf);
if (err)
return err;
if (arg[1])
{
if (!read_vector(&vec,(char*)arg[1]))
return ERROR_VECTOR;
err = rsiSetPlane(plane, rsiTPlanePos, &vec, rsiTDone);
if (err)
return err;
}
if (arg[2])
{
if (!read_vector(&vec,(char*)arg[2]))
return ERROR_VECTOR;
err = rsiSetPlane(plane, rsiTPlaneNorm, &vec, rsiTDone);
if (err)
return err;
}
if (arg[3])
{
actor = FindActorListItem((char*)arg[3]);
if (!actor)
return rsiERR_ACTOR;
err = rsiSetPlane(plane,rsiTPlaneActor,actor,rsiTDone);
if (err)
return err;
}
return rsiERR_NONE;
}
开发者ID:Kalamatee,项目名称:RayStorm,代码行数:48,代码来源:parser.cpp
示例5: TEST
TEST(rust, MP4Metadata)
{
FILE* f = fopen("street.mp4", "rb");
ASSERT_TRUE(f != nullptr);
// Read just the moov header to work around the parser
// treating mid-box eof as an error.
//read_vector reader = read_vector(f, 1061);
struct stat s;
ASSERT_EQ(0, fstat(fileno(f), &s));
read_vector reader = read_vector(f, s.st_size);
fclose(f);
mp4parse_io io = { vector_reader, &reader };
mp4parse_parser* context = mp4parse_new(&io);
ASSERT_NE(nullptr, context);
mp4parse_error rv = mp4parse_read(context);
EXPECT_EQ(MP4PARSE_OK, rv);
uint32_t tracks = 0;
rv = mp4parse_get_track_count(context, &tracks);
EXPECT_EQ(MP4PARSE_OK, rv);
EXPECT_EQ(2U, tracks);
mp4parse_free(context);
}
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:26,代码来源:TestMP4Rust.cpp
示例6: scm_proc_read
/* R5RS library procedure read
* (read)
* (read [port])
*/
SCM scm_proc_read(FILE *file)
{
int c = skip_comment_and_space(file);
switch (c) {
case '(':
return read_list(file);
case ')': /* List end */
scheme_error("symtax error");
case '[':
case ']':
scheme_error("unsupport bracket");
case '{':
case '}':
scheme_error("unsupport brace");
case '|':
scheme_error("unsupport bar");
case '#':
c = fgetc(file);
if ('(' == c) {
return read_vector(file);
} else {
ungetc(c, file);
return read_simple_datum(file, '#');
}
case '\'': /* Quotation */
return new_cons(SCM_SYMBOL_QUOTE, new_cons(scm_proc_read(file), SCM_NULL));
case '`': /* Quasiquotation */
scheme_error("unsupport quasiquotation");
case ',': /* (Splicing) Uuquotation */
scheme_error("unsupport (splicing) unquotation");
default:
return read_simple_datum(file, c);
}
}
开发者ID:troter,项目名称:thesis,代码行数:39,代码来源:read.c
示例7: sphere
ULONG sphere(ULONG *arg)
{
rsiVECTOR vec;
float fnum;
void *sphere,*surf,*actor;
rsiResult err;
surf = FindSurfListItem((char*)arg[0]);
if(!surf)
return rsiERR_SURFACE;
err = rsiCreateSphere(CTXT, &sphere,surf);
if(err)
return err;
if(!read_vector(&vec,(char*)arg[1]))
return ERROR_VECTOR;
err = rsiSetSphere(CTXT, sphere,rsiTSpherePos,&vec,rsiTDone);
if(err)
return err;
fnum = (float)atof((char*)arg[2]);
err = rsiSetSphere(CTXT, sphere,rsiTSphereRadius,fnum,rsiTDone);
if(err)
return err;
if(arg[3])
{
actor = FindActorListItem((char*)arg[3]);
if(!actor)
return rsiERR_ACTOR;
err = rsiSetSphere(CTXT, sphere,rsiTSphereActor,actor,rsiTDone);
if(err)
return err;
}
if(arg[4])
{
fnum = (float)atof((char*)arg[4]);
err = rsiSetSphere(CTXT, sphere,rsiTSphereFuzzy,fnum,rsiTDone);
if(err)
return err;
}
if(arg[5])
{
err = rsiSetSphere(CTXT, sphere,rsiTSphereFlags,rsiFSphereInverted,rsiTDone);
if(err)
return err;
}
if(insideCSG > 0)
{
SetCSGObject(sphere);
insideCSG--;
}
return rsiERR_NONE;
}
开发者ID:privatosan,项目名称:RayStorm,代码行数:60,代码来源:interface.cpp
示例8: sizeof
void GameObjectMessage::read_object_points() {
char point_count;
socket_->read_buffer(&point_count, sizeof(char));
for (char i = 0; i < point_count; i++) {
points_.push_back(read_vector(socket_));
}
}
开发者ID:tinchou,项目名称:bluesjackrabbit,代码行数:7,代码来源:GameObjectMessage.cpp
示例9: read_uint32
void GameObjectMessage::read() {
object_id_ = read_uint32(socket_);
position_ = read_vector(socket_);
object_type_ = read_char(socket_);
read_object_points();
alive_ = read_bool(socket_);
}
开发者ID:tinchou,项目名称:bluesjackrabbit,代码行数:7,代码来源:GameObjectMessage.cpp
示例10: size
ULONG size(ULONG *arg)
{
rsiVECTOR vec;
float begin,end;
int flags = rsiFActionLinear;
if(!actor)
return rsiERR_ACTOR;
begin = (float)atof((char*)arg[0]);
end = (float)atof((char*)arg[1]);
if(!read_vector(&vec,(char*)arg[2]))
return ERROR_VECTOR;
if(arg[3])
{
if(KEYWORD((char*)arg[3], "LINEAR"))
flags |= rsiFActionLinear;
else
if(KEYWORD((char*)arg[3], "SPLINE"))
flags |= rsiFActionSpline;
else
return ERROR_INTERPOL;
}
return rsiSize(CTXT, actor->item,begin,end,&vec,/*rsiTSizeFlags,flags,*/rsiTDone);
}
开发者ID:privatosan,项目名称:RayStorm,代码行数:28,代码来源:interface.cpp
示例11: f_alignment
int f_alignment(ULONG *arg)
{
rsiVECTOR vec;
float begin,end;
int flags = rsiFActionLinear;
if (!actor)
return rsiERR_ACTOR;
begin = end = 0;
if (arg[0])
begin = (float)atof((char*)arg[0]);
if (arg[1])
end = (float)atof((char*)arg[1]);
if (!read_vector(&vec,(char*)arg[2]))
return ERROR_VECTOR;
if (arg[3])
{
if (!stricmp((char*)arg[3], "LINEAR"))
flags |= rsiFActionLinear;
else
if (!stricmp((char*)arg[3], "SPLINE"))
flags |= rsiFActionSpline;
else
return ERROR_INTERPOL;
}
return rsiAlignment(actor->item,begin,end,&vec,rsiTAlignFlags,flags,rsiTDone);
}
开发者ID:Kalamatee,项目名称:RayStorm,代码行数:33,代码来源:parser.cpp
示例12: to_string
NurbsOverAdaptedGrid::NurbsOverAdaptedGrid(int depth) {
string d = to_string(depth);
string grid_file = "grid-" + d + ".dat";
string cmd = "./generate --knots " + d + " > " + grid_file;
system(cmd.c_str());
ifstream fin(grid_file);
int N; // number of elements
fin >> N;
for (int i = 0; i < N; i++) {
Bounds b;
fin >> b.left >> b.right >> b.up >> b.down;
}
int M; // number of B-splines
fin >> M;
for (int i = 0; i < M; i++) {
string type;
// Regular or Gnomon
fin >> type;
if (type == "Regular") {
vector<double> x_knots, y_knots;
read_vector(fin, &x_knots, 4);
read_vector(fin, &y_knots, 4);
Bspline* regular = new Bspline(x_knots, y_knots);
unscaled_bsplines.push_back(regular);
} else { // type == "Gnomon"
double x_mid, y_mid, shift_x, shift_y;
fin >> x_mid >> y_mid >> shift_x >> shift_y;
GnomonBspline* gnomon = new GnomonBspline(x_mid, y_mid, shift_x, shift_y);
unscaled_bsplines.push_back(gnomon);
}
}
LinearCombination* sum_of_unscaled = new LinearCombination(unscaled_bsplines);
for (const Function2D* unscaled_bspline: unscaled_bsplines) {
const GnomonBspline* gb = dynamic_cast<const GnomonBspline*>(unscaled_bspline);
Quotient* scaled_bspline;
if (gb != nullptr)
scaled_bspline = new GnomonNurbs(*gb, *sum_of_unscaled);
else
scaled_bspline = new Quotient(*unscaled_bspline, *sum_of_unscaled);
scaled_bsplines.push_back(scaled_bspline);
}
}
开发者ID:tilius,项目名称:bspline-singularities-galois,代码行数:45,代码来源:bspline-non-rect.cpp
示例13: read_vector
bool read_vector(const std::string& filename, boost::numeric::ublas::vector<T>& v) {
FILE* file = fopen(filename.c_str(), "rb");
if (!file)
return false;
bool res = read_vector(file, v);
fclose(file);
return res;
}
开发者ID:e-thereal,项目名称:gapputils,代码行数:9,代码来源:ublas_io.hpp
示例14: option_b
void option_b() {
/* Method solves the second subproblem:
* Given a vector of numbers, find the longest increasing contiguous subsequence.
*/
vector v = read_vector();
printf("Longest increasing contiguous subsequence: ");
print_vector(get_longest_increasing_subsequence(v));
}
开发者ID:harababurel,项目名称:homework,代码行数:9,代码来源:1.c
示例15: triangle
ULONG triangle(ULONG *arg)
{
void *surf,*actor=NULL;
int i;
rsiVECTOR v[3];
rsiVECTOR n[3];
surf = FindSurfListItem((char*)arg[0]);
if(!surf)
return rsiERR_SURFACE;
for(i=0; i<3; i++)
{
if(!read_vector(&v[i],(char*)arg[i+1]))
return ERROR_VECTOR;
}
if(arg[7])
{
actor = FindActorListItem((char*)arg[7]);
if(!actor)
return rsiERR_ACTOR;
}
if(arg[4])
{
for(i=0; i<3; i++)
{
if(arg[i+4])
{
if(!read_vector(&n[i],(char*)arg[i+4]))
return ERROR_VECTOR;
}
}
return rsiCreateTriangle(CTXT, surf, &v[0], &v[1], &v[2],
rsiTTriangleActor, actor,
rsiTTriangleNorm1, &n[0],
rsiTTriangleNorm2, &n[1],
rsiTTriangleNorm3, &n[2], rsiTDone);
}
else
return rsiCreateTriangle(CTXT, surf, &v[0], &v[1], &v[2],
rsiTTriangleActor, actor, rsiTDone);
}
开发者ID:privatosan,项目名称:RayStorm,代码行数:44,代码来源:interface.cpp
示例16: main
int main(int argc, char * args[]){
int i,j,it;
unsigned long long counter, stop;
char a[256], b[256];
FILE * f;
f = fopen("results.txt","w");
for(it=2; it<=13; it++){
fprintf(f,"%d ",it);
sprintf(a,"mat_%d_a.mat",it);
sprintf(b,"mat_%d_b.mat",it);
int a_row = (int)pow(2,it), a_column = (int)pow(2,it), b_row = (int)pow(2,it), b_column = 1;
//alokacja pamięci na macierze
float ** m1 = read_matrix(a,a_row,a_column);
float * m2 = read_vector(b,b_row);
float * mw1 = (float*)malloc(a_row* sizeof(float));
for(i=0; i<a_row; i++)
mw1[i] = 0;
counter = rdtsc();
mul(mw1,m1,m2,a_row);
stop = rdtsc() - counter;
fprintf(f,"%llu ",stop / (int)pow(2,2*it));
printf("%d\n",it);
for(i=0; i<a_row; i++)
mw1[i] = 0;
counter = rdtsc();
mul6(mw1,m1,m2,a_row);
stop = rdtsc() - counter;
fprintf(f,"%llu ",stop / (int)pow(2,2*it));
printf("%d\n",it);
//print_matrix(mw1,a_row);
//zwalnianie pamięci
for(i=0; i<a_row; i++)
free(m1[i]);
free(m1);
free(m2);
free(mw1);
fprintf(f,"\n");
}
fclose(f);
return 0;
}
开发者ID:DaniCF93,项目名称:studia,代码行数:56,代码来源:matrix.c
示例17: read_matrix
double* read_matrix(double *a, int n, int m)
{
int j;
for (j=0; j<n; j++) {
read_vector(a+j*m, m);
}
return a;
}
开发者ID:kolyuchiy,项目名称:slau-mpi,代码行数:10,代码来源:util2.c
示例18: f_newactor
int f_newactor(ULONG *arg)
{
rsiVECTOR vec;
void *act;
rsiResult err;
err = rsiCreateActor(&act);
if (err)
return err;
if (!arg[0])
return ERROR_STRINGEXP;
actor = AddActorList((char*)arg[0],act);
if (!actor)
return rsiERR_MEM;
if (arg[1])
{
if (!read_vector(&vec,(char*)arg[1]))
return ERROR_VECTOR;
err = rsiSetActor(act,rsiTActorPos,&vec,rsiTDone);
if (err)
return err;
}
if (arg[2])
{
if (!read_vector(&vec,(char*)arg[2]))
return ERROR_VECTOR;
err = rsiSetActor(act,rsiTActorAlign,&vec,rsiTDone);
if (err)
return err;
}
if (arg[3])
{
if (!read_vector(&vec,(char*)arg[3]))
return ERROR_VECTOR;
err = rsiSetActor(act,rsiTActorSize,&vec,rsiTDone);
if (err)
return err;
}
return rsiERR_NONE;
}
开发者ID:Kalamatee,项目名称:RayStorm,代码行数:43,代码来源:parser.cpp
示例19: loadobj
ULONG loadobj(ULONG *arg)
{
rsiVECTOR pos = {0.,0.,0.}, align = {0.,0.,0.}, scale = {1.,1.,1.};
void *surf=NULL,*actor=NULL;
if(arg[1])
{
if(!read_vector(&pos,(char*)arg[1]))
return ERROR_VECTOR;
}
if(arg[2])
{
if(!read_vector(&align,(char*)arg[2]))
return ERROR_VECTOR;
}
if(arg[3])
{
if(!read_vector(&scale,(char*)arg[3]))
return ERROR_VECTOR;
}
if(arg[4])
{
actor = FindActorListItem((char*)arg[4]);
if(!actor)
return rsiERR_ACTOR;
}
if(arg[5])
{
surf = FindSurfListItem((char*)arg[5]);
if(!surf)
return rsiERR_SURFACE;
}
return rsiLoadObject(CTXT, (char*)arg[0],
rsiTObjPos,&pos,
rsiTObjAlign,&align,
rsiTObjScale,&scale,
rsiTObjActor,actor,
rsiTObjSurface,surf,
rsiTDone);
}
开发者ID:privatosan,项目名称:RayStorm,代码行数:41,代码来源:interface.cpp
示例20: read_field
static void read_field(FILE *f, const save_field_t *field, void *base)
{
void *p = (byte *)base + field->ofs;
int i;
switch (field->type) {
case F_BYTE:
read_data(p, field->size, f);
break;
case F_SHORT:
for (i = 0; i < field->size; i++) {
((short *)p)[i] = read_short(f);
}
break;
case F_INT:
for (i = 0; i < field->size; i++) {
((int *)p)[i] = read_int(f);
}
break;
case F_FLOAT:
for (i = 0; i < field->size; i++) {
((float *)p)[i] = read_float(f);
}
break;
case F_VECTOR:
read_vector(f, (vec_t *)p);
break;
case F_LSTRING:
*(char **)p = read_string(f);
break;
case F_ZSTRING:
read_zstring(f, (char *)p, field->size);
break;
case F_EDICT:
*(edict_t **)p = read_index(f, sizeof(edict_t), g_edicts, game.maxentities - 1);
break;
case F_CLIENT:
*(gclient_t **)p = read_index(f, sizeof(gclient_t), game.clients, game.maxclients - 1);
break;
case F_ITEM:
*(gitem_t **)p = read_index(f, sizeof(gitem_t), itemlist, game.num_items - 1);
break;
case F_POINTER:
*(void **)p = read_pointer(f, field->size);
break;
default:
gi.error("%s: unknown field type", __func__);
}
}
开发者ID:Jenco420,项目名称:q2pro,代码行数:53,代码来源:g_save.c
注:本文中的read_vector函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论