当前位置: 首页>>代码示例>>C++>>正文


C++ dVector::size方法代码示例

本文整理汇总了C++中dVector::size方法的典型用法代码示例。如果您正苦于以下问题:C++ dVector::size方法的具体用法?C++ dVector::size怎么用?C++ dVector::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dVector的用法示例。


在下文中一共展示了dVector::size方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ortogonalizacao

dVector ortogonalizacao(const dVector u, const dVector v)
{
    double escalar = produtoEscalar(u, v) / produtoEscalar(v, v);
    dVector vetor(u.size());
    for(int i = 0;i< u.size();i++)vetor[i]=u[i] - escalar*v[i];
    return vetor;
}
开发者ID:tfc2,项目名称:if680,代码行数:7,代码来源:util.cpp

示例2: assert

// Adds the dVector b to the dVector a. a is modified in-place.
void RKF45::sum_in_place(dVector& a, const dVector& b) const {
    assert ( a.size() == b.size()
	   && "To sum two vectors, they must be the same size.");
    for (unsigned int i = 0; i < a.size(); i++) {
      a[i] += b[i];
    }
}
开发者ID:eschnett,项目名称:wave_equation,代码行数:8,代码来源:rkf45.cpp

示例3: sqrt

// Takes the norm of the difference between two dVectors.
double RKF45::norm_difference(const dVector& a, const dVector& b) const {
  assert ( a.size() == b.size()
	   && "To sum two vectors, they must be the same size.");
  double output = 0;
  for (unsigned int i = 0; i < a.size(); i++) {
    output += (a[i] - b[i]) * (a[i] - b[i]);
  }
  return sqrt(output);
}
开发者ID:eschnett,项目名称:wave_equation,代码行数:10,代码来源:rkf45.cpp

示例4: derivative

// ----------------------------------------------------------------------
double derivative(int i, const dVector& v, double lattice_spacing) {
  // A local "num points" variable. Used for simplicity.
  int num_points = get_num_points(v);
  assert (0 <= i && i < (int)v.size()
	  && "The ith elemennt must be in the vector");

  if ( i % num_points == 0 ) { // We're at the lower boundary of the grid.
    if (DEBUGGING) {
      cout << "\tUsing forward difference." << endl;
    }
    return forward_difference(i,v,lattice_spacing);
  }
  else if (i % num_points == num_points - 1) {
    // We're at the upper boundary of the grid.
    if (DEBUGGING) {
      cout << "\tUsing backward difference." << endl;
    }
    return backward_difference(i,v,lattice_spacing);
  }
  else { // We're in the middle of the grid.
    if (DEBUGGING) {
      cout << "\tUsing centered difference." << endl;
    }
    return centered_difference(i,v,lattice_spacing);
  }
}
开发者ID:eschnett,项目名称:wave_equation,代码行数:27,代码来源:wave_equation.cpp

示例5: set_v

void Quaternion::set_v(const dVector & v)
{
	if(v.size() == 3) {
		v_ = v;
	}
	else {
		assert (0 && "Quaternion::set_v: input has a wrong size.");
	}
}
开发者ID:sangwook236,项目名称:general-development-and-testing,代码行数:9,代码来源:Quaternion.cpp

示例6: sin

Quaternion::Quaternion(const double angle, const dVector & axis)
{
	if(axis.size() != 3) {
		assert (0 && "Quaternion::Quaternion, size of axis != 3");
		return;
	}

	// make sure axis is a unit vector
	v_ = sin(angle/2) * axis/Norm2(axis);
	s_ = cos(angle/2);
}
开发者ID:sangwook236,项目名称:general-development-and-testing,代码行数:11,代码来源:Quaternion.cpp

示例7: f

// ----------------------------------------------------------------------
// Iterative Function
// ----------------------------------------------------------------------
dVector f(double t, const dVector& y, const dVector& optional_args) {
  // t is not used. But it is required by the integrator.

  // The optional arguments vector contains the lattice spacing and c^2.
  double h = optional_args[0];  // h = lattice spacing
  double c2 = optional_args[1]; // c2 = c^2.

  // For convenience, get the number of points in the lattice
  int num_points = get_num_points(y);

  // The output dVector. Starts empty.
  dVector output(y.size(),0);

  // The order of elements in v is s,r,u. So we have the following system:
  // (d/dt) [s,r,u] = [c^2 (dr/dx), (ds/dx), s]

  // Fill the output array
  for (int i = 0; i < num_points; i++) {
    // Fill the (du/dt) terms with s.

    // ES: A nicer notation would allow you to write e.g.
    // "output[i].*s" or "output.*s[i]" (see "member pointers), or
    // "output[i][s]", or maybe even "s[i]" where "s" is a local
    // variable defined before the loop.
    output[get_linear_index_u(i,output)] = get_ith_s(i,y);
    // Fill the (dr/dt) vectors with (ds/dx).
    // ES: A nicer notation would allow you to write e.g.
    // "diff(h,y,i,s)" or "diff(h,y,s,i)" instead.
    output[get_linear_index_r(i,output)] = derivative_for_s(i,y,h);
    // Fill the (ds/dt) vectors with c^2(dr/dx).
    output[get_linear_index_s(i,output)] = c2 * derivative_for_r(i,y,h);
  }
  // (du/dt) at the boundary is forced to be zero. Impose this.
  // ES: What about the boundary conditions for the other fields?
  output[get_linear_index_s(0,output)] = 0;
  output[get_linear_index_s(num_points-1,output)] = 0;

  // That's it. Return the array!
  return output;
}
开发者ID:eschnett,项目名称:wave_equation,代码行数:43,代码来源:wave_equation.cpp

示例8: subtracao

dVector subtracao(dVector u, dVector v){
	dVector retorno(v.size());
	for (int i = 0; i < v.size(); i++)
		retorno[i] = u[i] - v[i];
	return retorno;
}
开发者ID:tfc2,项目名称:if680,代码行数:6,代码来源:util.cpp

示例9: soma

dVector soma(dVector u, dVector v){
	dVector retorno(v.size());
	for (int i = 0; i < v.size(); i++)
		retorno[i] = u[i] + v[i];
	return retorno;
}
开发者ID:tfc2,项目名称:if680,代码行数:6,代码来源:util.cpp

示例10: normalize

dVector normalize(dVector v)
{
    double norma = getNorma(v);
    for(int i = 0;i< v.size();i++)   v[i]=v[i]/norma;
    return v;
}
开发者ID:tfc2,项目名称:if680,代码行数:6,代码来源:util.cpp

示例11: getNorma

double getNorma(const dVector v)
{
	double retorno = 0;
	for(int i = 0;i< v.size();i++)    retorno+=pow(v[i], 2);
    return (sqrt(retorno));
}
开发者ID:tfc2,项目名称:if680,代码行数:6,代码来源:util.cpp

示例12: produtoEscalar

double produtoEscalar(const dVector u, const dVector v)
{
    double retorno  =0;
for(int i = 0;i< u.size();i++)    retorno+=u[i]*v[i];
	return retorno;
}
开发者ID:tfc2,项目名称:if680,代码行数:6,代码来源:util.cpp

示例13: get_num_points

// ----------------------------------------------------------------------
int get_num_points(const dVector& v) {
  assert ( v.size() % NUM_VAR_TYPES == 0
	   && "The vector must be for the variables of the system.");
  return v.size() / 3;
}
开发者ID:eschnett,项目名称:wave_equation,代码行数:6,代码来源:wave_equation.cpp


注:本文中的dVector::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。