本文整理汇总了C++中r3函数的典型用法代码示例。如果您正苦于以下问题:C++ r3函数的具体用法?C++ r3怎么用?C++ r3使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了r3函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: imp3
void Constraint::ApplyImpulse()
{
if (bodyA != NULL && bodyA->mass < w_vars->UNMOVABLE_MASS)
{
bodyA->velocity = bodyA->velocity + Impulse * bodyA->iMass;
double iinrt1 = bodyA->iInert;
Vector3 imp3(Impulse.v1, Impulse.v2, 0);
Vector3 r3(rA.v1, rA.v2, 0);
r3 = r3.cross(imp3);
double ro1 = r3.v3;
bodyA->angle_vel += iinrt1 * ro1;
bodyA->angle_vel += iinrt1 * Torque;
}
if (bodyB != NULL && bodyB->mass < w_vars->UNMOVABLE_MASS)
{
bodyB->velocity = bodyB->velocity - Impulse * bodyB->iMass;
double iinrt2 = bodyB->iInert;
Vector3 imp3(Impulse.v1, Impulse.v2, 0);
Vector3 r3(rB.v1, rB.v2, 0);
r3 = r3.cross(imp3);
double ro2 = r3.v3;
bodyB->angle_vel -= iinrt2 * ro2;
bodyB->angle_vel -= iinrt2 * Torque;
}
}
示例2: TEST
TEST(SegmentTest, swaps)
{
{
RAJA::RangeSegment r1(0, 5);
RAJA::RangeSegment r2(1, 6);
RAJA::RangeSegment r3(r1);
RAJA::RangeSegment r4(r2);
std::swap(r1, r2);
ASSERT_EQ(r1, r4);
ASSERT_EQ(r2, r3);
}
{
RAJA::RangeStrideSegment r1(0, 5, 2);
RAJA::RangeStrideSegment r2(1, 6, 1);
RAJA::RangeStrideSegment r3(r1);
RAJA::RangeStrideSegment r4(r2);
std::swap(r1, r2);
ASSERT_EQ(r1, r4);
ASSERT_EQ(r2, r3);
}
{
RAJA::Index_type vals[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
RAJA::ListSegment r1(vals, 5, RAJA::Unowned);
RAJA::ListSegment r2(vals + 5, 5, RAJA::Unowned);
ASSERT_NE(r1, r2);
RAJA::ListSegment r3(r1);
RAJA::ListSegment r4(r2);
std::swap(r1, r2);
ASSERT_EQ(r1, r4);
ASSERT_EQ(r2, r3);
}
}
示例3: BprojCore_dag
void Dirac_DomainWall_4D::
BprojCore_dag(double* f1,double* fN,const double* f) const{
// f1 = f5(0), fN = f5(N5_-1)
for(int c=0; c<NC_; ++c){
double fup_r = 0.5*(f[r0(c)] +f[r2(c)]);
double fup_i = 0.5*(f[i0(c)] +f[i2(c)]);
double fdn_r = 0.5*(f[r1(c)] +f[r3(c)]);
double fdn_i = 0.5*(f[i1(c)] +f[i3(c)]);
fN[r0(c)] = fup_r; fN[i0(c)] = fup_i;
fN[r1(c)] = fdn_r; fN[i1(c)] = fdn_i;
fN[r2(c)] = fup_r; fN[i2(c)] = fup_i;
fN[r3(c)] = fdn_r; fN[i3(c)] = fdn_i;
fup_r -= f[r2(c)]; //0.5*(f[r0(c)] -f[r2(c)])
fup_i -= f[i2(c)]; //0.5*(f[i0(c)] -f[i2(c)])
fdn_r -= f[r3(c)]; //0.5*(f[r1(c)] -f[r3(c)])
fdn_i -= f[i3(c)]; //0.5*(f[i1(c)] -f[i3(c)])
f1[r0(c)] = fup_r; f1[i0(c)] = fup_i;
f1[r1(c)] = fdn_r; f1[i1(c)] = fdn_i;
f1[r2(c)] =-fup_r; f1[i2(c)] =-fup_i;
f1[r3(c)] =-fdn_r; f1[i3(c)] =-fdn_i;
}
}
示例4:
void GammaMatrix::isigma24core(double* w,const double* f)const{
for(int c=0; c<Ncol_; ++c){
w[r0(c)] = f[r3(c)]; w[i0(c)] = f[i3(c)];
w[r1(c)] =-f[r2(c)]; w[i1(c)] =-f[i2(c)];
w[r2(c)] = f[r1(c)]; w[i2(c)] = f[i1(c)];
w[r3(c)] =-f[r0(c)]; w[i3(c)] =-f[i0(c)];
}
}
示例5:
void DiracWilsonLike::gamma5core(double* w,const double* f)const{
for(int c=0; c<N; ++c){
w[r0(c)] = f[r2(c)]; w[i0(c)] = f[i2(c)];
w[r1(c)] = f[r3(c)]; w[i1(c)] = f[i3(c)];
w[r2(c)] = f[r0(c)]; w[i2(c)] = f[i0(c)];
w[r3(c)] = f[r1(c)]; w[i3(c)] = f[i1(c)];
}
}
示例6: projMcore
void GammaMatrix::projMcore(double* w,const double* f)const{
for(int c=0; c<Ncol_; ++c){
double fup_r = 0.5*(f[r0(c)] -f[r2(c)]);
double fup_i = 0.5*(f[i0(c)] -f[i2(c)]);
double fdn_r = 0.5*(f[r1(c)] -f[r3(c)]);
double fdn_i = 0.5*(f[i1(c)] -f[i3(c)]);
w[r0(c)] = fup_r; w[i0(c)] = fup_i;
w[r1(c)] = fdn_r; w[i1(c)] = fdn_i;
w[r2(c)] =-fup_r; w[i2(c)] =-fup_i;
w[r3(c)] =-fdn_r; w[i3(c)] =-fdn_i;
}
}
示例7: projMcore
void DiracWilsonLike::projMcore(double* w,const double* f)const{
for(int c=0; c<N; ++c){
double fup_r = 0.5*(f[r0(c)] -f[r2(c)]);
double fup_i = 0.5*(f[i0(c)] -f[i2(c)]);
double fdn_r = 0.5*(f[r1(c)] -f[r3(c)]);
double fdn_i = 0.5*(f[i1(c)] -f[i3(c)]);
w[r0(c)] = fup_r; w[i0(c)] = fup_i;
w[r1(c)] = fdn_r; w[i1(c)] = fdn_i;
w[r2(c)] =-fup_r; w[i2(c)] =-fup_i;
w[r3(c)] =-fdn_r; w[i3(c)] =-fdn_i;
}
}
示例8: testClassBasics
bool testClassBasics() {
bool passedTests=true;
RealNumber a=1,b=-22,c=5+5,d(1),e(2,1),f(-3),g(2,3);
if(passedTests)
passedTests = (a == 1);
if(passedTests)
passedTests = (b == -22);
if(passedTests)
passedTests = (c == 10);
if(passedTests)
passedTests = (d == 1);
if(passedTests)
passedTests = (e == 2);
if(passedTests)
passedTests = (f == -3);
if(passedTests)
passedTests = (g != 2 && g != 3);
RealNumber r1(20,30), r2(30,30), r3(30,20), r4(2,3), r5(3,2);
RealNumber r6 = r4;
if(passedTests)
passedTests = (r1 == r4);
if(passedTests)
passedTests = (r5 == r3);
if(passedTests)
passedTests = (r2 != r3);
if(passedTests)
passedTests = (r1 != r3);
if(passedTests)
passedTests = (r6 == r4);
return passedTests;
}
示例9: main
int main(void)
{
static const struct st3 a = {1, 2, 3, 4, 5, 6};
l1(100);
l2(100, 200);
l3(100, 200, 300);
l4(100, 200, 300, 400);
l5(100, 200, 300, 400, 500);
l6(100, 200, 300, 400, 500, 600);
l7(100, 200, 300, 400, 500, 600, 700);
l8(100, 200, 300, 400, 500, 600, 700, 800);
d1();
d2(43);
d3(100, 200);
d4(a);
d5('a', 43, a);
d6('a', 1);
c1(44);
c2(100, 'a', 3.4);
c3(200, 2.777, 'q');
c4(200, 1);
c5(1.1, 2.2);
c6(1.23, 45.6);
c7('z', 0x200);
a1('a');
a2(10);
a3(20);
a4(102030405060LL);
b1('a', 20);
b2(30, 'b');
b3(10, 20, 30, 40, 50, 60);
s1(sx);
s1p(&sx);
s2(sy);
s3(sz);
s4(sq);
s5(sa);
s6(sb);
r1();
r3();
r4();
q1(200, sx);
q2(300, 't', sx);
q3(400, 410, sy);
q4(500, 510, sq);
q5(600, 610, 'z', 'q', sq);
real1("fresh air");
real2();
return 0;
}
示例10: rotateAround
TVector3<float> rotateAround( const TVector3<float>& v,
const TVector3<float>& axis,
float angle )
{
float one = 1.0f;
if ( Math::notZero( angle ) )
{
float sangle = sin( Math::Pi * angle / 180.0f );
float cangle = cos( Math::Pi * angle / 180.0f );
float xangle = one - cangle; // "1 minus cos angle"
TVector3<float> u = normalized( axis );
TVector3<float> r1( u.mX * u.mX + cangle * ( one - u.mX * u.mX ),
u.mX * u.mY * xangle - sangle * u.mZ,
u.mY * u.mZ * xangle + sangle * u.mY );
TVector3<float> r2( u.mX * u.mY * xangle + sangle * u.mZ,
u.mY * u.mY + cangle * ( one - u.mY * u.mY ),
u.mY * u.mZ * xangle - sangle * u.mX );
TVector3<float> r3( u.mX * u.mZ * xangle - sangle * u.mY,
u.mY * u.mZ * xangle + sangle * u.mX,
u.mZ * u.mZ + cangle * ( one - u.mZ * u.mZ ) );
return TVector3<float>( dot( v, r1 ),
dot( v, r2 ),
dot( v, r3 ) );
}
else
{
return v;
}
}
示例11: main
int main()
{
// initialize grid. params are read from input file
GRID grid;
// initialize a result object on grid
Result result(&grid);
// fill in Delta by initializing it to semi-circle
InitDelta(DOStypes::SemiCircle, grid.get_N(), 0.2, 0.0, 0.01, 0.5, result.omega, result.Delta);
result.mu = 0.1;
result.n = 0.5;
result.mu0 = 0.3;
//make a copy
Result r2(result);
//r2.CopyFrom(&result);
r2.mu = 0.2;
r2.Delta[1000] = 7;
result.PrintResult("Result.dat");
r2.PrintResult("Result.dat.c");
Result r3(&grid);
// this way mu, n and mu0 are not read
r3.ReadFromFile("Result.dat.c");
r3.n = 0.3;
r3.PrintResult("Result.dat.cc");
return 0;
}
示例12: taylorSample
/** An sample for taylor expansion of logdet(X). */
void taylorSample() {
std::string ans;
char rowChar[5];
int rowTmp = ROW;
sprintf(rowChar, "%d", rowTmp);
std::string row = rowChar;
// Initialize the matrices.
symbolic_matrix_type X("X", ROW, COL);
symbolic_matrix_type X0("X0", ROW, COL);
symbolic_matrix_type Delta("(X-X0)", ROW, COL);
AMD::SymbolicScalarMatlab a2("1/2!");
AMD::SymbolicScalarMatlab a3("1/3!");
SymbolicSMFunc r2(a2,ROW,COL);
SymbolicSMFunc r3(a3,ROW, COL);
// Initialize MatrixMatrixFunction.
SymbolicMMFunc fX(X, false);
SymbolicMMFunc fX0(X0, false);
SymbolicMMFunc fDelta(Delta, true);
// Compute Taylor series iteratively.
SymbolicSMFunc f0 = logdet(fX0);
SymbolicSMFunc f1 = trace(fDelta * transpose(*f0.derivativeFuncVal));
SymbolicSMFunc f2 = trace(fDelta * transpose(*f1.derivativeFuncVal));
SymbolicSMFunc f3 = trace(fDelta * transpose(*f2.derivativeFuncVal));
// Taylor Expansion.
SymbolicSMFunc func = f0 + f1 + r2*f2 + r3*f3;
std::cout<<"The first 4 terms of Taylor Expansion for logdet(X) around X0 is:";
std::cout << std::endl;
std::cout << func.functionVal.getString() << std::endl;
}
示例13: rMax
void CDrawArea::SelfTest()
{
#ifdef _DEBUG
CDrawArea a,b,c;
CRect<int> rMax(0,0,640,400);
CRect<int> r1(0,0,100,100);
CRect<int> r2(0,0,500,300);
CRect<int> r3(200,200,300,300);
CRect<int> rTooBig(0,0,1000,1000);
ASSERT(a.Size()==0);
a.Combine(r1);
ASSERT(a.Size()==1);
ASSERT(a.Rect(0,rMax).Equals(r1));
a.Combine(r3);
ASSERT(a.Size()==2);
ASSERT(a.Rect(0,rMax).Equals(r1));
ASSERT(a.Rect(1,rMax).Equals(r3));
a.Combine(r2);
ASSERT(a.Size()==1);
ASSERT(a.Rect(0,rMax).Equals(r2));
a.Combine(rTooBig);
ASSERT(a.Size()==1);
#endif
}
示例14: QVERIFY
void tst_QPicture::boundingRect()
{
QPicture p1;
// default value
QVERIFY( !p1.boundingRect().isValid() );
QRect r1( 20, 30, 5, 15 );
p1.setBoundingRect( r1 );
QCOMPARE( p1.boundingRect(), r1 );
p1.setBoundingRect(QRect());
QPainter pt( &p1 );
pt.drawLine( 10, 20, 110, 80 );
pt.end();
// assignment and copy constructor
QRect r2( 10, 20, 100, 60 );
QCOMPARE( p1.boundingRect(), r2 );
QPicture p2( p1 );
QCOMPARE( p1.boundingRect(), r2 );
QPicture p3;
p3 = p1;
QCOMPARE( p1.boundingRect(), r2 );
{
QPicture p4;
QPainter p(&p4);
p.drawLine(0, 0, 5, 0);
p.drawLine(0, 0, 0, 5);
p.end();
QRect r3(0, 0, 5, 5);
QCOMPARE(p4.boundingRect(), r3);
}
}
示例15: test_reference
template<typename MatrixType> void test_reference(const MatrixType& m) {
typedef typename MatrixType::Scalar Scalar;
enum { Flag = MatrixType::IsRowMajor ? Eigen::RowMajor : Eigen::ColMajor};
enum { TransposeFlag = !MatrixType::IsRowMajor ? Eigen::RowMajor : Eigen::ColMajor};
typename MatrixType::Index rows = m.rows(), cols=m.cols();
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Flag > MatrixX;
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, TransposeFlag> MatrixXT;
// Dynamic reference:
typedef Eigen::Ref<const MatrixX > Ref;
typedef Eigen::Ref<const MatrixXT > RefT;
Ref r1(m);
Ref r2(m.block(rows/3, cols/4, rows/2, cols/2));
RefT r3(m.transpose());
RefT r4(m.topLeftCorner(rows/2, cols/2).transpose());
VERIFY_RAISES_ASSERT(RefT r5(m));
VERIFY_RAISES_ASSERT(Ref r6(m.transpose()));
VERIFY_RAISES_ASSERT(Ref r7(Scalar(2) * m));
// Copy constructors shall also never malloc
Ref r8 = r1;
RefT r9 = r3;
// Initializing from a compatible Ref shall also never malloc
Eigen::Ref<const MatrixX, Unaligned, Stride<Dynamic, Dynamic> > r10=r8, r11=m;
// Initializing from an incompatible Ref will malloc:
typedef Eigen::Ref<const MatrixX, Aligned> RefAligned;
VERIFY_RAISES_ASSERT(RefAligned r12=r10);
VERIFY_RAISES_ASSERT(Ref r13=r10); // r10 has more dynamic strides
}