本文整理汇总了C++中s0函数的典型用法代码示例。如果您正苦于以下问题:C++ s0函数的具体用法?C++ s0怎么用?C++ s0使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了s0函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: d0
void StokesPreconditioner::vmult (Vector<double> &dst,
const Vector<double> &src) const
{
int n_dof_v = Ax->n();
int n_dof_p = Q->n();
Vector<double> d0(n_dof_v);
Vector<double> d1(n_dof_v);
Vector<double> s0(n_dof_v);
Vector<double> s1(n_dof_v);
for (int i = 0; i < n_dof_v; ++i)
s0(i) = src(i);
for (int i = 0; i < n_dof_v; ++i)
s1(i) = src(n_dof_v + i);
for (int i = 0; i < n_dof_p; ++i)
dst(2 * n_dof_v + i) = src(2 * n_dof_v + i) / (*Q).diag_element(i);
AMGx.solve(d0, s0, 1e-8, 1, 1);
AMGy.solve(d1, s1, 1e-8, 1, 1);
for (int i = 0; i < n_dof_v; ++i)
dst(i) = d0(i);
for (int i = 0; i < n_dof_v; ++i)
dst(n_dof_v + i) = d1(i);
};
示例2: test_disconnect_equal
static void
test_disconnect_equal()
{
boost::signals2::signal<void ()> s0;
connections[0] = s0.connect(remove_connection(0));
connections[1] = s0.connect(remove_connection(1));
connections[2] = s0.connect(remove_connection(2));
connections[3] = s0.connect(remove_connection(3));
std::cout << "Deleting 2" << std::endl;
test_output = "";
s0(); std::cout << std::endl;
BOOST_CHECK(test_output == "0123");
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
connections[2].disconnect();
#else
s0.disconnect(remove_connection(2));
#endif
test_output = "";
s0(); std::cout << std::endl;
BOOST_CHECK(test_output == "013");
}
示例3: checkPolyline
void checkPolyline(const vector<T3DPointD> &p)
{
int ret;
if (p.size() < 3)
return;
TPointD p1;
TPointD p2;
int pointSize = (int)p.size() - 1;
for (int i = 0; i < pointSize; i++) {
for (int j = i + 1; j < pointSize; j++) {
vector<DoublePair> res;
p1 = TPointD(p[i].x, p[i].y);
p2 = TPointD(p[i + 1].x, p[i + 1].y);
TSegment s0(p1, p2);
p1 = TPointD(p[j].x, p[j].y);
p2 = TPointD(p[j + 1].x, p[j + 1].y);
TSegment s1(p1, p2);
ret = intersect(s0, s1, res);
if (ret)
assert(
(ret == 1) &&
(areAlmostEqual(res[0].first, 1) ||
areAlmostEqual(res[0].first, 0)) &&
(areAlmostEqual(res[0].second, 1) ||
areAlmostEqual(res[0].second, 0)));
}
}
p1 = TPointD(p.back().x, p.back().y);
p2 = TPointD(p[0].x, p[0].y);
TSegment s0(p1, p2);
for (int j = 0; j < pointSize; j++) {
vector<DoublePair> res;
p1 = TPointD(p[j].x, p[j].y);
p2 = TPointD(p[j + 1].x, p[j + 1].y);
TSegment s1(p1, p2);
ret = intersect(s0, s1, res);
if (ret)
assert(
(ret == 1) &&
(areAlmostEqual(res[0].first, 1) ||
areAlmostEqual(res[0].first, 0)) &&
(areAlmostEqual(res[0].second, 1) ||
areAlmostEqual(res[0].second, 0)));
}
}
示例4: s0
void CAstar::Astar(CAstarNode*& result)
{
CAstarNode s0(m_hgevStart,0,CalculateH(m_hgevStart),NULL);
//open表中插入起点
m_vOpenList.push_back(s0);
make_heap(m_vOpenList.begin(),m_vOpenList.end());
// CAstarNode* min;
while(!m_vOpenList.empty())
{
//pop出堆顶节点
pop_heap(m_vOpenList.begin(),m_vOpenList.end(),cmpAstarNode);
result = new CAstarNode(m_vOpenList.back().m_hgevCoordinate,m_vOpenList.back().m_nG,
m_vOpenList.back().m_nH, m_vOpenList.back().m_pParent);
//若节点是目标节点,则返回
if(result->m_hgevCoordinate == m_hgevGoal)
{
// memcpy(result,&min,sizeof(CAstarNode));
return ;
}
m_vOpenList.pop_back();
// make_heap(m_vOpenList.begin(),m_vOpenList.end());
//扩展该节点
ExtendNode(result);
// make_heap(m_vOpenList.begin(),m_vOpenList.end());
m_vClosedList.push_back(*result);
}
result = NULL;
}
示例5: weak_1
// Copy weak, access via shared
void weak_1()
{
assert_ck(0, 0);
{
shared_test s0(test_behavior::init());
assert_ck(1, 0);
weak_test w0(s0);
assert_ck(1, 0);
auto w1(w0);
assert_ck(1, 0);
assert(!w0.expired());
assert(w0.use_count() == 1);
assert(!w1.expired());
assert(w1.use_count() == 1);
assert(w0.lock().get() == w1.lock().get());
}
assert_ck(1, 1);
}
示例6: Test
void Test() {
std::string str('x', 4);
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructor parameters are probably swapped [misc-string-constructor]
std::wstring wstr(L'x', 4);
// CHECK-MESSAGES: [[@LINE-1]]:16: warning: constructor parameters are probably swapped
std::string s0(0, 'x');
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructor creating an empty string
std::string s1(-4, 'x');
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: negative value used as length parameter
std::string s2(0x1000000, 'x');
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: suspicious large length parameter
std::string q0("test", 0);
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructor creating an empty string
std::string q1(kText, -4);
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: negative value used as length parameter
std::string q2("test", 200);
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger then string literal size
std::string q3(kText, 200);
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger then string literal size
std::string q4(kText2, 200);
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger then string literal size
std::string q5(kText3, 0x1000000);
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: suspicious large length parameter
}
示例7: test_2
void test_2()
{
// Test bounding_box() for Point_2
Point_2 p0 (1, 2);
Point_2 p1 (2, 1);
std::vector<Point_2> pts;
pts.push_back(p0);
pts.push_back(p0);
pts.push_back(p1);
assert( CGAL::bounding_box(pts.begin(), pts.end())
== K::Iso_rectangle_2(p0, p1));
#if 0 // Does not work yet
// Test bounding_box() for Segment_2
Segment_2 s0 (p0, p1);
Segment_2 s1 (p0, p0);
std::vector<Segment_2> segs;
segs.push_back(s0);
segs.push_back(s0);
segs.push_back(s1);
assert( CGAL::bounding_box(segs.begin(), segs.end())
== K::Iso_rectangle_2(p0, p1));
#endif
}
示例8: s0
Float SoftCylinderPairScore::evaluate_index(
kernel::Model *m, const kernel::ParticleIndexPair &pip,
DerivativeAccumulator *da) const {
atom::Bond b[2] = {atom::Bond(m, pip[0]), atom::Bond(m, pip[1])};
core::XYZR d[2][2] = {
{core::XYZR(b[0].get_bonded(0)), core::XYZR(b[0].get_bonded(1))},
{core::XYZR(b[1].get_bonded(0)), core::XYZR(b[1].get_bonded(1))}};
algebra::Segment3D s0(d[0][0].get_coordinates(), d[0][1].get_coordinates());
algebra::Segment3D s1(d[1][0].get_coordinates(), d[1][1].get_coordinates());
algebra::Segment3D ss = algebra::get_shortest_segment(s0, s1);
if (ss.get_length() < d[0][0].get_radius() + d[1][0].get_radius()) {
double diff = d[0][0].get_radius() + d[1][0].get_radius() - ss.get_length();
double score = .5 * k_ * square(diff);
if (da) {
double deriv = k_ * diff;
algebra::Vector3D v = ss.get_point(1) - ss.get_point(0);
algebra::Vector3D uv = v.get_unit_vector();
algebra::Vector3D duv = deriv * uv;
d[0][0].add_to_derivatives(-duv, *da);
d[0][1].add_to_derivatives(-duv, *da);
d[1][0].add_to_derivatives(duv, *da);
d[1][1].add_to_derivatives(duv, *da);
}
return score;
} else {
return 0;
}
}
示例9: main
int main() {
Direction d = D;
Direction u = U;
Shift s0(d, 1);
Shift s1(d, 0);
std::vector<Shift> shifts;
s0.string_vec.push_back(0);
s0.string_vec.push_back(1);
s0.string_vec.push_back(0);
s0.string_vec.push_back(3);
s1.string_vec.push_back(0);
s1.string_vec.push_back(1);
s1.string_vec.push_back(0);
s1.string_vec.push_back(3);
if (s0 < s1) {
std::cout << "s0 < s1\n";
} else {
std::cout << "s0 > s1\n";
}
shifts.push_back(s0);
shifts.push_back(s1);
std::sort(shifts.begin(), shifts.end());
for (Shift s : shifts) {
std::cout << "id: " << s.id << ", str: ";
for (int i = 0; i < 4; i++) {
std::cout << s.string_vec[i] << " ";
}
std::cout << "\n";
}
}
示例10: _BRSHA256Compress
static void _BRSHA256Compress(uint32_t *r, uint32_t *x)
{
static const uint32_t k[] = {
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
};
int i;
uint32_t a = r[0], b = r[1], c = r[2], d = r[3], e = r[4], f = r[5], g = r[6], h = r[7], t1, t2, w[64];
for (i = 0; i < 16; i++) w[i] = be32(x[i]);
for (; i < 64; i++) w[i] = s3(w[i - 2]) + w[i - 7] + s2(w[i - 15]) + w[i - 16];
for (i = 0; i < 64; i++) {
t1 = h + s1(e) + ch(e, f, g) + k[i] + w[i];
t2 = s0(a) + maj(a, b, c);
h = g, g = f, f = e, e = d + t1, d = c, c = b, b = a, a = t1 + t2;
}
r[0] += a, r[1] += b, r[2] += c, r[3] += d, r[4] += e, r[5] += f, r[6] += g, r[7] += h;
var_clean(&a, &b, &c, &d, &e, &f, &g, &h, &t1, &t2);
mem_clean(w, sizeof(w));
}
示例11: formula_s0
PyObject* formula_s0(PyObject* self, PyObject* args)
{
float a, b, c, d, e, f;
if (!PyArg_ParseTuple(args, "ffffff", &a, &b, &c, &d, &e, &f))
return NULL;
return Py_BuildValue("f", s0(a,b,c,d,e,f));
}
示例12: main
int main()
{
void h0(float, float);
void e0(float, float);
void s0(float, float);
float a, b, c;
printf("请输入a,b,c:");
scanf("%f,%f,%f", &a, &b, &c);
printf("方程为:%5.2fx*x+%5.2fx+%5.2f=0\n", a, b, c);
Delta = b*b - 4 * a*c;
printf("结果是:\n");
if (Delta > 0)
{
h0(a, b);
printf("x1=%f\nx2=%f\n", x1, x2);
}
else if (Delta < 0)
{
s0(a, b);
printf("x1=%f+%fi\nx2=%f-%fi\n", m, n, m, n);
}
else
{
e0(a, b);
printf("x1=x2=%f\n", x1);
}
return 0;
}
示例13: main
int main()
{
/* Value constructor */
cv::Scalar s0(10); // (10,0,0,0)
cv::Scalar s(0.5,1.25,2.75,3.0);
std::cout << "s0(10) " << s0 << std::endl;
std::cout << "s(0.5,1.25,2.75,3.0) " << s << std::endl;
/* Element-wise mult */
cv::Scalar prod = s.mul(cv::Scalar(6.5, 7.5, 8.5, 9.5));
std::cout << "prod: " << prod << std::endl;
/* (Quaternion) conjugation */
std::cout << "s conj: " << s.conj() << std::endl;
/* (Quaternion) real test */
if (s0.isReal()) std::cout << s0 << " is real" << std::endl;
else std::cout << s0 << " is not real." << std::endl;
/* (Quaternion) real test */
if (s.isReal()) std::cout << s << " is real" << std::endl;
else std::cout << s << " is not real." << std::endl;
}
示例14: print_table
void print_table(str s, const Ptable& T) {
printf("%s", s.c_str()); printf("\n");
int l = T.size();
if (l==0) {
printf(" ! Empty table\n");
return;
}
int c = T[0].size();
for (int i=0; i<l; i++) {
if (T[i].size()!=c) {
printf(" ! Table has different number of columns depending to the lines\n");
return;
}
}
str s0(" ",10);
const char* space = s0.c_str();
printf("%s", space);
for (int j=0; j<c; j++) printf("%11d",j);
printf("\n");
for (int i=0; i<l; i++) {
printf("%4d",i);
for (int j=0; j<c; j++) printf("%11s",p2s(T[i][j]).c_str());
printf("\n");
}
printf("\n");
}
示例15: s0
string parser::preprocess_input(istream &stream)
{
streampos start = stream.tellg();
stream.seekg(0, ios::end);
streampos end = stream.tellg();
size_t file_size = end - start;
stream.seekg(start, ios::beg);
char bom_test[3];
static const char * BOM = "\xEF\xBB\xBF";
stream.read(bom_test, 3u);
if (strncmp(bom_test, BOM, 3u) == 0) {
// Matched BOM, keep stream position to prevent its reading
file_size -= 3u;
}
else {
// Seek stream back
stream.seekg(start, ios::beg);
}
char * buffer = new char[file_size + 1];
stream.read(buffer, file_size);
buffer[file_size] = '\0';
string s0(buffer);
delete[] buffer;
string s1 = fix_corrupted_data(s0);
return s1;
}