本文整理匯總了C++中A2函數的典型用法代碼示例。如果您正苦於以下問題:C++ A2函數的具體用法?C++ A2怎麽用?C++ A2使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了A2函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: ls_solve_od
mat ls_solve_od(const mat &A, const mat &B)
{
int m=A.rows(), n=A.cols(), N=B.cols(), j;
double beta;
mat A2(A), B2(B), B3(n,N), submat, submat2;
vec tmp(n), v;
// it_assert1(m >= n, "The system is under-determined!");
//it_assert1(m == B.rows(), "The number of rows in A must equal the number of rows in B!");
// Perform a Householder QR factorization
for (j=0; j<n; j++) {
house(rvectorize(A2(j, m-1, j, j)), v, beta);
v *= sqrt(beta);
// submat.ref(A2, j,m-1, j,n-1);
submat = A2(j,m-1,j,n-1);
sub_v_vT_m(submat, v);
// submat.ref(B2, j,m-1, 0,N-1);
submat = B2(j,m-1,0,N-1);
sub_v_vT_m(submat, v);
}
// submat.ref(A2, 0,n-1,0,n-1);
// submat2.ref(B2, 0,n-1,0,N-1);
submat = A2(0,n-1,0,n-1);
submat2 = B2(0,n-1,0,N-1);
for (j=0; j<N; j++) {
backward_substitution(submat, submat2.get_col(j), tmp);
B3.set_col(j, tmp);
}
return B3;
}
示例2: B
void prefi::initialize()
{
B(0) = 1.0;
A1(0) = 1.0;
A1(1) = 1.0/(2.0*M_PI*fc1);
A2(0) = 1.0;
A2(1) = 1.0/(2.0*M_PI*fc2);
}
示例3: FillPBufferAttribs_ByBits
static void
FillPBufferAttribs_ByBits(nsTArray<EGLint>& aAttrs,
int redBits, int greenBits,
int blueBits, int alphaBits,
int depthBits, int stencilBits)
{
aAttrs.Clear();
#if defined(A1) || defined(A2)
#error The temp-macro names we want are already defined.
#endif
#define A1(_x) do { aAttrs.AppendElement(_x); } while (0)
#define A2(_x,_y) do { A1(_x); A1(_y); } while (0)
A2(LOCAL_EGL_RENDERABLE_TYPE, LOCAL_EGL_OPENGL_ES2_BIT);
A2(LOCAL_EGL_SURFACE_TYPE, LOCAL_EGL_PBUFFER_BIT);
A2(LOCAL_EGL_RED_SIZE, redBits);
A2(LOCAL_EGL_GREEN_SIZE, greenBits);
A2(LOCAL_EGL_BLUE_SIZE, blueBits);
A2(LOCAL_EGL_ALPHA_SIZE, alphaBits);
A2(LOCAL_EGL_DEPTH_SIZE, depthBits);
A2(LOCAL_EGL_STENCIL_SIZE, stencilBits);
A1(LOCAL_EGL_NONE);
#undef A1
#undef A2
}
示例4: main
int main () {
Eigen::MatrixXd A(3,2);
A << -1, 0,
0, -1,
1, 1;
Eigen::VectorXd b(3);
b << 0, 0, 1;
iris::Polyhedron p(A, b);
Eigen::MatrixXd A2(2,2);
A2 << 2, 3,
4, 5;
Eigen::VectorXd b2(2);
b2 << 6, 7;
iris::Polyhedron other(A2, b2);
p.appendConstraints(other);
valuecheck(p.getNumberOfConstraints(), 5);
Eigen::MatrixXd A_expected(5,2);
A_expected << -1, 0,
0, -1,
1, 1,
2, 3,
4, 5;
valuecheckMatrix(p.getA(), A_expected, 1e-12);
return 0;
}
示例5: makeFormattedString
std::string makeFormattedString(
const char* aFormat,
const A1& a1 = A1(),
const A2& a2 = A2(),
const A3& a3 = A3(),
const A4& a4 = A4(),
const A5& a5 = A5(),
const A6& a6 = A6(),
const A7& a7 = A7(),
const A8& a8 = A8(),
const A9& a9 = A9(),
const A10& a10 = A10(),
const A11& a11 = A11(),
const A12& a12 = A12(),
const A13& a13 = A13(),
const A14& a14 = A14(),
const A15& a15 = A15(),
const A16& a16 = A16(),
const A17& a17 = A17(),
const A18& a18 = A18(),
const A19& a19 = A19(),
const A20& a20 = A20()
)
{
return makeStringByPrintf(aFormat,
a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
a11, a12, a13, a14, a15, a16, a17, a18, a19, a20
);
}
示例6: GetOverlapType
eOverlapType GetOverlapType(const CArea& a1, const CArea& a2)
{
CArea A1(a1);
A1.Subtract(a2);
if(A1.m_curves.size() == 0)
{
return eInside;
}
CArea A2(a2);
A2.Subtract(a1);
if(A2.m_curves.size() == 0)
{
return eOutside;
}
A1 = a1;
A1.Intersect(a2);
if(A1.m_curves.size() == 0)
{
return eSiblings;
}
return eCrossing;
}
示例7: inter_cone
void inter_cone(t_caster *caster, t_object *cone)
{
double a;
double b;
double c;
double delt;
init_temp_pos(caster, cone);
a = A2(caster->temp_vec.x, caster->temp_vec.y, caster->temp_vec.z,
cone->data.angle);
b = B2(caster->temp_vec.x, caster->temp_pos.x, caster->temp_vec.y,
caster->temp_pos.y, caster->temp_vec.z, caster->temp_pos.z,
cone->data.angle);
c = C2(caster->temp_pos.x, caster->temp_pos.y, caster->temp_pos.z,
cone->data.angle);
delt = (pow(b, 2.0) - 4.0 * (a * c));
if (delt >= 0.0)
{
cone->dist = get_nearest((-b - sqrt(delt)) / (2.0 * a),
(-b + sqrt(delt)) / (2.0 * a));
if (cone->dist > 0.0 && cone->dist < caster->intersection.dist)
{
caster->intersection.brightness = cone->brightness;
init_intersection(caster, cone);
rotate_caster(caster, cone);
}
}
}
示例8: CPLSafeIntOverflow
inline CPLSafeInt<unsigned> operator*( const CPLSafeInt<unsigned>& A,
const CPLSafeInt<unsigned>& B )
{
#ifdef BUILTIN_OVERFLOW_CHECK_AVAILABLE
unsigned res;
if( __builtin_umul_overflow(A.v(), B.v(), &res) )
throw CPLSafeIntOverflow();
return CPLSM(res);
#elif defined(_MSC_VER)
msl::utilities::SafeInt<unsigned, CPLMSVCSafeIntException> A2(A.v());
msl::utilities::SafeInt<unsigned, CPLMSVCSafeIntException> B2(B.v());
return CPLSM(static_cast<unsigned>(A2 * B2));
#elif defined(CPL_HAS_GINT64)
const unsigned a = A.v();
const unsigned b = B.v();
const GUInt64 res = static_cast<GUInt64>(a) * b;
if( res > std::numeric_limits<unsigned>::max() )
{
throw CPLSafeIntOverflow();
}
return CPLSM(static_cast<unsigned>(res));
#else
const unsigned a = A.v();
const unsigned b = B.v();
if( b > 0 && a > std::numeric_limits<unsigned>::max() / b )
throw CPLSafeIntOverflow();
return CPLSM(a*b);
#endif
}
示例9: main
int main(){
TTableContext Context;
// create scheme
Schema AnimalS;
AnimalS.Add(TPair<TStr,TAttrType>("Animal", atStr));
AnimalS.Add(TPair<TStr,TAttrType>("Size", atStr));
AnimalS.Add(TPair<TStr,TAttrType>("Location", atStr));
AnimalS.Add(TPair<TStr,TAttrType>("Number", atInt));
TIntV RelevantCols;
RelevantCols.Add(0);
RelevantCols.Add(1);
RelevantCols.Add(2);
// create table
PTable T = TTable::LoadSS("Animals", AnimalS, "tests/animals.txt", Context, RelevantCols);
//PTable T = TTable::LoadSS("Animals", AnimalS, "animals.txt");
T->Unique("Animal");
TTable Ts = *T; // did we fix problem with copy-c'tor ?
//PTable Ts = TTable::LoadSS("Animals_s", AnimalS, "../../testfiles/animals.txt", RelevantCols);
//Ts->Unique(AnimalUnique);
// test Select
// create predicate tree: find all animals that are big and african or medium and Australian
TPredicate::TAtomicPredicate A1(atStr, true, EQ, "Location", "", 0, 0, "Africa");
TPredicate::TPredicateNode N1(A1); // Location == "Africa"
TPredicate::TAtomicPredicate A2(atStr, true, EQ, "Size", "", 0, 0, "big");
TPredicate::TPredicateNode N2(A2); // Size == "big"
TPredicate::TPredicateNode N3(AND);
N3.AddLeftChild(&N1);
N3.AddRightChild(&N2);
TPredicate::TAtomicPredicate A4(atStr, true, EQ, "Location", "", 0, 0, "Australia");
TPredicate::TPredicateNode N4(A4);
TPredicate::TAtomicPredicate A5(atStr, true, EQ, "Size", "", 0, 0, "medium");
TPredicate::TPredicateNode N5(A5);
TPredicate::TPredicateNode N6(AND);
N6.AddLeftChild(&N4);
N6.AddRightChild(&N5);
TPredicate::TPredicateNode N7(OR);
N7.AddLeftChild(&N3);
N7.AddRightChild(&N6);
TPredicate Pred(&N7);
TIntV SelectedRows;
Ts.Select(Pred, SelectedRows);
TStrV GroupBy;
GroupBy.Add("Location");
T->Group(GroupBy, "LocationGroup");
GroupBy.Add("Size");
T->Group(GroupBy, "LocationSizeGroup");
T->Count("LocationCount", "Location");
PTable Tj = T->Join("Location", Ts, "Location");
TStrV UniqueAnimals;
UniqueAnimals.Add("Animals_1.Animal");
UniqueAnimals.Add("Animals_2.Animal");
Tj->Unique(UniqueAnimals, false);
//print table
T->SaveSS("tests/animals_out_T.txt");
Ts.SaveSS("tests/animals_out_Ts.txt");
Tj->SaveSS("tests/animals_out_Tj.txt");
return 0;
}
示例10: A2
bool PGCicrcleTaskPt::CrossPoint(const ProjPt& prev, const ProjPt& next, ProjPt& optimized) {
ProjPt A = prev - m_Center;
ProjPt B = next - m_Center;
ProjPt A2(A.m_X * A.m_X, A.m_Y * A.m_Y);
ProjPt B2(B.m_X * B.m_X, B.m_Y * B.m_Y);
double R2 = (m_Radius * m_Radius);
bool PrevOutside = (A2.m_X + A2.m_Y) > R2;
bool NextOutside = (B2.m_X + B2.m_Y) > R2;
if (!PrevOutside && !NextOutside) {
return false; // no cross point
}
ProjPt AB = B - A;
double a = (AB.m_X * AB.m_X) + (AB.m_Y * AB.m_Y);
double b = 2 * ((AB.m_X * A.m_X) + (AB.m_Y * A.m_Y));
double c = A2.m_X + A2.m_Y - R2;
double bb4ac = (b * b) -(4 * a * c);
if (bb4ac < 0.0) {
return false;
}
bool bCrossPoint = false;
double k = 0.0;
if (bb4ac == 0.0) {
LKASSERT(a);
// one point
k = -b / (2 * a);
bCrossPoint = true;
}
if (bb4ac > 0.0) {
// Two point,
if ((PrevOutside && m_bExit) || (!PrevOutside && NextOutside)) {
LKASSERT(a);
k = (-b + sqrt(bb4ac)) / (2 * a); // ouput : prev ouside && Exit TP || prev inside && next outside
bCrossPoint = true;
} else {
LKASSERT(a);
k = (-b - sqrt(bb4ac)) / (2 * a); // input : prev outside && Enter TP
bCrossPoint = true;
}
}
if (bCrossPoint) {
ProjPt O = prev + ((next - prev) * k);
if (dot_product((next - prev), O - prev) > 0.0 &&
dot_product((prev - next), O - next) > 0.0) {
optimized = O;
return true;
}
}
// no point
return false;
}
示例11: vecpot2b3i
/*! \fn Real vecpot2b3i(Real (*A1)(Real,Real,Real), Real (*A2)(Real,Real,Real),
* const GridS *pG, const int i, const int j, const int k)
* \brief Compute B-field components from a vector potential.
*
* THESE FUNCTIONS COMPUTE MAGNETIC FIELD COMPONENTS FROM COMPONENTS OF A
* SPECIFIED VECTOR POTENTIAL USING STOKES' THEOREM AND SIMPSON'S QUADRATURE.
* NOTE: THIS IS ONLY GUARANTEED TO WORK IF THE POTENTIAL IS OF CLASS C^1.
* WRITTEN BY AARON SKINNER.
*/
Real vecpot2b3i(Real (*A1)(Real,Real,Real), Real (*A2)(Real,Real,Real),
const GridS *pG, const int i, const int j, const int k)
{
Real x1,x2,x3,b3i=0.0,lsf=1.0,rsf=1.0,dx2=pG->dx2;
Real f1(Real x);
Real f2(Real y);
a1func = A1;
a2func = A2;
cc_pos(pG,i,j,k,&x1,&x2,&x3);
xmin = x1 - 0.5*pG->dx1; xmax = x1 + 0.5*pG->dx1;
ymin = x2 - 0.5*pG->dx2; ymax = x2 + 0.5*pG->dx2;
zmin = x3 - 0.5*pG->dx3; zmax = x3 + 0.5*pG->dx3;
zsav = zmin;
#ifdef CYLINDRICAL
rsf = xmax; lsf = xmin;
dx2 = x1*pG->dx2;
#endif
if (A1 != NULL) {
if (xmin == xmax)
b3i += A1(xmin,ymin,zmin) - A1(xmin,ymax,zmin);
else {
ysav = ymin;
b3i += qsimp(f1,xmin,xmax);
ysav = ymax;
b3i -= qsimp(f1,xmin,xmax);
}
}
if (A2 != NULL) {
if (ymin == ymax)
b3i += rsf*A2(xmax,ymin,zmin) - lsf*A2(xmin,ymin,zmin);
else {
xsav = xmax;
b3i += rsf*qsimp(f2,ymin,ymax);
xsav = xmin;
b3i -= lsf*qsimp(f2,ymin,ymax);
}
}
if (pG->dx1 > 0.0) b3i /= pG->dx1;
if (pG->dx2 > 0.0) b3i /= dx2;
return b3i;
}
示例12: uv
std::vector < Derived > lidarBoostEngine::lk_optical_flow( const MatrixBase<Derived>& I1, const MatrixBase<Derived> &I2, int win_sz)
{
//Instantiate optical flow matrices
std::vector < Derived > uv(2);
//Create masks
Matrix2d robX, robY, robT;
robX << -1, 1,
-1, 1;
robY << -1, -1,
1, 1;
robT << -1, -1,
-1, -1;
Derived Ix, Iy, It, A, solutions, x_block, y_block, t_block;
//Apply masks to images and average the result
Ix = 0.5 * ( conv2d( I1, robX ) + conv2d( I2, robX ) );
Iy = 0.5 * ( conv2d( I1, robY ) + conv2d( I2, robY ) );
It = 0.5 * ( conv2d( I1, robT ) + conv2d( I2, robT ) );
uv[0] = Derived::Zero( I1.rows(), I1.cols() );
uv[1] = Derived::Zero( I1.rows(), I1.cols() );
int hw = win_sz/2;
for( int i = hw+1; i < I1.rows()-hw; i++ )
{
for ( int j = hw+1; j < I1.cols()-hw; j++ )
{
//Take a small block of window size in the filtered images
x_block = Ix.block( i-hw, j-hw, win_sz, win_sz);
y_block = Iy.block( i-hw, j-hw, win_sz, win_sz);
t_block = It.block( i-hw, j-hw, win_sz, win_sz);
//Convert these blocks in vectors
Map<Derived> A1( x_block.data(), win_sz*win_sz, 1);
Map<Derived> A2( y_block.data(), win_sz*win_sz, 1);
Map<Derived> B( t_block.data(), win_sz*win_sz, 1);
//Organize the vectors in a matrix
A = Derived( win_sz*win_sz, 2 );
A.block(0, 0, win_sz*win_sz, 1) = A1;
A.block(0, 1, win_sz*win_sz, 1) = A2;
//Solve the linear least square system
solutions = (A.transpose() * A).ldlt().solve(A.transpose() * B);
//Insert the solutions in the optical flow matrices
uv[0](i, j) = solutions(0);
uv[1](i, j) = solutions(1);
}
}
return uv;
}
示例13: main
int main()
{
// Primary Operators
AnnihilationOperator A1(0); // 1st freedom
NumberOperator N1(0);
IdentityOperator Id1(0);
AnnihilationOperator A2(1); // 2nd freedom
NumberOperator N2(1);
IdentityOperator Id2(1);
SigmaPlus Sp(2); // 3rd freedom
IdentityOperator Id3(2);
Operator Sm = Sp.hc(); // Hermitian conjugate
Operator Ac1 = A1.hc();
Operator Ac2 = A2.hc();
// Hamiltonian
double E = 20.0;
double chi = 0.4;
double omega = -0.7;
double eta = 0.001;
Complex I(0.0,1.0);
Operator H = (E*I)*(Ac1-A1)
+ (0.5*chi*I)*(Ac1*Ac1*A2 - A1*A1*Ac2)
+ omega*Sp*Sm + (eta*I)*(A2*Sp-Ac2*Sm);
// Lindblad operators
double gamma1 = 1.0;
double gamma2 = 1.0;
double kappa = 0.1;
const int nL = 3;
Operator L[nL]={sqrt(2*gamma1)*A1,sqrt(2*gamma2)*A2,sqrt(2*kappa)*Sm};
// Initial state
State phi1(50,FIELD); // see paper Section 4.2
State phi2(50,FIELD);
State phi3(2,SPIN);
State stateList[3] = {phi1,phi2,phi3};
State psiIni(3,stateList);
// Trajectory
double dt = 0.01; // basic time step
int numdts = 100; // time interval between outputs = numdts*dt
int numsteps = 5; // total integration time = numsteps*numdts*dt
int nOfMovingFreedoms = 2;
double epsilon = 0.01; // cutoff probability
int nPad = 2; // pad size
//ACG gen(38388389); // random number generator with seed
//ComplexNormal rndm(&gen); // Complex Gaussian random numbers
ComplexNormalTest rndm(899101); // Simple portable random number generator
AdaptiveStep stepper(psiIni, H, nL, L); // see paper Section 5
// Output
const int nOfOut = 3;
Operator outlist[nOfOut]={ Sp*A2*Sm*Sp, Sm*Sp*A2*Sm, A2 };
char *flist[nOfOut]={"X1.out","X2.out","A2.out"};
int pipe[] = {1,5,9,11}; // controls standard output (see `onespin.cc')
// Simulate one trajectory (for several trajectories see `onespin.cc')
Trajectory traj(psiIni, dt, stepper, &rndm); // see paper Section 5
traj.plotExp( nOfOut, outlist, flist, pipe, numdts, numsteps,
nOfMovingFreedoms, epsilon, nPad );
}
示例14: testQLDSolver
void testQLDSolver()
{
BaseVariable xy("xy",2);
BaseVariable z("z",1);
CompositeVariable T("T", xy, z);
MatrixXd A1(1,1); A1 << 1;
VectorXd b1(1); b1 << -3;
LinearFunction lf1(z, A1, b1);
LinearConstraint c1(&lf1, true);
MatrixXd A2(1,2); A2 << 3,1 ;
VectorXd b2(1); b2 << 0;
LinearFunction lf2(xy, A2, b2);
LinearConstraint c2(&lf2, true);
MatrixXd A3(2,2); A3 << 2,1,-0.5,1 ;
VectorXd b3(2); b3 << 0, 1;
LinearFunction lf3(xy, A3, b3);
LinearConstraint c3(&lf3, false);
QuadraticFunction objFunc(T, Matrix3d::Identity(), Vector3d::Zero(), 0);
QuadraticObjective obj(&objFunc);
QLDSolver solver;
solver.addConstraint(c1);
solver.addConstraint(c2);
solver.addConstraint(c3);
solver.addObjective(obj);
std::cout << "sol = " << std::endl << solver.solve().solution << std::endl << std::endl;
ocra_assert(solver.getLastResult().info == 0);
solver.removeConstraint(c1);
IdentityFunction id(z);
VectorXd lz(1); lz << 1;
VectorXd uz(1); uz << 2;
IdentityConstraint bnd1(&id, lz, uz);
solver.addBounds(bnd1);
std::cout << "sol = " << std::endl << solver.solve().solution << std::endl << std::endl;
ocra_assert(solver.getLastResult().info == 0);
BaseVariable t("t", 2);
VectorXd ut(2); ut << -4,-1;
BoundFunction bf(t, ut, BOUND_TYPE_SUPERIOR);
BoundConstraint bnd2(&bf, false);
solver.addBounds(bnd2);
QuadraticFunction objFunc2(t, Matrix2d::Identity(), Vector2d::Constant(2.71828),0);
QuadraticObjective obj2(&objFunc2);
solver.addObjective(obj2);
std::cout << "sol = " << std::endl << solver.solve().solution << std::endl << std::endl;
ocra_assert(solver.getLastResult().info == 0);
Vector2d c3l(-1,-1);
c3.setL(c3l);
std::cout << "sol = " << std::endl << solver.solve().solution << std::endl << std::endl;
ocra_assert(solver.getLastResult().info == 0);
}
示例15: vecpot2b1i
/*! \fn Real vecpot2b1i(Real (*A2)(Real,Real,Real), Real (*A3)(Real,Real,Real),
* const GridS *pG, const int i, const int j, const int k)
* \brief Compute B-field components from a vector potential.
*
* THESE FUNCTIONS COMPUTE MAGNETIC FIELD COMPONENTS FROM COMPONENTS OF A
* SPECIFIED VECTOR POTENTIAL USING STOKES' THEOREM AND SIMPSON'S QUADRATURE.
* NOTE: THIS IS ONLY GUARANTEED TO WORK IF THE POTENTIAL IS OF CLASS C^1.
* WRITTEN BY AARON SKINNER.
*/
Real vecpot2b1i(Real (*A2)(Real,Real,Real), Real (*A3)(Real,Real,Real),
const GridS *pG, const int i, const int j, const int k)
{
Real x1,x2,x3,b1i=0.0,lsf=1.0,rsf=1.0,dx2=pG->dx2;
Real f2(Real y);
Real f3(Real z);
a2func = A2;
a3func = A3;
cc_pos(pG,i,j,k,&x1,&x2,&x3);
xmin = x1 - 0.5*pG->dx1; xmax = x1 + 0.5*pG->dx1;
ymin = x2 - 0.5*pG->dx2; ymax = x2 + 0.5*pG->dx2;
zmin = x3 - 0.5*pG->dx3; zmax = x3 + 0.5*pG->dx3;
xsav = xmin;
#ifdef CYLINDRICAL
lsf = xmin; rsf = xmin;
dx2 = xmin*pG->dx2;
#endif
if (A2 != NULL) {
if (ymin == ymax)
b1i += rsf*A2(xmin,ymin,zmin) - lsf*A2(xmin,ymin,zmax);
else {
zsav = zmin;
b1i += rsf*qsimp(f2,ymin,ymax);
zsav = zmax;
b1i -= lsf*qsimp(f2,ymin,ymax);
}
}
if (A3 != NULL) {
if (zmin == zmax)
b1i += A3(xmin,ymax,zmin) - A3(xmin,ymin,zmin);
else {
ysav = ymax;
b1i += qsimp(f3,zmin,zmax);
ysav = ymin;
b1i -= qsimp(f3,zmin,zmax);
}
}
if (pG->dx2 > 0.0) b1i /= dx2;
if (pG->dx3 > 0.0) b1i /= pG->dx3;
return b1i;
}