本文整理汇总了C++中Tensor::Rank方法的典型用法代码示例。如果您正苦于以下问题:C++ Tensor::Rank方法的具体用法?C++ Tensor::Rank怎么用?C++ Tensor::Rank使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tensor
的用法示例。
在下文中一共展示了Tensor::Rank方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RecomputeData
void ComputeItemRho::RecomputeData(const DataBoxAccess& box) const {
REQUIRE(l >= 0, "ERROR: l must be >= 0");
REQUIRE(abs(m) <= l, "ERROR: m must be between the values of -l and l");
const Tensor<DataMesh> rho_i=box.Get<Tensor<DataMesh> >(mInput);
REQUIRE(rho_i.Dim() == 3,
"ERROR: The Dimension of the Tensor<DataMesh> input must be 3");
REQUIRE(rho_i.Rank() == 0,
"ERROR: The Rank of the Tensor<DataMesh> input must be 0");
const MyVector<DataMesh>& coords=
box.Get<MyVector<DataMesh> >("GlobalCoords");
const Mesh mesh = box.Get<Mesh>("Mesh");
DataMesh theta(mesh);
DataMesh phi(mesh);
theta = acos(coords[2] / sqrt(coords[0]*coords[0] +
coords[1]*coords[1] + coords[2]*coords[2]));
phi = atan(coords[1] / coords[0]);
Tensor<DataMesh> SHY(SphericalHarmonicYTDM(l, m, theta, phi, mesh));
mResult.assign(0, "", rho_i()*SHY());
}
示例2: TensorDeterminant
void TensorDeterminant(const Tensor<DataMesh>& t, DataMesh& det) {
ASSERT(t.Rank() == 2, "Not a matrix");
ASSERT(t.Dim() == 3, "Not 3D");
det
= t(0,0) * (t(1,1)*t(2,2) - t(1,2)*t(2,1))
+ t(0,1) * (t(1,2)*t(2,0) - t(1,0)*t(2,2))
+ t(0,2) * (t(1,0)*t(2,1) - t(1,1)*t(2,0));
}
示例3: TensorInverse
void TensorInverse(const Tensor<DataMesh>& t, Tensor<DataMesh>& inv) {
ASSERT(t.Rank() == 2, "Not a matrix");
ASSERT(t.Dim() == 3, "Not 3D");
ASSERT(t.Structure() == inv.Structure(),
"Tensors have different structures");
DataMesh det = t(0,0);
TensorDeterminant(t, det);
for(int i=0;i<det.Size();i++) {
ASSERT(det[i] != 0, "Singular matrix");
}
for(TensorIter it(t);it;++it) {
IPoint ind = t.Structure().Indices(it.Index());
inv[it] = (t((ind[1]+1)%3,(ind[0]+1)%3) * t((ind[1]+2)%3,(ind[0]+2)%3)
- t((ind[1]+1)%3,(ind[0]+2)%3) * t((ind[1]+2)%3,(ind[0]+1)%3))
/ det;
}
}