本文整理汇总了C++中Polynomial::gradient方法的典型用法代码示例。如果您正苦于以下问题:C++ Polynomial::gradient方法的具体用法?C++ Polynomial::gradient怎么用?C++ Polynomial::gradient使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polynomial
的用法示例。
在下文中一共展示了Polynomial::gradient方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mapX
QuadEdgeBasis::QuadEdgeBasis(size_t order){
// Reference Space //
refSpace = new QuadReferenceSpace;
nRefSpace = getReferenceSpace().getNReferenceSpace();
const vector<vector<vector<size_t> > >&
edgeIdx = refSpace->getEdgeNodeIndex();
const vector<vector<vector<size_t> > >&
faceIdx = refSpace->getFaceNodeIndex();
// Set Basis Type //
this->order = order;
type = 1;
dim = 2;
nVertex = 0;
nEdge = 4 * (order + 1);
nFace = 2 * (order + 1) * order;
nCell = 0;
nFunction = nVertex + nEdge + nFace + nCell;
// Legendre Polynomial //
const size_t orderPlus = order + 1;
Polynomial* legendre = new Polynomial[orderPlus];
Polynomial* intLegendre = new Polynomial[orderPlus];
Legendre::integrated(intLegendre, orderPlus);
Legendre::legendre(legendre, order);
// Lagrange & Lifting //
const Polynomial lagrange[4] =
{
Polynomial((Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) *
(Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0))),
Polynomial((Polynomial(1, 1, 0, 0)) *
(Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0))),
Polynomial((Polynomial(1, 1, 0, 0)) *
(Polynomial(1, 0, 1, 0))),
Polynomial((Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) *
(Polynomial(1, 0, 1, 0)))
};
const Polynomial lifting[4] =
{
Polynomial((Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) +
(Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0))),
Polynomial((Polynomial(1, 1, 0, 0)) +
(Polynomial(1, 0, 0, 0) - Polynomial(1, 0, 1, 0))),
Polynomial((Polynomial(1, 1, 0, 0)) +
(Polynomial(1, 0, 1, 0))),
Polynomial((Polynomial(1, 0, 0, 0) - Polynomial(1, 1, 0, 0)) +
(Polynomial(1, 0, 1, 0)))
};
// Basis //
basis = new vector<Polynomial>**[nRefSpace];
for(size_t s = 0; s < nRefSpace; s++)
basis[s] = new vector<Polynomial>*[nFunction];
// Edge Based //
for(size_t s = 0; s < nRefSpace; s++){
size_t i = 0;
for(size_t e = 0; e < 4; e++){
for(size_t l = 0; l < orderPlus; l++){
// Nedelec
if(l == 0){
Polynomial lambda = (lagrange[edgeIdx[s][e][0]] +
lagrange[edgeIdx[s][e][1]]) * 0.5;
basis[s][i] =
new vector<Polynomial>((lifting[edgeIdx[s][e][1]] -
lifting[edgeIdx[s][e][0]]).gradient());
basis[s][i]->at(0).mul(lambda);
basis[s][i]->at(1).mul(lambda);
basis[s][i]->at(2).mul(lambda);
}
// High Order
else{
basis[s][i] =
new vector<Polynomial>
((intLegendre[l].compose(lifting[edgeIdx[s][e][1]] -
lifting[edgeIdx[s][e][0]])
*
(lagrange[edgeIdx[s][e][0]] +
lagrange[edgeIdx[s][e][1]])).gradient());
}
//.........这里部分代码省略.........
示例2: one
TriEdgeBasis::TriEdgeBasis(size_t order){
// Set Basis Type //
this->order = order;
type = TYPE_TRI;
dim = 2;
nVertex = 0;
nEdge = 3 * (order + 1);
nFace = ((order - 1) * order + order - 1);
nCell = 0;
nFunction = nVertex + nEdge + nFace + nCell;
// Reference Space //
const size_t nOrientation = ReferenceSpaceManager::getNOrientation(type);
const vector<vector<vector<size_t> > >&
edgeIdx = ReferenceSpaceManager::getEdgeNodeIndex(type);
const vector<vector<vector<size_t> > >&
faceIdx = ReferenceSpaceManager::getFaceNodeIndex(type);
// Alloc Some Space //
const int orderPlus = order + 1;
const int orderMinus = order - 1;
Polynomial* legendre = new Polynomial[orderPlus];
Polynomial* intLegendre = new Polynomial[orderPlus];
// Legendre Polynomial //
Legendre::legendre(legendre, order);
Legendre::intScaled(intLegendre, orderPlus);
// Lagrange //
const Polynomial lagrange[3] =
{
Polynomial(Polynomial(1, 0, 0, 0) -
Polynomial(1, 1, 0, 0) -
Polynomial(1, 0, 1, 0)),
Polynomial(Polynomial(1, 1, 0, 0)),
Polynomial(Polynomial(1, 0, 1, 0))
};
// One //
Polynomial one(1, 0, 0, 0);
// Basis //
basis = new vector<Polynomial>**[nOrientation];
for(size_t s = 0; s < nOrientation; s++)
basis[s] = new vector<Polynomial>*[nFunction];
// Edge Based //
for(size_t s = 0; s < nOrientation; s++){
size_t i = 0;
for(int e = 0; e < 3; e++){
for(int l = 0; l < orderPlus; l++){
// Nedelec
if(l == 0){
vector<Polynomial> tmp1 = lagrange[edgeIdx[s][e][1]].gradient();
vector<Polynomial> tmp2 = lagrange[edgeIdx[s][e][0]].gradient();
tmp1[0].mul(lagrange[edgeIdx[s][e][0]]);
tmp1[1].mul(lagrange[edgeIdx[s][e][0]]);
tmp1[2].mul(lagrange[edgeIdx[s][e][0]]);
tmp2[0].mul(lagrange[edgeIdx[s][e][1]]);
tmp2[1].mul(lagrange[edgeIdx[s][e][1]]);
tmp2[2].mul(lagrange[edgeIdx[s][e][1]]);
tmp2[0].sub(tmp1[0]);
tmp2[1].sub(tmp1[1]);
tmp2[2].sub(tmp1[2]);
basis[s][i] = new vector<Polynomial>(tmp2);
}
// High Order
else{
basis[s][i] =
new vector<Polynomial>
((intLegendre[l].compose(lagrange[edgeIdx[s][e][0]] -
lagrange[edgeIdx[s][e][1]]
,
lagrange[edgeIdx[s][e][1]] +
lagrange[edgeIdx[s][e][0]])).gradient());
}
i++;
}
}
}
// Face Based //
// NB: We use (*(*faceIdx[s])[f])[]
// where f = 0, because triangles
// have only ONE face: the face '0'
//.........这里部分代码省略.........