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


C++ tensor::Val方法代码示例

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


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

示例1: GetInterpTensor

//******************************************************************************
//Name:  GetInterpTensor                                                       *
//                                                                             *
//Purpose:  get the interpolated tensor at an arbitrary position               *
//                                                                             *
//Takes: pointer to the position as packed in a tensor                         *
//******************************************************************************
tensor field::GetInterpTensor(tensor &pos)
{
   double position[3];
   tensor ret_val;

   for(int i = 0; i < 3; i++)  position[i] = pos.Val(i);

   ret_val <= GetInterpTensor(position);

   return ret_val;
}
开发者ID:gravmath,项目名称:Projects,代码行数:18,代码来源:field.cpp

示例2: SetTensor

//******************************************************************************
//Name:  SetTensor                                                             *
//                                                                             *
//Purpose:  Set the tensor portion of the field                                *
//                                                                             *
//Takes: takes a position in tensor form and the address of the tensor         *
//******************************************************************************
void field::SetTensor(const tensor &pos, const tensor &rval)
{

   int i;
   double position[3];

   for( i = 0; i < 3; i++) position[i] = pos.Val(i);

   SetTensor(position, rval);

}
开发者ID:gravmath,项目名称:Projects,代码行数:18,代码来源:field.cpp

示例3: GetTensor

//******************************************************************************
//Name:  GetTensor                                                             *
//                                                                             *
//Purpose:  get the tensor portion of the field given the position             *
//                                                                             *
//Takes: position stored as a tensor                                           *
//******************************************************************************
tensor field::GetTensor(const tensor &pos)
{

   int i;
   double position[3];

   tensor temp;

   for( i = 0; i < 3; i++ ) position[i] = pos.Val(i);

   temp <= GetTensor(position);

   return temp;
}
开发者ID:gravmath,项目名称:Projects,代码行数:21,代码来源:field.cpp

示例4: Contract


//.........这里部分代码省略.........
  counter = 0;
  for( i = 0; i < p->num_indices; i++)
   {
      if(counter != ind1)
	  {
        range[r_counter]  =  p->range[i];
		  r_counter++;
	  }
      counter++;
   }

  counter = 0;
  //note that tot_indices + 2 is needed to loop over all the appropriate ranges
  for( i = p->num_indices; i < tot_indices + 2; i++)
    {
      if(counter != ind2)
	  {
        range[r_counter] = B.p->range[i - p->num_indices];
		  r_counter++;
	  }
      counter++;
    }

//create a temp tensor and handle scalar result
  tensor con;
  if( tot_indices == 0 )
   {
     tot_indices = 1;
     range[0] = 1;
   }
  con.Resize0(tot_indices, range);
  delete [] range;

//Now comes the fun part
  int *index, *B_index, *con_index;
  int j;
  double contract;
  int temp;

//Allocate index arrays to hold the current index structure
  index      = new int[p->num_indices];
  B_index    = new int[B.p->num_indices];
  con_index	 = new int[con.p->num_indices];

  for(i = 0; i < con.p->product; i++)
  {

   //pack the con_index array
   temp = 0;
	for(j = 0; j < con.p->num_indices - 1; j++)
    {
      con_index[j] = (i - i%con.p->scales[j] - temp)/con.p->scales[j];
      temp += con_index[j] * con.p->scales[j];
    }
    con_index[j] = (i - temp)/con.p->scales[j];

	//form the index structure for the LVAL object
	counter = 0;
	r_counter = 0;
    for( j = 0; j < p->num_indices; j++)
	{
      if(counter != ind1)
	  {
		index[j]  =  con_index[r_counter];
		r_counter++;
	  }
      counter++;
    }

	//form the index structure for the RVAL object
    counter = 0;
    for( j = 0; j < B.p->num_indices; j++)
	{
      if(counter != ind2)
	  {
      B_index[j] = con_index[r_counter];
		r_counter++;
	  }
      counter++;
    }

	//form the contraction
	contract = 0;
	for( j = 0; j < p->range[ind1]; j++)
	{
	  index[ind1]   = j;
	  B_index[ind2] = j;
	  contract += Val(index)*B.Val(B_index);
	 }
    con.p->m[i] = contract;
  }

  //clean up
  delete [] index;
  delete [] B_index;
  delete [] con_index;

  //return the result
  return con;
}
开发者ID:gravmath,项目名称:Projects,代码行数:101,代码来源:tensor.cpp


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