本文整理汇总了C++中SiconosVector类的典型用法代码示例。如果您正苦于以下问题:C++ SiconosVector类的具体用法?C++ SiconosVector怎么用?C++ SiconosVector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SiconosVector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: contactPointProcess
void contactPointProcess(SiconosVector& answer,
const Interaction& inter,
const T& rel)
{
answer.resize(14);
const SiconosVector& posa = *rel.pc1();
const SiconosVector& posb = *rel.pc2();
const SiconosVector& nc = *rel.nc();
const SimpleMatrix& jachqT = *rel.jachqT();
double id = inter.number();
double mu = ask<ForMu>(*inter.nslaw());
SiconosVector cf(jachqT.size(1));
prod(*inter.lambda(1), jachqT, cf, true);
answer.setValue(0, mu);
DEBUG_PRINTF("posa(0)=%g\n", posa(0));
DEBUG_PRINTF("posa(1)=%g\n", posa(1));
DEBUG_PRINTF("posa(2)=%g\n", posa(2));
answer.setValue(1, posa(0));
answer.setValue(2, posa(1));
answer.setValue(3, posa(2));
answer.setValue(4, posb(0));
answer.setValue(5, posb(1));
answer.setValue(6, posb(2));
answer.setValue(7, nc(0));
answer.setValue(8, nc(1));
answer.setValue(9, nc(2));
answer.setValue(10, cf(0));
answer.setValue(11, cf(1));
answer.setValue(12, cf(2));
answer.setValue(13, id);
};
示例2: assert
void FirstOrderType1R::computeh(double time, SiconosVector& x, SiconosVector& z, SiconosVector& y)
{
assert(_pluginh && "FirstOrderType1R::computeOutput() is not linked to a plugin function");
((Type1Ptr)(_pluginh->fPtr))(x.size(), &(x)(0), y.size(), &(y)(0), z.size(), &(z)(0));
}
示例3: computeh
void SphereNEDSSphereNEDSR::computeh(double time, BlockVector& q0, SiconosVector& y)
{
double q_0 = q0(0);
double q_1 = q0(1);
double q_2 = q0(2);
double q_7 = q0(7);
double q_8 = q0(8);
double q_9 = q0(9);
y.setValue(0, distance(q_0, q_1, q_2, r1, q_7, q_8, q_9, r2));
//Approximation _Pc1=_Pc2
_Pc1->setValue(0, (r1 * q_0 + r2 * q_7) / (r1 + r2));
_Pc1->setValue(1, (r1 * q_1 + r2 * q_8) / (r1 + r2));
_Pc1->setValue(2, (r1 * q_2 + r2 * q_9) / (r1 + r2));
_Pc2->setValue(0, (r1 * q_0 + r2 * q_7) / (r1 + r2));
_Pc2->setValue(1, (r1 * q_1 + r2 * q_8) / (r1 + r2));
_Pc2->setValue(2, (r1 * q_2 + r2 * q_9) / (r1 + r2));
_Nc->setValue(0, (q_0 - q_7) / (y.getValue(0) + r1pr2));
_Nc->setValue(1, (q_1 - q_8) / (y.getValue(0) + r1pr2));
_Nc->setValue(2, (q_2 - q_9) / (y.getValue(0) + r1pr2));
//std::cout<<" SphereNEDSSphereNEDSR::computeh dist:"<<y->getValue(0)<<"\n";
//std::cout<<"_Pc:\n";
//_Pc->display();
//std::cout<<"_Nc:\n";
//_Nc->display();
}
示例4: SolveByLeastSquares
void SimpleMatrix::SolveByLeastSquares(SiconosVector &B)
{
if (B.isBlock())
SiconosMatrixException::selfThrow("SimpleMatrix::SolveByLeastSquares(SiconosVector &B) failed. Not yet implemented for V being a BlockVector.");
DenseMat tmpB(B.size(), 1);
ublas::column(tmpB, 0) = *(B.dense()); // Conversion of vector to matrix. Temporary solution.
int info = 0;
#ifdef USE_OPTIMAL_WORKSPACE
info += lapack::gels(*mat.Dense, tmpB, lapack::optimal_workspace());
#endif
#ifdef USE_MINIMAL_WORKSPACE
info += lapack::gels(*mat.Dense, tmpB, lapack::minimal_workspace());
#endif
if (info != 0)
{
std::cout << "info = " << info << std::endl;
SiconosMatrixException::selfThrow("SimpleMatrix::SolveByLeastSquares failed.");
}
else
{
noalias(*(B.dense())) = ublas::column(tmpB, 0);
}
}
示例5: normalize
static
void normalize(SiconosVector& q, unsigned int i)
{
q.setValue(i, fmod(q.getValue(i), _2PI));
assert(fabs(q.getValue(i)) - std::numeric_limits<double>::epsilon() >= 0.);
assert(fabs(q.getValue(i)) < _2PI);
}
示例6: computee
void FirstOrderLinearR::computee(double time, SiconosVector& z, SiconosVector& e)
{
if (_plugine->fPtr)
{
((FOVecPtr) _plugine->fPtr)(time, e.size(), &(e)(0), z.size(), &(z)(0));
}
}
示例7: computeJachlambda
void LagrangianCompliantR::computeJachlambda(double time, SiconosVector& q0, SiconosVector& lambda, SiconosVector& z)
{
if (_pluginJachlambda->fPtr)
{
// get vector lambda of the current interaction
((FPtr2)_pluginJachlambda->fPtr)(q0.size(), &(q0)(0), lambda.size(), &(lambda)(0), &(*_jachlambda)(0, 0), z.size(), &(z)(0));
// Copy data that might have been changed in the plug-in call.
}
}
示例8: PLUForwardBackwardInPlace
void SimpleMatrix::PLUForwardBackwardInPlace(SiconosVector &B)
{
if (B.isBlock())
SiconosMatrixException::selfThrow("SimpleMatrix PLUForwardBackwardInPlace(V) failed. Not yet implemented for V being a BlockVector.");
DenseMat tmpB(B.size(), 1);
ublas::column(tmpB, 0) = *(B.dense()); // Conversion of vector to matrix. Temporary solution.
int info;
if (_num == 1)
{
if (!_isPLUFactorized) // call gesv => LU-factorize+solve
{
// solve system:
if (!_ipiv)
_ipiv.reset(new VInt(size(0)));
else
_ipiv->resize(size(0));
info = lapack::gesv(*mat.Dense, *_ipiv, tmpB);
_isPLUFactorized = true;
/*
ublas::matrix<double> COPY(*mat.Dense);
ublas::vector<double> S(std::max(size(0),size(1)));
ublas::matrix<double, ublas::column_major> U(size(0),size(1));
ublas::matrix<double, ublas::column_major> VT(size(0),size(1));
int ierr = lapack::gesdd(COPY, S, U, VT);
printf("info = %d, ierr = %d, emax = %f, emin = %f , cond = %f\n",info,ierr,S(0),S(2),S(0)/S(2));
*/
// B now contains solution:
}
else // call getrs: only solve using previous lu-factorization
info = lapack::getrs(*mat.Dense, *_ipiv, tmpB);
}
else
{
if (!_isPLUFactorized) // call first PLUFactorizationInPlace
{
PLUFactorizationInPlace();
}
// and then solve
inplace_solve(*sparse(), tmpB, ublas::lower_tag());
inplace_solve(ublas::trans(*sparse()), tmpB, ublas::upper_tag());
info = 0;
}
if (info != 0)
SiconosMatrixException::selfThrow("SimpleMatrix::PLUForwardBackwardInPlace failed.");
else
{
noalias(*(B.dense())) = ublas::column(tmpB, 0);
}
}
示例9: computeh
void LagrangianCompliantR::computeh(double time, SiconosVector& q0, SiconosVector& lambda, SiconosVector& z, SiconosVector& y)
{
if (_pluginh->fPtr)
{
// get vector y of the current interaction
// Warning: temporary method to have contiguous values in memory, copy of block to simple.
((FPtr2)(_pluginh->fPtr))(q0.size(), &(q0)(0), y.size(), &(lambda)(0), &(y)(0), z.size(), &(z)(0));
}
}
示例10: computeJachq
void LagrangianCompliantR::computeJachq(double time, SiconosVector& q0, SiconosVector& lambda, SiconosVector& z)
{
if (_pluginJachq->fPtr)
{
// Warning: temporary method to have contiguous values in memory, copy of block to simple.
// get vector lambda of the current interaction
((FPtr2)(_pluginJachq->fPtr))(q0.size(), &(q0)(0), lambda.size(), &(lambda)(0), &(*_jachq)(0, 0), z.size(), &(z)(0));
// Copy data that might have been changed in the plug-in call.
}
}
示例11: computeh
void LagrangianRheonomousR::computeh(double time, SiconosVector& q, SiconosVector& z, SiconosVector& y)
{
DEBUG_PRINT(" LagrangianRheonomousR::computeh(double time,Interaction& inter, SP::BlockVector q, SP::BlockVector z)");
if (_pluginh)
{
// arg= time. Unused in this function but required for interface.
if (_pluginh->fPtr)
{
((FPtr4)(_pluginh->fPtr))(q.size(), &(q)(0), time, y.size(), &(y)(0), z.size(), &(z)(0));
}
}
}
示例12: computeC
void FirstOrderLinearR::computeC(double time, SiconosVector& z, SimpleMatrix& C)
{
if (_pluginJachx->fPtr)
{
((FOMatPtr1)(_pluginJachx->fPtr))(time, C.size(0), C.size(1), &(C)(0, 0), z.size(), &(z)(0));
}
}
示例13: computeh
void computeh(double time, BlockVector& q0, SiconosVector& y)
{
std::cout <<"my_NewtonEulerR:: computeh" << std:: endl;
std::cout <<"q0.size() = " << q0.size() << std:: endl;
double height = q0.getValue(0) - _sBallRadius - q0.getValue(7);
// std::cout <<"my_NewtonEulerR:: computeh _jachq" << std:: endl;
// _jachq->display();
y.setValue(0, height);
_Nc->setValue(0, 1);
_Nc->setValue(1, 0);
_Nc->setValue(2, 0);
_Pc1->setValue(0, q0.getValue(0) - _sBallRadius);
_Pc1->setValue(1, q0.getValue(1));
_Pc1->setValue(2, q0.getValue(2));
_Pc2->setValue(0,q0.getValue(7));
_Pc2->setValue(1,q0.getValue(8));
_Pc2->setValue(2,q0.getValue(9));
//printf("my_NewtonEulerR N, Pc\n");
_Nc->display();
_Pc1->display();
_Pc2->display();
std::cout <<"my_NewtonEulerR:: computeh ends" << std:: endl;
}
示例14: setVector
void SiconosVector::setVector(unsigned int , const SiconosVector& newV)
{
if (newV.size() != size())
SiconosVectorException::selfThrow("SiconosVector::setVector(num,v), unconsistent sizes.");
*this = newV ;
}
示例15: prod
void ControlLinearAdditionalTermsED::addSmoothTerms(DynamicalSystemsGraph& DSG0, const DynamicalSystemsGraph::VDescriptor& dsgVD, const double t, SiconosVector& xdot)
{
// check whether we have a system with a control input
if (DSG0.u.hasKey(dsgVD))
{
if (DSG0.B.hasKey(dsgVD))
{
prod(DSG0.B.getRef(dsgVD), DSG0.u.getRef(dsgVD), xdot, false); // xdot += B*u
}
else if (DSG0.pluginU.hasKey(dsgVD))
{
DynamicalSystem& ds = *DSG0.bundle(dsgVD);
SiconosVector& u = DSG0.u.getRef(dsgVD);
SiconosVector& tmpXdot = DSG0.tmpXdot.getRef(dsgVD);
((AdditionalTermsEDfctU)DSG0.pluginU.getRef(dsgVD).fPtr)(t, xdot.size(), ds.getx().getArray(), u.size(), u.getArray(), tmpXdot.getArray(), ds.getz().size(), ds.getz().getArray());
xdot += tmpXdot; // xdot += g(x, u)
}
else
{
RuntimeException::selfThrow("ControlLinearAdditionalTermsED :: input u but no B nor pluginU");
}
}
// check whether the DynamicalSystem is an Observer
if (DSG0.e.hasKey(dsgVD))
{
assert(DSG0.L.hasKey(dsgVD));
prod(*DSG0.L[dsgVD], *DSG0.e[dsgVD], xdot, false); // xdot += -L*e
}
}